aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-12-05 11:18:29 +0100
committerNassim Jahnke <[email protected]>2024-12-05 12:20:56 +0100
commite4e24f3335609b38f460ced71d18babcf11bf9cb (patch)
tree51880d664b3444ce26d6f8cdeb3b8219e5616fca /patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch
parentc54c062e6ff742445bf7749c84106ca67090172d (diff)
downloadPaper-e4e24f3335609b38f460ced71d18babcf11bf9cb.tar.gz
Paper-e4e24f3335609b38f460ced71d18babcf11bf9cb.zip
Move around patches again
Diffstat (limited to 'patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch')
-rw-r--r--patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch48
1 files changed, 48 insertions, 0 deletions
diff --git a/patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch b/patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch
new file mode 100644
index 0000000000..d8a7435cf0
--- /dev/null
+++ b/patches/server/0448-Fix-interact-event-not-being-called-sometimes.patch
@@ -0,0 +1,48 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: TheMolkaPL <[email protected]>
+Date: Sun, 21 Jun 2020 17:21:46 +0200
+Subject: [PATCH] Fix interact event not being called sometimes
+
+* Call PlayerInteractEvent when left-clicking on a block in adventure
+ mode.
+* Call PlayerInteractEvent when left-clicking an Entity that is out of
+ range in adventure/survival (entity reach is 3.0).
+
+Co-authored-by: Moulberry <[email protected]>
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index 04de96af5415c3115703f5ab42e9fa3aa2ccee60..76b6c3fca13590f057dc4767d27fef4192974147 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -1842,7 +1842,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ } else if (enuminteractionresult instanceof InteractionResult.Success) {
+ InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
+
+- if (enuminteractionresult_d.swingSource() == InteractionResult.SwingSource.SERVER) {
++ if (enuminteractionresult_d.swingSource() == InteractionResult.SwingSource.SERVER && !this.player.gameMode.interactResult) { // Paper - Call interact event
+ this.player.swing(enumhand, true);
+ }
+ }
+@@ -2466,13 +2466,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ double d3 = Math.max(this.player.blockInteractionRange(), this.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 -> {
++ org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.0, entity -> { // Paper - Call interact event; change raySize from 0.1 to 0.0
+ Entity handle = ((CraftEntity) entity).getHandle();
+ return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player);
+ });
+ if (result == null) {
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
+- }
++ } else { // Paper start - Call interact event
++ GameType gameType = this.player.gameMode.getGameModeForPlayer();
++ if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) {
++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
++ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) {
++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
++ }
++ } // Paper end - Call interact event
+
+ // Arm swing animation
+ PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packet.getHand() == InteractionHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);