Server side only item callback: allow a held item to decide if it wants to pass sneak-clicks through

to a block, or not. Defaults false- the same as the new vanilla behaviour (sneak clicks with an item
in hand don't activateBlock anymore).
This commit is contained in:
Christian 2012-12-21 03:15:12 -05:00
parent 708516e060
commit 3d5197ea33
2 changed files with 25 additions and 11 deletions

View file

@ -18,17 +18,16 @@
public class Item
{
@@ -229,6 +232,9 @@
@@ -230,18 +233,26 @@
/** full name of item from language file */
private String itemName;
+
+ /** FORGE: To disable repair recipes. */
+ protected boolean canRepair = true;
+
public Item(int par1)
{
@@ -236,12 +242,17 @@
this.shiftedIndex = 256 + par1;
if (itemsList[256 + par1] != null)
{
@ -58,7 +57,7 @@
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3);
}
@@ -701,4 +716,289 @@
@@ -701,4 +716,304 @@
{
StatList.initStats();
}
@ -346,5 +345,20 @@
+ original.theMaximumChanceToGenerateItem, original.itemWeight);
+ }
+ return original;
+ }
+
+ /**
+ *
+ * Should this item, when held, allow sneak-clicks to pass through to the underlying block?
+ *
+ * @param par2World
+ * @param par4
+ * @param par5
+ * @param par6
+ * @return
+ */
+ public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6)
+ {
+ return false;
+ }
}

View file

@ -180,7 +180,7 @@
+ Block block = Block.blocksList[var11];
+ boolean result = false;
+
+ if (block != null && (!par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null))
+ if (block != null && (!par1EntityPlayer.isSneaking() || ( par1EntityPlayer.getHeldItem() == null || par1EntityPlayer.getHeldItem().getItem().shouldPassSneakingClickToBlock(par2World, par4, par5, par6))))
+ {
+ if (event.useBlock != Event.Result.DENY)
+ {