diff --git a/patches/net/minecraft/server/management/ItemInWorldManager.java.patch b/patches/net/minecraft/server/management/ItemInWorldManager.java.patch index 0b2916f8..c66f3fc7 100644 --- a/patches/net/minecraft/server/management/ItemInWorldManager.java.patch +++ b/patches/net/minecraft/server/management/ItemInWorldManager.java.patch @@ -176,7 +176,7 @@ int j = p_73085_3_.getItemDamage(); ItemStack itemstack1 = p_73085_3_.useItemRightClick(p_73085_2_, p_73085_1_); -@@ -350,57 +419,106 @@ +@@ -350,57 +419,113 @@ public boolean activateBlockOrUseItem(EntityPlayer p_73078_1_, World p_73078_2_, ItemStack p_73078_3_, int p_73078_4_, int p_73078_5_, int p_73078_6_, int p_73078_7_, float p_73078_8_, float p_73078_9_, float p_73078_10_) { @@ -186,46 +186,33 @@ - thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld)); - return false; - } -- -- if (p_73078_3_ != null && p_73078_3_.getItem().onItemUseFirst(p_73078_3_, p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_)) -- { -- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_); -- return true; -- } -- + // CraftBukkit start - Interact - Block block = p_73078_2_.getBlock(p_73078_4_, p_73078_5_, p_73078_6_); -- boolean isAir = block.isAir(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_); -- boolean useBlock = !p_73078_1_.isSneaking() || p_73078_1_.getHeldItem() == null; -- if (!useBlock) useBlock = p_73078_1_.getHeldItem().getItem().doesSneakBypassUse(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_); -- boolean result = false; ++ Block block = p_73078_2_.getBlock(p_73078_4_, p_73078_5_, p_73078_6_); + boolean isAir = block.isAir(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_); // Cauldron + boolean denyResult = false, denyItem = false, denyBlock = false; -- if (useBlock) +- if (p_73078_3_ != null && p_73078_3_.getItem().onItemUseFirst(p_73078_3_, p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_)) + if (!isAir) { -- if (event.useBlock != Event.Result.DENY) +- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_); +- return true; +- } + org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(p_73078_1_, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_3_); + net.minecraftforge.event.entity.player.PlayerInteractEvent forgeEvent = ForgeEventFactory.onPlayerBukkitInteract(p_73078_1_, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_2_, event); + + // Cauldron start + // if forge event is explicitly cancelled, return + if (forgeEvent.isCanceled()) - { -- result = block.onBlockActivated(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_); ++ { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld)); + return false; - } -- else ++ } + denyItem = event.useItemInHand() == org.bukkit.event.Event.Result.DENY || forgeEvent.useItem == cpw.mods.fml.common.eventhandler.Event.Result.DENY; + denyBlock = event.useInteractedBlock() == org.bukkit.event.Event.Result.DENY || forgeEvent.useBlock == cpw.mods.fml.common.eventhandler.Event.Result.DENY; + denyResult = denyItem || denyBlock; + // if we have no explicit deny, check if item can be used + if (!denyItem) - { -- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld)); -- result = event.useItem != Event.Result.ALLOW; ++ { + Item item = (p_73078_3_ != null ? p_73078_3_.getItem() : null); + // try to use an item in hand before activating a block. Used for items such as IC2's wrench. + if (item != null && item.onItemUseFirst(p_73078_3_, p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_)) @@ -233,8 +220,7 @@ + if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_); + return true; + } - } -- } ++ } + // Cauldron end + if (denyBlock) + { @@ -265,12 +251,11 @@ + thisPlayerMP.openContainer.bukkitView = new CraftInventoryView(thisPlayerMP.getBukkitEntity(), MinecraftServer.getServer().server.createInventory(thisPlayerMP.getBukkitEntity(), InventoryType.CHEST), thisPlayerMP.openContainer); + } -- if (p_73078_3_ != null && !result && event.useItem != Event.Result.DENY) -- { -- int meta = p_73078_3_.getItemDamage(); -- int size = p_73078_3_.stackSize; -- result = p_73078_3_.tryPlaceItemIntoWorld(p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_); -- if (isCreative()) +- Block block = p_73078_2_.getBlock(p_73078_4_, p_73078_5_, p_73078_6_); +- boolean isAir = block.isAir(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_); +- boolean useBlock = !p_73078_1_.isSneaking() || p_73078_1_.getHeldItem() == null; +- if (!useBlock) useBlock = p_73078_1_.getHeldItem().getItem().doesSneakBypassUse(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_); +- boolean result = false; + thisPlayerMP.openContainer = CraftEventFactory.callInventoryOpenEvent(thisPlayerMP, thisPlayerMP.openContainer, false); + if (thisPlayerMP.openContainer == null) + { @@ -281,11 +266,13 @@ + } + // Cauldron end + } -+ + +- if (useBlock) +- { +- if (event.useBlock != Event.Result.DENY) + if (p_73078_3_ != null && !denyResult && p_73078_3_.stackSize > 0) { -- p_73078_3_.setItemDamage(meta); -- p_73078_3_.stackSize = size; +- result = block.onBlockActivated(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_); + int meta = p_73078_3_.getItemDamage(); + int size = p_73078_3_.stackSize; + denyResult = p_73078_3_.tryPlaceItemIntoWorld(p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_); @@ -302,13 +289,32 @@ + ForgeEventFactory.onPlayerDestroyItem(this.thisPlayerMP, p_73078_3_); + } } -- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_); -+ +- else ++ else if(p_73078_3_ != null && !denyResult) // Thermos call the Forge item destruction event... + { +- thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(p_73078_4_, p_73078_5_, p_73078_6_, theWorld)); +- result = event.useItem != Event.Result.ALLOW; ++ if (p_73078_3_.stackSize <= 0) ++ { ++ ForgeEventFactory.onPlayerDestroyItem(this.thisPlayerMP, p_73078_3_); ++ } + } +- } + +- if (p_73078_3_ != null && !result && event.useItem != Event.Result.DENY) +- { +- int meta = p_73078_3_.getItemDamage(); +- int size = p_73078_3_.stackSize; +- result = p_73078_3_.tryPlaceItemIntoWorld(p_73078_1_, p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_); +- if (isCreative()) + // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook + if (p_73078_3_ != null && ((!denyResult && event.useItemInHand() != org.bukkit.event.Event.Result.DENY) || event.useItemInHand() == org.bukkit.event.Event.Result.ALLOW)) -+ { + { +- p_73078_3_.setItemDamage(meta); +- p_73078_3_.stackSize = size; + this.tryUseItem(p_73078_1_, p_73078_2_, p_73078_3_); -+ } + } +- if (p_73078_3_.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, p_73078_3_); } - /* Re-enable if this causes bukkit incompatibility, or re-write client side to only send a single packet per right click.