Commits

Doc authored and md_5 committed c18668be3d7
SPIGOT-7192: Call PlayerInteractEvent with Action.LEFT_CLICK_AIR if the entity interacted is hidden to the player
No tags

nms-patches/net/minecraft/server/network/PlayerConnection.patch

Modified
1154 1154 + // CraftBukkit start - Raytrace to look for 'rogue armswings'
1155 1155 + float f1 = this.player.getXRot();
1156 1156 + float f2 = this.player.getYRot();
1157 1157 + double d0 = this.player.getX();
1158 1158 + double d1 = this.player.getY() + (double) this.player.getEyeHeight();
1159 1159 + double d2 = this.player.getZ();
1160 1160 + Location origin = new Location(this.player.level.getWorld(), d0, d1, d2, f2, f1);
1161 1161 +
1162 1162 + double d3 = player.gameMode.getGameModeForPlayer() == EnumGamemode.CREATIVE ? 5.0D : 4.5D;
1163 1163 + // SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time
1164 -+ org.bukkit.util.RayTraceResult result = this.player.level.getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> entity != this.player.getBukkitEntity());
1164 ++ org.bukkit.util.RayTraceResult result = this.player.level.getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity));
1165 1165 +
1166 1166 + if (result == null) {
1167 1167 + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
1168 1168 + }
1169 1169 +
1170 1170 + // Arm swing animation
1171 1171 + PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packetplayinarmanimation.getHand() == EnumHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
1172 1172 + this.cserver.getPluginManager().callEvent(event);
1173 1173 +
1174 1174 + if (event.isCancelled()) return;

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut