-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockFluids.java
More file actions
349 lines (320 loc) · 10 KB
/
BlockFluids.java
File metadata and controls
349 lines (320 loc) · 10 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
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 abstract class BlockFluids extends Block
{
protected BlockFluids(int i, Material material)
{
super(i, (material != Material.lava ? 12 : 14) * 16 + 13, material);
float f = 0.0F;
float f1 = 0.0F;
setBlockBounds(0.0F + f1, 0.0F + f, 0.0F + f1, 1.0F + f1, 1.0F + f, 1.0F + f1);
setTickOnLoad(true);
}
public static float setFluidHeight(int i)
{
if(i >= 8)
{
i = 0;
}
float f = (float)(i + 1) / 9F;
return f;
}
public int getBlockTextureFromSide(int i)
{
if(i == 0 || i == 1)
{
return blockIndexInTexture;
} else
{
return blockIndexInTexture + 1;
}
}
protected int func_290_h(World world, int i, int j, int k)
{
if(world.getBlockMaterial(i, j, k) != blockMaterial)
{
return -1;
} else
{
return world.getBlockMetadata(i, j, k);
}
}
protected int func_289_b(IBlockAccess iblockaccess, int i, int j, int k)
{
if(iblockaccess.getBlockMaterial(i, j, k) != blockMaterial)
{
return -1;
}
int l = iblockaccess.getBlockMetadata(i, j, k);
if(l >= 8)
{
l = 0;
}
return l;
}
public boolean renderAsNormalBlock()
{
return false;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean canCollideCheck(int i, boolean flag)
{
return flag && i == 0;
}
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
Material material = iblockaccess.getBlockMaterial(i, j, k);
if(material == blockMaterial)
{
return false;
}
if(material == Material.ice)
{
return false;
}
if(l == 1)
{
return true;
} else
{
return super.shouldSideBeRendered(iblockaccess, i, j, k, l);
}
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public int getRenderType()
{
return 4;
}
public int idDropped(int i, Random random)
{
return 0;
}
public int quantityDropped(Random random)
{
return 0;
}
private Vec3D func_291_e(IBlockAccess iblockaccess, int i, int j, int k)
{
Vec3D vec3d = Vec3D.createVector(0.0D, 0.0D, 0.0D);
int l = func_289_b(iblockaccess, i, j, k);
for(int i1 = 0; i1 < 4; i1++)
{
int j1 = i;
int k1 = j;
int l1 = k;
if(i1 == 0)
{
j1--;
}
if(i1 == 1)
{
l1--;
}
if(i1 == 2)
{
j1++;
}
if(i1 == 3)
{
l1++;
}
int i2 = func_289_b(iblockaccess, j1, k1, l1);
if(i2 < 0)
{
if(iblockaccess.getBlockMaterial(j1, k1, l1).getIsSolid())
{
continue;
}
i2 = func_289_b(iblockaccess, j1, k1 - 1, l1);
if(i2 >= 0)
{
int j2 = i2 - (l - 8);
vec3d = vec3d.addVector((j1 - i) * j2, (k1 - j) * j2, (l1 - k) * j2);
}
continue;
}
if(i2 >= 0)
{
int k2 = i2 - l;
vec3d = vec3d.addVector((j1 - i) * k2, (k1 - j) * k2, (l1 - k) * k2);
}
}
if(iblockaccess.getBlockMetadata(i, j, k) >= 8)
{
boolean flag = false;
if(flag || shouldSideBeRendered(iblockaccess, i, j, k - 1, 2))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i, j, k + 1, 3))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i - 1, j, k, 4))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i + 1, j, k, 5))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i, j + 1, k - 1, 2))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i, j + 1, k + 1, 3))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i - 1, j + 1, k, 4))
{
flag = true;
}
if(flag || shouldSideBeRendered(iblockaccess, i + 1, j + 1, k, 5))
{
flag = true;
}
if(flag)
{
vec3d = vec3d.normalize().addVector(0.0D, -6D, 0.0D);
}
}
vec3d = vec3d.normalize();
return vec3d;
}
public void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d)
{
Vec3D vec3d1 = func_291_e(world, i, j, k);
vec3d.xCoord += vec3d1.xCoord;
vec3d.yCoord += vec3d1.yCoord;
vec3d.zCoord += vec3d1.zCoord;
}
public int tickRate()
{
if(blockMaterial == Material.water)
{
return 5;
}
return blockMaterial != Material.lava ? 0 : 30;
}
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k)
{
float f = iblockaccess.getLightBrightness(i, j, k);
float f1 = iblockaccess.getLightBrightness(i, j + 1, k);
return f <= f1 ? f1 : f;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
super.updateTick(world, i, j, k, random);
}
public int getRenderBlockPass()
{
return blockMaterial != Material.water ? 0 : 1;
}
public void randomDisplayTick(World world, int i, int j, int k, Random random)
{
if(blockMaterial == Material.water && random.nextInt(64) == 0)
{
int l = world.getBlockMetadata(i, j, k);
if(l > 0 && l < 8)
{
world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "liquid.water", random.nextFloat() * 0.25F + 0.75F, random.nextFloat() * 1.0F + 0.5F);
}
}
if(blockMaterial == Material.lava && world.getBlockMaterial(i, j + 1, k) == Material.air && !world.isBlockOpaqueCube(i, j + 1, k) && random.nextInt(100) == 0)
{
double d = (float)i + random.nextFloat();
double d1 = (double)j + maxY;
double d2 = (float)k + random.nextFloat();
world.spawnParticle("lava", d, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
public static double func_293_a(IBlockAccess iblockaccess, int i, int j, int k, Material material)
{
Vec3D vec3d = null;
if(material == Material.water)
{
vec3d = ((BlockFluids)Block.waterStill).func_291_e(iblockaccess, i, j, k);
}
if(material == Material.lava)
{
vec3d = ((BlockFluids)Block.lavaStill).func_291_e(iblockaccess, i, j, k);
}
if(vec3d.xCoord == 0.0D && vec3d.zCoord == 0.0D)
{
return -1000D;
} else
{
return Math.atan2(vec3d.zCoord, vec3d.xCoord) - 1.5707963267948966D;
}
}
public void onBlockAdded(World world, int i, int j, int k)
{
checkForHarden(world, i, j, k);
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
checkForHarden(world, i, j, k);
}
private void checkForHarden(World world, int i, int j, int k)
{
if(world.getBlockId(i, j, k) != blockID)
{
return;
}
if(blockMaterial == Material.lava)
{
boolean flag = false;
if(flag || world.getBlockMaterial(i, j, k - 1) == Material.water)
{
flag = true;
}
if(flag || world.getBlockMaterial(i, j, k + 1) == Material.water)
{
flag = true;
}
if(flag || world.getBlockMaterial(i - 1, j, k) == Material.water)
{
flag = true;
}
if(flag || world.getBlockMaterial(i + 1, j, k) == Material.water)
{
flag = true;
}
if(flag || world.getBlockMaterial(i, j + 1, k) == Material.water)
{
flag = true;
}
if(flag)
{
int l = world.getBlockMetadata(i, j, k);
if(l == 0)
{
world.setBlockWithNotify(i, j, k, Block.obsidian.blockID);
} else
if(l <= 4)
{
world.setBlockWithNotify(i, j, k, Block.cobblestone.blockID);
}
func_292_i(world, i, j, k);
}
}
}
protected void func_292_i(World world, int i, int j, int k)
{
world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
for(int l = 0; l < 8; l++)
{
world.spawnParticle("largesmoke", (double)i + Math.random(), (double)j + 1.2D, (double)k + Math.random(), 0.0D, 0.0D, 0.0D);
}
}
}