PaperMC/patches/server/0518-Fix-interact-event-not-being-called-in-adventure.patch

30 lines
2.3 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
2023-06-08 07:21:04 +02:00
index 3ae085ec1ed9b39c86ae5edeb628ab9118d24cbd..16bc796a138d7dd7220591e59fc1118f05217872 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
2023-06-08 07:21:04 +02:00
@@ -1834,7 +1834,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2022-12-07 21:16:54 +01:00
MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED);
2021-06-11 14:02:28 +02:00
2022-12-07 21:16:54 +01:00
this.player.sendSystemMessage(ichatmutablecomponent, true);
- } else if (enuminteractionresult.shouldSwing()) {
2022-06-08 09:30:41 +02:00
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper
2022-12-07 21:16:54 +01:00
this.player.swing(enumhand, true);
}
2022-03-01 06:43:03 +01:00
}
2023-06-08 07:21:04 +02:00
@@ -2470,7 +2470,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// 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
2023-06-08 01:56:33 +02:00
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() && this.player.getBukkitEntity().canSee(entity));
2021-06-11 14:02:28 +02: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 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
}