mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
212 lines
9.2 KiB
Diff
212 lines
9.2 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockFire.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockFire.java
|
|
@@ -41,18 +41,24 @@
|
|
int j = pos.getY();
|
|
int k = pos.getZ();
|
|
|
|
- if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
|
|
+ if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down(), EnumFacing.UP))
|
|
{
|
|
boolean flag = (i + j + k & 1) == 1;
|
|
boolean flag1 = (i / 2 + j / 2 + k / 2 & 1) == 1;
|
|
int l = 0;
|
|
|
|
- if (this.canCatchFire(worldIn, pos.up()))
|
|
+ if (this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN))
|
|
{
|
|
l = flag ? 1 : 2;
|
|
}
|
|
|
|
- return state.withProperty(NORTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canCatchFire(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canCatchFire(worldIn, pos.west()))).withProperty(UPPER, Integer.valueOf(l)).withProperty(FLIP, Boolean.valueOf(flag1)).withProperty(ALT, Boolean.valueOf(flag));
|
|
+ return state.withProperty(NORTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)))
|
|
+ .withProperty(EAST, Boolean.valueOf(this.canCatchFire(worldIn, pos.east(), EnumFacing.EAST )))
|
|
+ .withProperty(SOUTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)))
|
|
+ .withProperty(WEST, Boolean.valueOf(this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST )))
|
|
+ .withProperty(UPPER, Integer.valueOf(l))
|
|
+ .withProperty(FLIP, Boolean.valueOf(flag1))
|
|
+ .withProperty(ALT, Boolean.valueOf(flag));
|
|
}
|
|
else
|
|
{
|
|
@@ -108,6 +114,7 @@
|
|
|
|
public void setFireInfo(Block blockIn, int encouragement, int flammability)
|
|
{
|
|
+ if (blockIn == Blocks.air) throw new IllegalArgumentException("Tried to set air on fire... This is bad.");
|
|
this.encouragements.put(blockIn, Integer.valueOf(encouragement));
|
|
this.flammabilities.put(blockIn, Integer.valueOf(flammability));
|
|
}
|
|
@@ -147,13 +154,8 @@
|
|
}
|
|
|
|
Block block = worldIn.getBlockState(pos.down()).getBlock();
|
|
- boolean flag = block == Blocks.netherrack;
|
|
+ boolean flag = block.isFireSource(worldIn, pos.down(), EnumFacing.UP);
|
|
|
|
- if (worldIn.provider instanceof WorldProviderEnd && block == Blocks.bedrock)
|
|
- {
|
|
- flag = true;
|
|
- }
|
|
-
|
|
if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos))
|
|
{
|
|
worldIn.setBlockToAir(pos);
|
|
@@ -182,7 +184,7 @@
|
|
return;
|
|
}
|
|
|
|
- if (!this.canCatchFire(worldIn, pos.down()) && i == 15 && rand.nextInt(4) == 0)
|
|
+ if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0)
|
|
{
|
|
worldIn.setBlockToAir(pos);
|
|
return;
|
|
@@ -197,12 +199,12 @@
|
|
j = -50;
|
|
}
|
|
|
|
- this.catchOnFire(worldIn, pos.east(), 300 + j, rand, i);
|
|
- this.catchOnFire(worldIn, pos.west(), 300 + j, rand, i);
|
|
- this.catchOnFire(worldIn, pos.down(), 250 + j, rand, i);
|
|
- this.catchOnFire(worldIn, pos.up(), 250 + j, rand, i);
|
|
- this.catchOnFire(worldIn, pos.north(), 300 + j, rand, i);
|
|
- this.catchOnFire(worldIn, pos.south(), 300 + j, rand, i);
|
|
+ this.tryCatchFire(worldIn, pos.east(), 300 + j, rand, i, EnumFacing.WEST);
|
|
+ this.tryCatchFire(worldIn, pos.west(), 300 + j, rand, i, EnumFacing.EAST);
|
|
+ this.tryCatchFire(worldIn, pos.down(), 250 + j, rand, i, EnumFacing.UP);
|
|
+ this.tryCatchFire(worldIn, pos.up(), 250 + j, rand, i, EnumFacing.DOWN);
|
|
+ this.tryCatchFire(worldIn, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH);
|
|
+ this.tryCatchFire(worldIn, pos.south(), 300 + j, rand, i, EnumFacing.NORTH);
|
|
|
|
for (int k = -1; k <= 1; ++k)
|
|
{
|
|
@@ -261,22 +263,30 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated // Use Block.getFlammability
|
|
public int getFlammability(Block blockIn)
|
|
{
|
|
Integer integer = (Integer)this.flammabilities.get(blockIn);
|
|
return integer == null ? 0 : integer.intValue();
|
|
}
|
|
|
|
+ @Deprecated // Use Block.getFlammability
|
|
public int getEncouragement(Block blockIn)
|
|
{
|
|
Integer integer = (Integer)this.encouragements.get(blockIn);
|
|
return integer == null ? 0 : integer.intValue();
|
|
}
|
|
|
|
+ @Deprecated // Use tryCatchFire with face below
|
|
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
|
|
{
|
|
- int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());
|
|
+ this.tryCatchFire(worldIn, pos, chance, random, age, EnumFacing.UP);
|
|
+ }
|
|
|
|
+ private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face)
|
|
+ {
|
|
+ int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);
|
|
+
|
|
if (random.nextInt(chance) < i)
|
|
{
|
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
|
@@ -308,7 +318,7 @@
|
|
{
|
|
for (EnumFacing enumfacing : EnumFacing.values())
|
|
{
|
|
- if (this.canCatchFire(worldIn, pos.offset(enumfacing)))
|
|
+ if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()))
|
|
{
|
|
return true;
|
|
}
|
|
@@ -329,7 +339,7 @@
|
|
|
|
for (EnumFacing enumfacing : EnumFacing.values())
|
|
{
|
|
- i = Math.max(this.getEncouragement(worldIn.getBlockState(pos.offset(enumfacing)).getBlock()), i);
|
|
+ i = Math.max(worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getFlammability(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()), i);
|
|
}
|
|
|
|
return i;
|
|
@@ -341,9 +351,10 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated // Use canCatchFire with face sensitive version below
|
|
public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos)
|
|
{
|
|
- return this.getEncouragement(worldIn.getBlockState(pos).getBlock()) > 0;
|
|
+ return canCatchFire(worldIn, pos, EnumFacing.UP);
|
|
}
|
|
|
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
|
@@ -382,9 +393,9 @@
|
|
worldIn.playSound((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "fire.fire", 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
|
|
}
|
|
|
|
- if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
|
|
+ if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down(), EnumFacing.UP))
|
|
{
|
|
- if (Blocks.fire.canCatchFire(worldIn, pos.west()))
|
|
+ if (Blocks.fire.canCatchFire(worldIn, pos.west(), EnumFacing.EAST))
|
|
{
|
|
for (int j = 0; j < 2; ++j)
|
|
{
|
|
@@ -395,7 +406,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.fire.canCatchFire(worldIn, pos.east()))
|
|
+ if (Blocks.fire.canCatchFire(worldIn, pos.east(), EnumFacing.WEST))
|
|
{
|
|
for (int k = 0; k < 2; ++k)
|
|
{
|
|
@@ -406,7 +417,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.fire.canCatchFire(worldIn, pos.north()))
|
|
+ if (Blocks.fire.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH))
|
|
{
|
|
for (int l = 0; l < 2; ++l)
|
|
{
|
|
@@ -417,7 +428,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.fire.canCatchFire(worldIn, pos.south()))
|
|
+ if (Blocks.fire.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH))
|
|
{
|
|
for (int i1 = 0; i1 < 2; ++i1)
|
|
{
|
|
@@ -428,7 +439,7 @@
|
|
}
|
|
}
|
|
|
|
- if (Blocks.fire.canCatchFire(worldIn, pos.up()))
|
|
+ if (Blocks.fire.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN))
|
|
{
|
|
for (int j1 = 0; j1 < 2; ++j1)
|
|
{
|
|
@@ -476,4 +487,19 @@
|
|
{
|
|
return new BlockState(this, new IProperty[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT});
|
|
}
|
|
+
|
|
+ /*================================= Forge Start ======================================*/
|
|
+ /**
|
|
+ * Side sensitive version that calls the block function.
|
|
+ *
|
|
+ * @param world The current world
|
|
+ * @param pos Block position
|
|
+ * @param face The side the fire is coming from
|
|
+ * @return True if the face can catch fire.
|
|
+ */
|
|
+ public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face)
|
|
+ {
|
|
+ return world.getBlockState(pos).getBlock().isFlammable(world, pos, face);
|
|
+ }
|
|
+ /*================================= Forge Start ======================================*/
|
|
}
|