From f5fad449bd3b9c822318a0bc2e97c51147bb2c2b Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 12 Dec 2013 01:56:49 -0600 Subject: Call interact event if block cannot be punched. Fixes BUKKIT-5126 We do ray tracing on arm swings to filter out swings that hit blocks since punching blocks has its own event handling. However, some blocks cannot be punched so the air interact type is still valid for them. Luckily these blocks all have a means to query them so add an additional check for this and don't fail the check for them. --- src/main/java/net/minecraft/server/PlayerConnection.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/net/minecraft/server/PlayerConnection.java') diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java index da1a7e70..c1483013 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -962,7 +962,17 @@ public class PlayerConnection implements PacketPlayInListener { Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true); + boolean valid = false; if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) { + valid = true; + } else { + Block block = this.player.world.getType(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d); + if (!block.c()) { // Should be isBreakable? + valid = true; + } + } + + if (valid) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand()); } -- cgit v1.2.3