-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockChest.java
More file actions
279 lines (267 loc) · 8.89 KB
/
BlockChest.java
File metadata and controls
279 lines (267 loc) · 8.89 KB
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
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
import java.util.Random;
public class BlockChest extends BlockContainer
{
protected BlockChest(int i)
{
super(i, Material.wood);
random = new Random();
blockIndexInTexture = 26;
}
public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
if(l == 1)
{
return blockIndexInTexture - 1;
}
if(l == 0)
{
return blockIndexInTexture - 1;
}
int i1 = iblockaccess.getBlockId(i, j, k - 1);
int j1 = iblockaccess.getBlockId(i, j, k + 1);
int k1 = iblockaccess.getBlockId(i - 1, j, k);
int l1 = iblockaccess.getBlockId(i + 1, j, k);
if(i1 == blockID || j1 == blockID)
{
if(l == 2 || l == 3)
{
return blockIndexInTexture;
}
int i2 = 0;
if(i1 == blockID)
{
i2 = -1;
}
int k2 = iblockaccess.getBlockId(i - 1, j, i1 != blockID ? k + 1 : k - 1);
int i3 = iblockaccess.getBlockId(i + 1, j, i1 != blockID ? k + 1 : k - 1);
if(l == 4)
{
i2 = -1 - i2;
}
byte byte1 = 5;
if((Block.opaqueCubeLookup[k1] || Block.opaqueCubeLookup[k2]) && !Block.opaqueCubeLookup[l1] && !Block.opaqueCubeLookup[i3])
{
byte1 = 5;
}
if((Block.opaqueCubeLookup[l1] || Block.opaqueCubeLookup[i3]) && !Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[k2])
{
byte1 = 4;
}
return (l != byte1 ? blockIndexInTexture + 32 : blockIndexInTexture + 16) + i2;
}
if(k1 == blockID || l1 == blockID)
{
if(l == 4 || l == 5)
{
return blockIndexInTexture;
}
int j2 = 0;
if(k1 == blockID)
{
j2 = -1;
}
int l2 = iblockaccess.getBlockId(k1 != blockID ? i + 1 : i - 1, j, k - 1);
int j3 = iblockaccess.getBlockId(k1 != blockID ? i + 1 : i - 1, j, k + 1);
if(l == 3)
{
j2 = -1 - j2;
}
byte byte2 = 3;
if((Block.opaqueCubeLookup[i1] || Block.opaqueCubeLookup[l2]) && !Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[j3])
{
byte2 = 3;
}
if((Block.opaqueCubeLookup[j1] || Block.opaqueCubeLookup[j3]) && !Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l2])
{
byte2 = 2;
}
return (l != byte2 ? blockIndexInTexture + 32 : blockIndexInTexture + 16) + j2;
}
byte byte0 = 3;
if(Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[j1])
{
byte0 = 3;
}
if(Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[i1])
{
byte0 = 2;
}
if(Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[l1])
{
byte0 = 5;
}
if(Block.opaqueCubeLookup[l1] && !Block.opaqueCubeLookup[k1])
{
byte0 = 4;
}
return l != byte0 ? blockIndexInTexture : blockIndexInTexture + 1;
}
public int getBlockTextureFromSide(int i)
{
if(i == 1)
{
return blockIndexInTexture - 1;
}
if(i == 0)
{
return blockIndexInTexture - 1;
}
if(i == 3)
{
return blockIndexInTexture + 1;
} else
{
return blockIndexInTexture;
}
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
int l = 0;
if(world.getBlockId(i - 1, j, k) == blockID)
{
l++;
}
if(world.getBlockId(i + 1, j, k) == blockID)
{
l++;
}
if(world.getBlockId(i, j, k - 1) == blockID)
{
l++;
}
if(world.getBlockId(i, j, k + 1) == blockID)
{
l++;
}
if(l > 1)
{
return false;
}
if(isThereANeighborChest(world, i - 1, j, k))
{
return false;
}
if(isThereANeighborChest(world, i + 1, j, k))
{
return false;
}
if(isThereANeighborChest(world, i, j, k - 1))
{
return false;
}
return !isThereANeighborChest(world, i, j, k + 1);
}
private boolean isThereANeighborChest(World world, int i, int j, int k)
{
if(world.getBlockId(i, j, k) != blockID)
{
return false;
}
if(world.getBlockId(i - 1, j, k) == blockID)
{
return true;
}
if(world.getBlockId(i + 1, j, k) == blockID)
{
return true;
}
if(world.getBlockId(i, j, k - 1) == blockID)
{
return true;
}
return world.getBlockId(i, j, k + 1) == blockID;
}
public void onBlockRemoval(World world, int i, int j, int k)
{
TileEntityChest tileentitychest = (TileEntityChest)world.getBlockTileEntity(i, j, k);
label0:
for(int l = 0; l < tileentitychest.getSizeInventory(); l++)
{
ItemStack itemstack = tileentitychest.getStackInSlot(l);
if(itemstack == null)
{
continue;
}
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
do
{
if(itemstack.stackSize <= 0)
{
continue label0;
}
int i1 = random.nextInt(21) + 10;
if(i1 > itemstack.stackSize)
{
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3;
world.entityJoinedWorld(entityitem);
} while(true);
}
super.onBlockRemoval(world, i, j, k);
}
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
Object obj = (TileEntityChest)world.getBlockTileEntity(i, j, k);
if(world.isBlockOpaqueCube(i, j + 1, k))
{
return true;
}
if(world.getBlockId(i - 1, j, k) == blockID && world.isBlockOpaqueCube(i - 1, j + 1, k))
{
return true;
}
if(world.getBlockId(i + 1, j, k) == blockID && world.isBlockOpaqueCube(i + 1, j + 1, k))
{
return true;
}
if(world.getBlockId(i, j, k - 1) == blockID && world.isBlockOpaqueCube(i, j + 1, k - 1))
{
return true;
}
if(world.getBlockId(i, j, k + 1) == blockID && world.isBlockOpaqueCube(i, j + 1, k + 1))
{
return true;
}
if(world.getBlockId(i - 1, j, k) == blockID)
{
obj = new InventoryLargeChest("Large chest", (TileEntityChest)world.getBlockTileEntity(i - 1, j, k), ((IInventory) (obj)));
}
if(world.getBlockId(i + 1, j, k) == blockID)
{
obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)), (TileEntityChest)world.getBlockTileEntity(i + 1, j, k));
}
if(world.getBlockId(i, j, k - 1) == blockID)
{
obj = new InventoryLargeChest("Large chest", (TileEntityChest)world.getBlockTileEntity(i, j, k - 1), ((IInventory) (obj)));
}
if(world.getBlockId(i, j, k + 1) == blockID)
{
obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)), (TileEntityChest)world.getBlockTileEntity(i, j, k + 1));
}
if(world.multiplayerWorld)
{
return true;
} else
{
entityplayer.displayGUIChest(((IInventory) (obj)));
return true;
}
}
protected TileEntity getBlockEntity()
{
return new TileEntityChest();
}
private Random random;
}