2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
Date: Sun, 11 Feb 2018 10:43:46 +0000
|
|
|
|
Subject: [PATCH] Extend Player Interact cancellation
|
|
|
|
|
|
|
|
GUIs are opened on the client, meaning that the server cannot block them from opening,
|
|
|
|
However, it is possible to close these GUIs from the server.
|
|
|
|
|
|
|
|
Flower pots are also not updated on the client when interaction is cancelled, this patch
|
|
|
|
also resolves this.
|
|
|
|
|
|
|
|
Update adjacent blocks of doors, double plants, pistons and beds
|
|
|
|
when cancelling interaction.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2022-06-07 20:45:38 +00:00
|
|
|
index b18bb06caf5f034dffbb72120c8f21da482ae3df..53717a4a2bfd841346c00b5f854899e23661122c 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2022-06-07 20:45:38 +00:00
|
|
|
@@ -186,6 +186,11 @@ public class ServerPlayerGameMode {
|
2021-06-12 16:56:13 +00:00
|
|
|
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
2021-06-11 12:02:28 +00:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
// Let the client know the block still exists
|
|
|
|
+ // Paper start - brute force neighbor blocks for any attached blocks
|
|
|
|
+ for (Direction dir : Direction.values()) {
|
|
|
|
+ this.player.connection.send(new ClientboundBlockUpdatePacket(level, pos.relative(dir)));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
|
|
|
// Update any tile entity data for this block
|
|
|
|
BlockEntity tileentity = this.level.getBlockEntity(pos);
|
2022-06-07 20:45:38 +00:00
|
|
|
@@ -509,7 +514,13 @@ public class ServerPlayerGameMode {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
// send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
|
|
|
|
player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above()));
|
|
|
|
+ // Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method
|
2021-06-12 16:56:13 +00:00
|
|
|
+ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) {
|
|
|
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId));
|
|
|
|
+ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) {
|
|
|
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId));
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
+ // Paper end - extend Player Interact cancellation
|
|
|
|
player.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
|
|
|
enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
|
|
|
} else if (this.gameModeForPlayer == GameType.SPECTATOR) {
|