Paper/patches/server/0564-Fix-interact-event-not-being-called-in-adventure.patch

30 lines
2.2 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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
2021-11-24 18:37:07 +01:00
index ff36ca2dbdf4a9abb953097f1b6246a177370b02..f9490e629b8aa94158724850812414ede2df7e92 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2021-11-24 18:37:07 +01:00
@@ -1739,7 +1739,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
2021-06-14 20:50:22 +02:00
MutableComponent ichatmutablecomponent = (new TranslatableComponent("build.tooHigh", new Object[]{i - 1})).withStyle(ChatFormatting.RED);
2021-06-11 14:02:28 +02:00
2021-11-24 18:37:07 +01:00
this.player.sendMessage(ichatmutablecomponent, ChatType.GAME_INFO, Util.NIL_UUID);
2021-06-11 14:02:28 +02:00
- } else if (enuminteractionresult.shouldSwing()) {
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) {
this.player.swing(enumhand, true);
}
}
2021-11-24 18:37:07 +01:00
@@ -2211,7 +2211,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
2021-06-11 14:02:28 +02:00
Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
2021-06-14 20:50:22 +02:00
HitResult movingobjectposition = this.player.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player));
2021-06-11 14:02:28 +02:00
- 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
2021-06-14 20:50:22 +02:00
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
2021-06-11 14:02:28 +02:00
}