testserver/patches/server/0551-Fix-interact-event-not...

30 lines
2.2 KiB
Diff
Raw Normal View History

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-08-05 22:58:34 +00:00
index 25b44f5f83bf03fb6910b06c79f35ac10bf50e3a..7db3c6502eb15192e876f5c766bf64c30f52e9c4 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
@@ -1855,7 +1855,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-08-05 22:58:34 +00:00
@@ -2615,7 +2615,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 12:02:28 +00:00
Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
2021-06-14 18:50:22 +00:00
HitResult movingobjectposition = this.player.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player));
2021-06-11 12:02:28 +00: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 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
}