Rework canSilkHarvest hook to try and honor vanilla overrides, should close #391

This commit is contained in:
LexManos 2013-01-28 17:51:48 -08:00
parent fb87773c3a
commit 704f879320
1 changed files with 20 additions and 6 deletions

View File

@ -141,7 +141,22 @@
{
ItemStack var8 = this.createStackedBlock(par6);
@@ -1364,4 +1380,840 @@
@@ -1097,12 +1113,13 @@
}
}
+ private int silk_check_meta = -1; //Dirty hack to stop us from needing to special case the silk check hook.
/**
* Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
*/
protected boolean canSilkHarvest()
{
- return this.renderAsNormalBlock() && !this.isBlockContainer;
+ return this.renderAsNormalBlock() && !this.hasTileEntity(silk_check_meta);
}
/**
@@ -1364,4 +1381,839 @@
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
@ -493,11 +508,10 @@
+ */
+ public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
+ {
+ if (this instanceof BlockGlass || this instanceof BlockEnderChest)
+ {
+ return true;
+ }
+ return renderAsNormalBlock() && !hasTileEntity(metadata);
+ silk_check_meta = metadata;
+ boolean ret = this.canSilkHarvest();
+ silk_check_meta = 0;
+ return ret;
+ }
+
+ /**