Changed Block.setBurnRate to public and Block.setBurnProperties

Re-added bounce functions to BlockFire for non-forge mods.
Should fix Optifine compatibility.
This commit is contained in:
LexManos 2011-12-24 05:07:55 +00:00
parent 906cb8ee39
commit df3449534f
4 changed files with 112 additions and 62 deletions

View File

@ -321,7 +321,7 @@
+ * @param encouragement How much the block encourages fire to spread
+ * @param flammability how easy a block is to catch fire
+ */
+ protected static void setBurnRate(int id, int encouragement, int flammability)
+ public static void setBurnProperties(int id, int encouragement, int flammability)
+ {
+ blockFireSpreadSpeed[id] = encouragement;
+ blockFlammability[id] = flammability;

View File

@ -20,20 +20,21 @@
setTickOnLoad(true);
}
@@ -39,12 +39,6 @@
@@ -38,11 +38,10 @@
setBurnRate(Block.cloth.blockID, 30, 60);
setBurnRate(Block.vine.blockID, 15, 100);
}
- private void setBurnRate(int i, int j, int k)
- {
-
+
private void setBurnRate(int i, int j, int k)
{
- chanceToEncourageFire[i] = j;
- abilityToCatchFire[i] = k;
- }
-
+ Block.setBurnProperties(i, j, k);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
@@ -77,11 +71,9 @@
@@ -77,11 +76,9 @@
public void updateTick(World world, int i, int j, int k, Random random)
{
@ -48,7 +49,7 @@
if(!canPlaceBlockAt(world, i, j, k))
{
world.setBlockWithNotify(i, j, k, 0);
@@ -99,23 +91,23 @@
@@ -99,23 +96,23 @@
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
if(!flag && !func_263_h(world, i, j, k))
{
@ -80,14 +81,22 @@
for(int i1 = i - 1; i1 <= i + 1; i1++)
{
for(int j1 = k - 1; j1 <= k + 1; j1++)
@@ -155,9 +147,14 @@
@@ -155,9 +152,23 @@
}
- private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1)
+ private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1, int face)
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1)
{
- int j1 = abilityToCatchFire[world.getBlockId(i, j, k)];
+ tryToCatchBlockOnFire(world, i, j, k, l, random, i1, 0);
+ }
+
+ private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1, int face)
+ {
+ Block block = Block.blocksList[world.getBlockId(i, j, k)];
+ int j1 = 0;
+ if (block != null)
@ -97,7 +106,7 @@
if(random.nextInt(l) < j1)
{
boolean flag = world.getBlockId(i, j, k) == Block.tnt.blockID;
@@ -182,27 +179,27 @@
@@ -182,27 +193,27 @@
private boolean func_263_h(World world, int i, int j, int k)
{
@ -131,7 +140,7 @@
}
private int getChanceOfNeighborsEncouragingFire(World world, int i, int j, int k)
@@ -213,12 +210,12 @@
@@ -213,12 +224,12 @@
return 0;
} else
{
@ -150,19 +159,24 @@
return l;
}
}
@@ -228,14 +225,25 @@
@@ -227,15 +238,43 @@
{
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)
+ public boolean canBlockCatchFire(IBlockAccess world, int i, int j, int k, int face)
-
+
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
public boolean canBlockCatchFire(IBlockAccess iblockaccess, int i, int j, int k)
{
- int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
- return chanceToEncourageFire[iblockaccess.getBlockId(i, j, k)] > 0;
+ return canBlockCatchFire(iblockaccess, i, j, k, 0);
}
+ public boolean canBlockCatchFire(IBlockAccess world, int i, int j, int k, int face)
+ {
+ Block block = Block.blocksList[world.getBlockId(i, j, k)];
+ if (block != null)
+ {
@ -171,6 +185,16 @@
+ return false;
+ }
+
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
public int getChanceToEncourageFire(World world, int i, int j, int k, int l)
{
- int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
+ return getChanceToEncourageFire(world, i, j, k, l, 0);
+ }
+
+ public int getChanceToEncourageFire(World world, int i, int j, int k, int l, int face)
+ {
+ int i1 = 0;
@ -182,7 +206,7 @@
if(i1 > l)
{
return i1;
@@ -247,12 +255,12 @@
@@ -247,12 +286,12 @@
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
@ -197,7 +221,7 @@
{
world.setBlockWithNotify(i, j, k, 0);
return;
@@ -268,7 +276,7 @@
@@ -268,7 +307,7 @@
{
return;
}
@ -206,7 +230,7 @@
{
world.setBlockWithNotify(i, j, k, 0);
return;
@@ -285,7 +293,7 @@
@@ -285,7 +324,7 @@
{
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);
}
@ -215,7 +239,7 @@
{
for(int l = 0; l < 3; l++)
{
@@ -297,7 +305,7 @@
@@ -297,7 +336,7 @@
} else
{
@ -224,7 +248,7 @@
{
for(int i1 = 0; i1 < 2; i1++)
{
@@ -308,7 +316,7 @@
@@ -308,7 +347,7 @@
}
}
@ -233,7 +257,7 @@
{
for(int j1 = 0; j1 < 2; j1++)
{
@@ -319,7 +327,7 @@
@@ -319,7 +358,7 @@
}
}
@ -242,7 +266,7 @@
{
for(int k1 = 0; k1 < 2; k1++)
{
@@ -330,7 +338,7 @@
@@ -330,7 +369,7 @@
}
}
@ -251,7 +275,7 @@
{
for(int l1 = 0; l1 < 2; l1++)
{
@@ -341,7 +349,7 @@
@@ -341,7 +380,7 @@
}
}

View File

@ -304,7 +304,7 @@
+ * @param encouragement How much the block encourages fire to spread
+ * @param flammability how easy a block is to catch fire
+ */
+ protected static void setBurnRate(int id, int encouragement, int flammability)
+ public static void setBurnProperties(int id, int encouragement, int flammability)
+ {
+ blockFireSpreadSpeed[id] = encouragement;
+ blockFlammability[id] = flammability;

View File

@ -20,20 +20,21 @@
setTickOnLoad(true);
}
@@ -39,12 +39,6 @@
@@ -38,11 +38,10 @@
setBurnRate(Block.cloth.blockID, 30, 60);
setBurnRate(Block.vine.blockID, 15, 100);
}
- private void setBurnRate(int i, int j, int k)
- {
-
+
private void setBurnRate(int i, int j, int k)
{
- chanceToEncourageFire[i] = j;
- abilityToCatchFire[i] = k;
- }
-
+ Block.setBurnProperties(i, j, k);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
@@ -77,11 +71,9 @@
@@ -77,11 +76,9 @@
public void updateTick(World world, int i, int j, int k, Random random)
{
@ -48,7 +49,7 @@
if(!canPlaceBlockAt(world, i, j, k))
{
world.setBlockWithNotify(i, j, k, 0);
@@ -99,23 +91,23 @@
@@ -99,23 +96,23 @@
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
if(!flag && !func_268_g(world, i, j, k))
{
@ -80,14 +81,24 @@
for(int i1 = i - 1; i1 <= i + 1; i1++)
{
for(int j1 = k - 1; j1 <= k + 1; j1++)
@@ -155,9 +147,14 @@
@@ -154,10 +151,24 @@
}
}
- private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1)
+ private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1, int face)
-
+
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1)
{
- int j1 = abilityToCatchFire[world.getBlockId(i, j, k)];
+ tryToCatchBlockOnFire(world, i, j, k, l, random, i1, 0);
+ }
+
+ private void tryToCatchBlockOnFire(World world, int i, int j, int k, int l, Random random, int i1, int face)
+ {
+ Block block = Block.blocksList[world.getBlockId(i, j, k)];
+ int j1 = 0;
+ if (block != null)
@ -97,7 +108,7 @@
if(random.nextInt(l) < j1)
{
boolean flag = world.getBlockId(i, j, k) == Block.tnt.blockID;
@@ -182,27 +179,27 @@
@@ -182,27 +193,27 @@
private boolean func_268_g(World world, int i, int j, int k)
{
@ -131,7 +142,7 @@
}
private int getChanceOfNeighborsEncouragingFire(World world, int i, int j, int k)
@@ -213,12 +210,12 @@
@@ -213,12 +224,12 @@
return 0;
} else
{
@ -150,19 +161,24 @@
return l;
}
}
@@ -228,14 +225,24 @@
@@ -227,15 +238,43 @@
{
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)
+ public boolean canBlockCatchFire(IBlockAccess world, int i, int j, int k, int face)
+
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
public boolean canBlockCatchFire(IBlockAccess iblockaccess, int i, int j, int k)
{
- int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
- return chanceToEncourageFire[iblockaccess.getBlockId(i, j, k)] > 0;
+ return canBlockCatchFire(iblockaccess, i, j, k, 0);
}
+ public boolean canBlockCatchFire(IBlockAccess world, int i, int j, int k, int face)
+ {
+ Block block = Block.blocksList[world.getBlockId(i, j, k)];
+ if (block != null)
+ {
@ -171,6 +187,16 @@
+ return false;
+ }
+
+ /*
+ * Added for backwards compatibility, should not be called by anyone who is making a mod for forge
+ */
+ @Deprecated
public int getChanceToEncourageFire(World world, int i, int j, int k, int l)
{
- int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
+ return getChanceToEncourageFire(world, i, j, k, l, 0);
+ }
+
+ public int getChanceToEncourageFire(World world, int i, int j, int k, int l, int face)
+ {
+ int i1 = 0;
@ -182,7 +208,7 @@
if(i1 > l)
{
return i1;
@@ -247,12 +254,12 @@
@@ -247,12 +286,12 @@
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
@ -197,7 +223,7 @@
{
world.setBlockWithNotify(i, j, k, 0);
return;
@@ -268,7 +275,7 @@
@@ -268,7 +307,7 @@
{
return;
}