This allows the result of the explosion to take into account metadata,

tile entities, or even to cancel it altogether.

Allowed block exploding to take into account tile entity and metadata
This commit is contained in:
ChildWalrus 2013-03-24 12:01:06 +00:00 committed by Christian
parent 5f44333b8f
commit 0034a0c6c2
2 changed files with 28 additions and 1 deletions

View File

@ -155,7 +155,7 @@
}
/**
@@ -1435,4 +1455,881 @@
@@ -1435,4 +1455,898 @@
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
@ -724,6 +724,23 @@
+ }
+
+ /**
+ * Called when the block is destroyed by an explosion.
+ * Useful for allowing the block to take into account tile entities,
+ * metadata, etc. when exploded, before it is removed.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param Explosion The explosion instance affecting the block
+ */
+ public void onBlockExploded(World world, int x, int y, int z, Explosion explosion)
+ {
+ world.setBlockToAir(x, y, z);
+ onBlockDestroyedByExplosion(world, x, y, z, explosion);
+ }
+
+ /**
+ * Determine if this block can make a redstone connection on the side provided,
+ * Useful to control which sides are inputs and outputs for redstone wires.
+ *

View File

@ -9,3 +9,13 @@
f1 -= (f3 + 0.3F) * f2;
}
@@ -222,8 +222,7 @@
block.dropBlockAsItemWithChance(this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1.0F / this.explosionSize, 0);
}
- this.worldObj.setBlock(i, j, k, 0, 0, 3);
- block.onBlockDestroyedByExplosion(this.worldObj, i, j, k, this);
+ block.onBlockExploded(this.worldObj, i, j, k, this);
}
}
}