mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
310 lines
15 KiB
Diff
310 lines
15 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockFire.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockFire.java
|
|
@@ -2,7 +2,10 @@
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
+import java.util.IdentityHashMap;
|
|
+import java.util.Map.Entry;
|
|
import java.util.Random;
|
|
+import com.google.common.collect.Maps;
|
|
import net.minecraft.block.material.MapColor;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
@@ -12,11 +15,15 @@
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.WorldProviderEnd;
|
|
+import net.minecraftforge.common.util.ForgeDirection;
|
|
+import static net.minecraftforge.common.util.ForgeDirection.*;
|
|
|
|
public class BlockFire extends Block
|
|
{
|
|
- private int[] field_149849_a = new int[256];
|
|
- private int[] field_149848_b = new int[256];
|
|
+ @Deprecated
|
|
+ private int[] field_149849_a = new int[4096];
|
|
+ @Deprecated
|
|
+ private int[] field_149848_b = new int[4096];
|
|
@SideOnly(Side.CLIENT)
|
|
private IIcon[] field_149850_M;
|
|
private static final String __OBFID = "CL_00000245";
|
|
@@ -54,10 +61,10 @@
|
|
Blocks.field_150480_ab.func_149842_a(func_149682_b(Blocks.field_150404_cg), 60, 20);
|
|
}
|
|
|
|
+ @Deprecated // Use setFireInfo
|
|
public void func_149842_a(int p_149842_1_, int p_149842_2_, int p_149842_3_)
|
|
{
|
|
- this.field_149849_a[p_149842_1_] = p_149842_2_;
|
|
- this.field_149848_b[p_149842_1_] = p_149842_3_;
|
|
+ this.setFireInfo((Block)Block.field_149771_c.func_148754_a(p_149842_1_), p_149842_2_, p_149842_3_);
|
|
}
|
|
|
|
public AxisAlignedBB func_149668_a(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
|
@@ -94,13 +101,8 @@
|
|
{
|
|
if (p_149674_1_.func_82736_K().func_82766_b("doFireTick"))
|
|
{
|
|
- boolean flag = p_149674_1_.func_147439_a(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == Blocks.field_150424_aL;
|
|
+ boolean flag = p_149674_1_.func_147439_a(p_149674_2_, p_149674_3_ - 1, p_149674_4_).isFireSource(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP);
|
|
|
|
- if (p_149674_1_.field_73011_w instanceof WorldProviderEnd && p_149674_1_.func_147439_a(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == Blocks.field_150357_h)
|
|
- {
|
|
- flag = true;
|
|
- }
|
|
-
|
|
if (!this.func_149742_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
|
|
{
|
|
p_149674_1_.func_147468_f(p_149674_2_, p_149674_3_, p_149674_4_);
|
|
@@ -128,7 +130,7 @@
|
|
p_149674_1_.func_147468_f(p_149674_2_, p_149674_3_, p_149674_4_);
|
|
}
|
|
}
|
|
- else if (!flag && !this.func_149844_e(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) && l == 15 && p_149674_5_.nextInt(4) == 0)
|
|
+ else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0)
|
|
{
|
|
p_149674_1_.func_147468_f(p_149674_2_, p_149674_3_, p_149674_4_);
|
|
}
|
|
@@ -142,12 +144,12 @@
|
|
b0 = -50;
|
|
}
|
|
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l);
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l);
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, 250 + b0, p_149674_5_, l);
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, 250 + b0, p_149674_5_, l);
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, 300 + b0, p_149674_5_, l);
|
|
- this.func_149841_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, 300 + b0, p_149674_5_, l);
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, WEST );
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, EAST );
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, 250 + b0, p_149674_5_, l, UP );
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, 250 + b0, p_149674_5_, l, DOWN );
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, 300 + b0, p_149674_5_, l, SOUTH);
|
|
+ this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, 300 + b0, p_149674_5_, l, NORTH);
|
|
|
|
for (int i1 = p_149674_2_ - 1; i1 <= p_149674_2_ + 1; ++i1)
|
|
{
|
|
@@ -201,10 +203,16 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated
|
|
private void func_149841_a(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_)
|
|
{
|
|
- int j1 = this.field_149848_b[Block.func_149682_b(p_149841_1_.func_147439_a(p_149841_2_, p_149841_3_, p_149841_4_))];
|
|
+ this.tryCatchFire(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, p_149841_5_, p_149841_6_, p_149841_7_, UP);
|
|
+ }
|
|
|
|
+ private void tryCatchFire(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_, ForgeDirection face)
|
|
+ {
|
|
+ int j1 = p_149841_1_.func_147439_a(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, face);
|
|
+
|
|
if (p_149841_6_.nextInt(p_149841_5_) < j1)
|
|
{
|
|
boolean flag = p_149841_1_.func_147439_a(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.field_150335_W;
|
|
@@ -234,7 +242,12 @@
|
|
|
|
private boolean func_149847_e(World p_149847_1_, int p_149847_2_, int p_149847_3_, int p_149847_4_)
|
|
{
|
|
- return this.func_149844_e(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_) ? true : (this.func_149844_e(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_) ? true : (this.func_149844_e(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_) ? true : (this.func_149844_e(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_) ? true : (this.func_149844_e(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1) ? true : this.func_149844_e(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1)))));
|
|
+ return this.canCatchFire(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_, WEST ) ||
|
|
+ this.canCatchFire(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_, EAST ) ||
|
|
+ this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_, UP ) ||
|
|
+ this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_, DOWN ) ||
|
|
+ this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1, SOUTH) ||
|
|
+ this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1, NORTH);
|
|
}
|
|
|
|
private int func_149845_m(World p_149845_1_, int p_149845_2_, int p_149845_3_, int p_149845_4_)
|
|
@@ -247,12 +260,13 @@
|
|
}
|
|
else
|
|
{
|
|
- int l = this.func_149846_a(p_149845_1_, p_149845_2_ + 1, p_149845_3_, p_149845_4_, b0);
|
|
- l = this.func_149846_a(p_149845_1_, p_149845_2_ - 1, p_149845_3_, p_149845_4_, l);
|
|
- l = this.func_149846_a(p_149845_1_, p_149845_2_, p_149845_3_ - 1, p_149845_4_, l);
|
|
- l = this.func_149846_a(p_149845_1_, p_149845_2_, p_149845_3_ + 1, p_149845_4_, l);
|
|
- l = this.func_149846_a(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ - 1, l);
|
|
- l = this.func_149846_a(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ + 1, l);
|
|
+ int l = b0;
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ + 1, p_149845_3_, p_149845_4_, l, WEST );
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ - 1, p_149845_3_, p_149845_4_, l, EAST );
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ - 1, p_149845_4_, l, UP );
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ + 1, p_149845_4_, l, DOWN );
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ - 1, l, SOUTH);
|
|
+ l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ + 1, l, NORTH);
|
|
return l;
|
|
}
|
|
}
|
|
@@ -262,15 +276,16 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated
|
|
public boolean func_149844_e(IBlockAccess p_149844_1_, int p_149844_2_, int p_149844_3_, int p_149844_4_)
|
|
{
|
|
- return this.field_149849_a[Block.func_149682_b(p_149844_1_.func_147439_a(p_149844_2_, p_149844_3_, p_149844_4_))] > 0;
|
|
+ return canCatchFire(p_149844_1_, p_149844_2_, p_149844_3_, p_149844_4_, UP);
|
|
}
|
|
|
|
+ @Deprecated
|
|
public int func_149846_a(World p_149846_1_, int p_149846_2_, int p_149846_3_, int p_149846_4_, int p_149846_5_)
|
|
{
|
|
- int i1 = this.field_149849_a[Block.func_149682_b(p_149846_1_.func_147439_a(p_149846_2_, p_149846_3_, p_149846_4_))];
|
|
- return i1 > p_149846_5_ ? i1 : p_149846_5_;
|
|
+ return getChanceToEncourageFire(p_149846_1_, p_149846_2_, p_149846_3_, p_149846_4_, p_149846_5_, UP);
|
|
}
|
|
|
|
public boolean func_149742_c(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
|
|
@@ -314,9 +329,9 @@
|
|
float f1;
|
|
float f2;
|
|
|
|
- if (!World.func_147466_a(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_))
|
|
+ if (!World.func_147466_a(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_, UP))
|
|
{
|
|
- if (Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_))
|
|
+ if (Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_, EAST))
|
|
{
|
|
for (l = 0; l < 2; ++l)
|
|
{
|
|
@@ -327,7 +342,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_))
|
|
+ if (Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_, WEST))
|
|
{
|
|
for (l = 0; l < 2; ++l)
|
|
{
|
|
@@ -338,7 +353,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1))
|
|
+ if (Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1, SOUTH))
|
|
{
|
|
for (l = 0; l < 2; ++l)
|
|
{
|
|
@@ -349,7 +364,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1))
|
|
+ if (Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1, NORTH))
|
|
{
|
|
for (l = 0; l < 2; ++l)
|
|
{
|
|
@@ -360,7 +375,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.field_150480_ab.func_149844_e(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_))
|
|
+ if (Blocks.field_150480_ab.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_, DOWN))
|
|
{
|
|
for (l = 0; l < 2; ++l)
|
|
{
|
|
@@ -405,4 +420,101 @@
|
|
{
|
|
return MapColor.field_151656_f;
|
|
}
|
|
+
|
|
+ /*================================= Forge Start ======================================*/
|
|
+ private static class FireInfo
|
|
+ {
|
|
+ private int encouragement = 0;
|
|
+ private int flammibility = 0;
|
|
+ }
|
|
+ private IdentityHashMap<Block, FireInfo> blockInfo = Maps.newIdentityHashMap();
|
|
+
|
|
+ public void setFireInfo(Block block, int encouragement, int flammibility)
|
|
+ {
|
|
+ if (block == Blocks.field_150350_a) throw new IllegalArgumentException("Tried to set air on fire... This is bad.");
|
|
+ int id = Block.func_149682_b(block);
|
|
+ this.field_149849_a[id] = encouragement;
|
|
+ this.field_149848_b[id] = flammibility;
|
|
+
|
|
+ FireInfo info = getInfo(block, true);
|
|
+ info.encouragement = encouragement;
|
|
+ info.flammibility = flammibility;
|
|
+ }
|
|
+
|
|
+ private FireInfo getInfo(Block block, boolean garentee)
|
|
+ {
|
|
+ FireInfo ret = blockInfo.get(block);
|
|
+ if (ret == null && garentee)
|
|
+ {
|
|
+ ret = new FireInfo();
|
|
+ blockInfo.put(block, ret);
|
|
+ }
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ public void rebuildFireInfo()
|
|
+ {
|
|
+ for (int x = 0; x < 4096; x++)
|
|
+ {
|
|
+ //If we care.. we could detect changes in here and make sure we keep them, however
|
|
+ //it's my thinking that anyone who hacks into the private variables should DIAF and we don't care about them.
|
|
+ field_149849_a[x] = 0;
|
|
+ field_149848_b[x] = 0;
|
|
+ }
|
|
+
|
|
+ for (Entry<Block, FireInfo> e : blockInfo.entrySet())
|
|
+ {
|
|
+ int id = Block.func_149682_b(e.getKey());
|
|
+ if (id >= 0 && id < 4096)
|
|
+ {
|
|
+ field_149849_a[id] = e.getValue().encouragement;
|
|
+ field_149848_b[id] = e.getValue().flammibility;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public int getFlammability(Block block)
|
|
+ {
|
|
+ int id = Block.func_149682_b(block);
|
|
+ return id >= 0 && id < 4096 ? field_149848_b[id] : 0;
|
|
+ }
|
|
+
|
|
+ public int getEncouragement(Block block)
|
|
+ {
|
|
+ int id = Block.func_149682_b(block);
|
|
+ return id >= 0 && id < 4096 ? field_149849_a[id] : 0;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Side sensitive version that calls the block function.
|
|
+ *
|
|
+ * @param world The current world
|
|
+ * @param x X Position
|
|
+ * @param y Y Position
|
|
+ * @param z Z Position
|
|
+ * @param face The side the fire is coming from
|
|
+ * @return True if the face can catch fire.
|
|
+ */
|
|
+ public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
|
+ {
|
|
+ return world.func_147439_a(x, y, z).isFlammable(world, x, y, z, face);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Side sensitive version that calls the block function.
|
|
+ *
|
|
+ * @param world The current world
|
|
+ * @param x X Position
|
|
+ * @param y Y Position
|
|
+ * @param z Z Position
|
|
+ * @param oldChance The previous maximum chance.
|
|
+ * @param face The side the fire is coming from
|
|
+ * @return The chance of the block catching fire, or oldChance if it is higher
|
|
+ */
|
|
+ public int getChanceToEncourageFire(IBlockAccess world, int x, int y, int z, int oldChance, ForgeDirection face)
|
|
+ {
|
|
+ int newChance = world.func_147439_a(x, y, z).getFireSpreadSpeed(world, x, y, z, face);
|
|
+ return (newChance > oldChance ? newChance : oldChance);
|
|
+ }
|
|
+ /*================================= Forge Start ======================================*/
|
|
}
|