New Block hook to determine if it can be destroied by the ender dragon, for PR 199

This commit is contained in:
LexManos 2012-10-14 20:17:07 -07:00
parent 91e88afdbe
commit 006a27dcd6
2 changed files with 33 additions and 1 deletions

View file

@ -102,7 +102,7 @@
{
ItemStack var8 = this.createStackedBlock(par6);
@@ -1249,4 +1255,816 @@
@@ -1249,4 +1255,831 @@
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
@ -917,5 +917,20 @@
+ public int getLightOpacity(World world, int x, int y, int z)
+ {
+ return lightOpacity[blockID];
+ }
+
+ /**
+ * Determines if this block is destroyed when a ender dragon tries to fly through it.
+ * The block will be set to 0, nothing will drop.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z position
+ * @return True to allow the ender dragon to destroy this block
+ */
+ public boolean canDragonDestroy(World world, int x, int y, int z)
+ {
+ return blockID != obsidian.blockID && blockID != whiteStone.blockID && blockID != bedrock.blockID;
+ }
}

View file

@ -0,0 +1,17 @@
--- ../src_base/common/net/minecraft/src/EntityDragon.java
+++ ../src_work/common/net/minecraft/src/EntityDragon.java
@@ -505,10 +505,11 @@
for (int var12 = var4; var12 <= var7; ++var12)
{
int var13 = this.worldObj.getBlockId(var10, var11, var12);
-
- if (var13 != 0)
+ Block block = Block.blocksList[var13];
+
+ if (block != null)
{
- if (var13 != Block.obsidian.blockID && var13 != Block.whiteStone.blockID && var13 != Block.bedrock.blockID)
+ if (block.canDragonDestroy(worldObj, var10, var11, var12))
{
var9 = true;
this.worldObj.setBlockWithNotify(var10, var11, var12, 0);