-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockFire.java
More file actions
326 lines (295 loc) · 10.6 KB
/
BlockFire.java
File metadata and controls
326 lines (295 loc) · 10.6 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
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 BlockFire extends Block
{
protected BlockFire(int i, int j)
{
super(i, j, Material.fire);
chanceToEncourageFire = new int[256];
abilityToCatchFire = new int[256];
setBurnRate(Block.planks.blockID, 5, 20);
setBurnRate(Block.wood.blockID, 5, 5);
setBurnRate(Block.leaves.blockID, 30, 60);
setBurnRate(Block.bookShelf.blockID, 30, 20);
setBurnRate(Block.tnt.blockID, 15, 100);
setBurnRate(Block.cloth.blockID, 30, 60);
setTickOnLoad(true);
}
private void setBurnRate(int i, int j, int k)
{
chanceToEncourageFire[i] = j;
abilityToCatchFire[i] = k;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 3;
}
public int quantityDropped(Random random)
{
return 0;
}
public int tickRate()
{
return 10;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
boolean flag = world.getBlockId(i, j - 1, k) == Block.bloodStone.blockID;
int l = world.getBlockMetadata(i, j, k);
if(l < 15)
{
world.setBlockMetadataWithNotify(i, j, k, l + 1);
world.func_22136_c(i, j, k, blockID, tickRate());
}
if(!flag && !func_263_h(world, i, j, k))
{
if(!world.isBlockOpaqueCube(i, j - 1, k) || l > 3)
{
world.setBlockWithNotify(i, j, k, 0);
}
return;
}
if(!flag && !canBlockCatchFire(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0)
{
world.setBlockWithNotify(i, j, k, 0);
return;
}
if(l % 2 == 0 && l > 2)
{
tryToCatchBlockOnFire(world, i + 1, j, k, 300, random);
tryToCatchBlockOnFire(world, i - 1, j, k, 300, random);
tryToCatchBlockOnFire(world, i, j - 1, k, 250, random);
tryToCatchBlockOnFire(world, i, j + 1, k, 250, random);
tryToCatchBlockOnFire(world, i, j, k - 1, 300, random);
tryToCatchBlockOnFire(world, i, j, k + 1, 300, random);
for(int i1 = i - 1; i1 <= i + 1; i1++)
{
for(int j1 = k - 1; j1 <= k + 1; j1++)
{
for(int k1 = j - 1; k1 <= j + 4; k1++)
{
if(i1 == i && k1 == j && j1 == k)
{
continue;
}
int l1 = 100;
if(k1 > j + 1)
{
l1 += (k1 - (j + 1)) * 100;
}
int i2 = getChanceOfNeighborsEncouragingFire(world, i1, k1, j1);
if(i2 > 0 && random.nextInt(l1) <= i2)
{
world.setBlockWithNotify(i1, k1, j1, blockID);
}
}
}
}
}
if(l == 15)
{
tryToCatchBlockOnFire(world, i + 1, j, k, 1, random);
tryToCatchBlockOnFire(world, i - 1, j, k, 1, random);
tryToCatchBlockOnFire(world, i, j - 1, k, 1, random);
tryToCatchBlockOnFire(world, i, j + 1, k, 1, random);
tryToCatchBlockOnFire(world, i, j, k - 1, 1, random);
tryToCatchBlockOnFire(world, i, j, k + 1, 1, random);
}
}
private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random)
{
int i1 = abilityToCatchFire[world.getBlockId(i, j, k)];
if(random.nextInt(l) < i1)
{
boolean flag = world.getBlockId(i, j, k) == Block.tnt.blockID;
if(random.nextInt(2) == 0)
{
world.setBlockWithNotify(i, j, k, blockID);
} else
{
world.setBlockWithNotify(i, j, k, 0);
}
if(flag)
{
Block.tnt.onBlockDestroyedByPlayer(world, i, j, k, 0);
}
}
}
private boolean func_263_h(World world, int i, int j, int k)
{
if(canBlockCatchFire(world, i + 1, j, k))
{
return true;
}
if(canBlockCatchFire(world, i - 1, j, k))
{
return true;
}
if(canBlockCatchFire(world, i, j - 1, k))
{
return true;
}
if(canBlockCatchFire(world, i, j + 1, k))
{
return true;
}
if(canBlockCatchFire(world, i, j, k - 1))
{
return true;
}
return canBlockCatchFire(world, i, j, k + 1);
}
private int getChanceOfNeighborsEncouragingFire(World world, int i, int j, int k)
{
int l = 0;
if(!world.isAirBlock(i, j, k))
{
return 0;
} else
{
l = getChanceToEncourageFire(world, i + 1, j, k, l);
l = getChanceToEncourageFire(world, i - 1, j, k, l);
l = getChanceToEncourageFire(world, i, j - 1, k, l);
l = getChanceToEncourageFire(world, i, j + 1, k, l);
l = getChanceToEncourageFire(world, i, j, k - 1, l);
l = getChanceToEncourageFire(world, i, j, k + 1, l);
return l;
}
}
public boolean isCollidable()
{
return false;
}
public boolean canBlockCatchFire(IBlockAccess iblockaccess, int i, int j, int k)
{
return chanceToEncourageFire[iblockaccess.getBlockId(i, j, k)] > 0;
}
public int getChanceToEncourageFire(World world, int i, int j, int k, int l)
{
int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
if(i1 > l)
{
return i1;
} else
{
return l;
}
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
return world.isBlockOpaqueCube(i, j - 1, k) || func_263_h(world, i, j, k);
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if(!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k))
{
world.setBlockWithNotify(i, j, k, 0);
return;
} else
{
return;
}
}
public void onBlockAdded(World world, int i, int j, int k)
{
if(world.getBlockId(i, j - 1, k) == Block.obsidian.blockID && Block.portal.tryToCreatePortal(world, i, j, k))
{
return;
}
if(!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k))
{
world.setBlockWithNotify(i, j, k, 0);
return;
} else
{
world.func_22136_c(i, j, k, blockID, tickRate());
return;
}
}
public void randomDisplayTick(World world, int i, int j, int k, Random random)
{
if(random.nextInt(24) == 0)
{
world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "fire.fire", 1.0F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F);
}
if(world.isBlockOpaqueCube(i, j - 1, k) || Block.fire.canBlockCatchFire(world, i, j - 1, k))
{
for(int l = 0; l < 3; l++)
{
float f = (float)i + random.nextFloat();
float f6 = (float)j + random.nextFloat() * 0.5F + 0.5F;
float f12 = (float)k + random.nextFloat();
world.spawnParticle("largesmoke", f, f6, f12, 0.0D, 0.0D, 0.0D);
}
} else
{
if(Block.fire.canBlockCatchFire(world, i - 1, j, k))
{
for(int i1 = 0; i1 < 2; i1++)
{
float f1 = (float)i + random.nextFloat() * 0.1F;
float f7 = (float)j + random.nextFloat();
float f13 = (float)k + random.nextFloat();
world.spawnParticle("largesmoke", f1, f7, f13, 0.0D, 0.0D, 0.0D);
}
}
if(Block.fire.canBlockCatchFire(world, i + 1, j, k))
{
for(int j1 = 0; j1 < 2; j1++)
{
float f2 = (float)(i + 1) - random.nextFloat() * 0.1F;
float f8 = (float)j + random.nextFloat();
float f14 = (float)k + random.nextFloat();
world.spawnParticle("largesmoke", f2, f8, f14, 0.0D, 0.0D, 0.0D);
}
}
if(Block.fire.canBlockCatchFire(world, i, j, k - 1))
{
for(int k1 = 0; k1 < 2; k1++)
{
float f3 = (float)i + random.nextFloat();
float f9 = (float)j + random.nextFloat();
float f15 = (float)k + random.nextFloat() * 0.1F;
world.spawnParticle("largesmoke", f3, f9, f15, 0.0D, 0.0D, 0.0D);
}
}
if(Block.fire.canBlockCatchFire(world, i, j, k + 1))
{
for(int l1 = 0; l1 < 2; l1++)
{
float f4 = (float)i + random.nextFloat();
float f10 = (float)j + random.nextFloat();
float f16 = (float)(k + 1) - random.nextFloat() * 0.1F;
world.spawnParticle("largesmoke", f4, f10, f16, 0.0D, 0.0D, 0.0D);
}
}
if(Block.fire.canBlockCatchFire(world, i, j + 1, k))
{
for(int i2 = 0; i2 < 2; i2++)
{
float f5 = (float)i + random.nextFloat();
float f11 = (float)(j + 1) - random.nextFloat() * 0.1F;
float f17 = (float)k + random.nextFloat();
world.spawnParticle("largesmoke", f5, f11, f17, 0.0D, 0.0D, 0.0D);
}
}
}
}
private int chanceToEncourageFire[];
private int abilityToCatchFire[];
}