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.
This commit is contained in:
Travis Watkins 2013-12-12 01:56:49 -06:00
parent ca4c118994
commit f5fad449bd

View File

@ -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());
}