aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0557-Fix-interact-event-not-being-called-in-adventure.patch
blob: 49080fbb8ec3f3b181681780aa58b04a18b33d67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TheMolkaPL <themolkapl@gmail.com>
Date: Sun, 21 Jun 2020 17:21:46 +0200
Subject: [PATCH] Fix interact event not being called in adventure

Call PlayerInteractEvent when left-clicking on a block in adventure mode

diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 9dd934166b96b9379f549d52386fc83894079212..1bd25f0d74ab3a018b56df7a517e661b9af32341 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1760,7 +1760,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
                             MutableComponent ichatmutablecomponent = (new TranslatableComponent("build.tooHigh", new Object[]{i - 1})).withStyle(ChatFormatting.RED);
 
                             this.player.sendMessage(ichatmutablecomponent, ChatType.GAME_INFO, Util.NIL_UUID);
-                        } else if (enuminteractionresult.shouldSwing()) {
+                } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) {
                             this.player.swing(enumhand, true);
                         }
                     }
@@ -2238,7 +2238,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
         Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
         HitResult movingobjectposition = this.player.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player));
 
-        if (movingobjectposition == null || movingobjectposition.getType() != HitResult.Type.BLOCK) {
+        if (movingobjectposition == null || movingobjectposition.getType() != HitResult.Type.BLOCK || this.player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { // Paper - call PlayerInteractEvent when left-clicking on a block in adventure mode
             CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
         }