-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecoBlockCabinet.java
291 lines (237 loc) · 8.73 KB
/
DecoBlockCabinet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package net.minecraft.src;
public class DecoBlockCabinet extends Block
{
private String m_Tag;
public DecoBlockCabinet(int id, String tag)
{
super(id, Material.wood);
this.setUnlocalizedName("decoBlockCabinet." + tag);
this.setHardness(2.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundWoodFootstep);
this.setCreativeTab(CreativeTabs.tabDecorations);
Block.useNeighborBrightness[id] = true;
Block.lightOpacity[id] = 255;
this.m_Tag = tag;
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
public int idPicked(World world, int x, int y, int z)
{
return world.getBlockId(x, y, z);
}
/**
* Get the block's damage value (for use with pick block).
*/
public int getDamageValue(World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z);
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int metadata)
{
return metadata;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (side < 2) side = 2;
else side = FCUtilsMisc.GetOppositeFacing(side);
return this.SetFacingInMetadata(metadata, side);
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity, ItemStack itemStack)
{
int metadata = FCUtilsMisc.ConvertOrientationToFlatBlockFacingReversed(entity);
this.SetFacing(world, x, y, z, metadata);
}
public boolean DoesBlockHaveSolidTop(IBlockAccess bAccess, int x, int y, int z)
{
return true;
}
public int GetFacing(IBlockAccess bAccess, int x, int y, int z)
{
return bAccess.getBlockMetadata(x, y, z);
}
public void SetFacing(World world, int x, int y, int z, int direction)
{
world.setBlockMetadataWithNotify(x, y, z, direction);
}
public int GetFacingFromMetadata(int metadata)
{
return metadata;
}
public int SetFacingInMetadata(int direction, int metadata)
{
return metadata;
}
public boolean CanRotateOnTurntable(IBlockAccess bAccess, int x, int y, int z)
{
return true;
}
public boolean CanTransmitRotationHorizontallyOnTurntable(IBlockAccess bAccess, int x, int y, int z)
{
return false;
}
public boolean CanTransmitRotationVerticallyOnTurntable(IBlockAccess bAccess, int x, int y, int z)
{
return false;
}
public boolean RotateAroundJAxis(World world, int x, int y, int z, boolean var5)
{
return FCUtilsMisc.StandardRotateAroundJ(this, world, x, y, z, var5);
}
public int RotateMetadataAroundJAxis(int metadata, boolean var2)
{
return FCUtilsMisc.StandardRotateMetadataAroundJ(this, metadata, var2);
}
public boolean ToggleFacing(World world, int x, int y, int z, boolean var5)
{
this.RotateAroundJAxis(world, x, y, z, var5);
return true;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or
* not to render the shared face of two adjacent blocks and also whether the
* player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False
* (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
public boolean shouldSideBeRendered(IBlockAccess bAccess, int x, int y, int z, int side)
{
return true;
}
/**
* When this method is called, your block should register all the icons it needs
* with the given IconRegister. This is the only chance you get to register
* icons.
*/
public void registerIcons(IconRegister register)
{
this.blockIcon = register.registerIcon("decoBlockFurniture_" + this.m_Tag);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
int direction = this.GetFacing(world, x, y, z);
return direction != 2 && direction != 3 ? AxisAlignedBB.getAABBPool().getAABB((double) ((float) x), (double) ((float) y), (double) ((float) z),
(double) ((float) x + 1.0F), (double) ((float) y + 1.0F), (double) ((float) z + 1.0F))
: AxisAlignedBB.getAABBPool().getAABB((double) ((float) x), (double) ((float) y), (double) ((float) z),
(double) ((float) x + 1.0F), (double) ((float) y + 1.0F), (double) ((float) z + 1.0F));
}
public void setBlockBoundsBasedOnState(IBlockAccess bAccess, int x, int y, int z)
{
int direction = GetFacing(bAccess, x, y, z);
float rotatedMinX;
float rotatedMinZ;
float rotatedMaxX;
float rotatedMaxZ;
if (direction == 4)
{
rotatedMinX = 1.0F - 1.0F;
rotatedMinZ = 1.0F - 1.0F;
rotatedMaxX = 1.0F - 0.0F;
rotatedMaxZ = 1.0F - 0.0F;
}
else if (direction == 3)
{
rotatedMinX = 0.0F;
rotatedMinZ = 0.0F;
rotatedMaxX = 1.0F;
rotatedMaxZ = 1.0F;
}
else if (direction == 2)
{
rotatedMinX = 1.0F - 1.0F;
rotatedMinZ = 1.0F - 1.0F;
rotatedMaxX = 1.0F - 0.0F;
rotatedMaxZ = 1.0F - 0.0F;
}
else
{
rotatedMinX = 0.0F;
rotatedMinZ = 0.0F;
rotatedMaxX = 1.0F;
rotatedMaxZ = 1.0F;
}
this.setBlockBounds(rotatedMinX, 0.0F, rotatedMinZ, rotatedMaxX, 1.0F, rotatedMaxZ);
}
public boolean RenderBlock(RenderBlocks render, int x, int y, int z)
{
int direction = GetFacing(render.blockAccess, x, y, z);
// LEG: NW
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.025F, 0.0F, 0.025F, 0.15F, 0.85F, 0.15F, direction);
render.renderStandardBlock(this, x, y, z);
// LEG: NE
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.025F, 0.0F, 0.85F, 0.15F, 0.85F, 0.975F, direction);
render.renderStandardBlock(this, x, y, z);
// LEG: SW
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.85F, 0.0F, 0.025F, 0.975F, 0.85F, 0.15F, direction);
render.renderStandardBlock(this, x, y, z);
// LEG: SE
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.85F, 0F, 0.85F, 0.975F, 0.85F, 0.975F, direction);
render.renderStandardBlock(this, x, y, z);
// SHELF: BOTTOM
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.1F, 0.3F, 0.1F, 0.9F, 0.4F, 0.9F, direction);
render.renderStandardBlock(this, x, y, z);
// SHELF: TOP
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.1F, 0.5F, 0.1F, 0.9F, 0.6F, 0.9F, direction);
render.renderStandardBlock(this, x, y, z);
// SIDE: BACK
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.05F, 0.3F, 0.05F, 0.95F, 0.85F, 0.1F, direction);
render.renderStandardBlock(this, x, y, z);
// SIDE: LEFT
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.05F, 0.3F, 0.05F, 0.1F, 0.85F, 0.95F, direction);
render.renderStandardBlock(this, x, y, z);
// SIDE: RIGHT
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.05F, 0.3F, 0.9F, 0.95F, 0.85F, 0.95F, direction);
render.renderStandardBlock(this, x, y, z);
// TOP
DecoUtilsRender.setRenderBoundsRotatedAboutJToFacing(render, 0.0F, 0.85F, 0.0F, 1.0F, 1.0F, 1.0F, direction);
render.renderStandardBlock(this, x, y, z);
return true;
}
public void RenderBlockAsItem(RenderBlocks render, int var2, float var3)
{
// LEG: NW
render.setRenderBounds(0.0F, 0.0F, 0.0F, 0.15F, 0.85F, 0.15F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// LEG: NE
render.setRenderBounds(0.0F, 0.0F, 0.85F, 0.15F, 0.85F, 1.0F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// LEG: SW
render.setRenderBounds(0.85F, 0.0F, 0.0F, 1.0F, 0.85F, 0.15F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// LEG: SE
render.setRenderBounds(0.85F, 0F, 0.85F, 1.0F, 0.85F, 1.0F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SHELF: BOTTOM
render.setRenderBounds(0.1F, 0.3F, 0.1F, 0.9F, 0.4F, 0.9F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SHELF: TOP
render.setRenderBounds(0.1F, 0.5F, 0.1F, 0.9F, 0.6F, 0.9F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SIDE: BACK
render.setRenderBounds(0.05F, 0.3F, 0.05F, 0.95F, 0.85F, 0.1F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SIDE: LEFT
render.setRenderBounds(0.05F, 0.3F, 0.05F, 0.1F, 0.85F, 0.95F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SIDE: RIGHT
render.setRenderBounds(0.05F, 0.3F, 0.9F, 0.95F, 0.85F, 0.95F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
// SIDE: TOP
render.setRenderBounds(0.0F, 0.85F, 0.0F, 1.0F, 1.0F, 1.0F);
FCClientUtilsRender.RenderInvBlockWithTexture(render, this, -0.5F, -0.5F, -0.5F, blockIcon);
}
}