Use expanded interaction ranges for traced interact events

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-06-16 18:39:52 +10:00
parent d2d0972bc3
commit 9707379cfa

View file

@ -717,7 +717,7 @@
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
+ float f7 = f4 * f5;
+ float f8 = f3 * f5;
+ double d3 = player.gameMode.getGameModeForPlayer()== EnumGamemode.CREATIVE ? 5.0D : 4.5D;
+ double d3 = player.blockInteractionRange();
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player));
+
@ -1121,7 +1121,7 @@
+ double d2 = this.player.getZ();
+ Location origin = new Location(this.player.level().getWorld(), d0, d1, d2, f2, f1);
+
+ double d3 = player.gameMode.getGameModeForPlayer() == EnumGamemode.CREATIVE ? 5.0D : 4.5D;
+ double d3 = Math.max(player.blockInteractionRange(), player.entityInteractionRange());
+ // 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
+ // SPIGOT-7429: Make sure to call PlayerInteractEvent for spectators and non-pickable entities
+ org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> {