2021-06-11 12:02:28 +00: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
2022-09-12 11:31:45 +00:00
index 32227020d0cba1aba3ec0fcda5f4b4cd4b1ce394..c0cca7442d3bb7df393088d66c5962bcda78e609 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2022-08-29 13:21:45 +00:00
@@ -1852,7 +1852,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2022-06-08 07:30:41 +00:00
MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED);
2021-06-11 12:02:28 +00:00
2022-07-27 20:55:55 +00:00
this.player.sendSystemMessage(ichatmutablecomponent, true);
2022-03-01 05:43:03 +00:00
- } else if (enuminteractionresult.shouldSwing()) {
2022-06-08 07:30:41 +00:00
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper
2022-03-01 05:43:03 +00:00
this.player.swing(enumhand, true);
}
}
2022-09-12 11:31:45 +00:00
@@ -2610,7 +2610,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2022-09-09 18:54:00 +00:00
// 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
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());
2021-06-11 12:02:28 +00:00
2022-09-09 18:54:00 +00:00
- if (result == null) {
+ if (result == null || this.player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { // Paper - call PlayerInteractEvent when left-clicking on a block in adventure mode
2021-06-14 18:50:22 +00:00
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
2021-06-11 12:02:28 +00:00
}