2021-03-16 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								--- a/net/minecraft/server/level/PlayerInteractManager.java
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/net/minecraft/server/level/PlayerInteractManager.java
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-01 02:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -26,6 +26,27 @@
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 import net.minecraft.world.phys.Vec3D;
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-01 02:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 import org.slf4j.Logger;
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-09 08:47:33 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import java.util.ArrayList;
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-16 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.server.MinecraftServer;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.entity.EnumItemSlot;
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 11:37:52 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.item.ItemBisected;
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-16 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.block.BlockCake;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.block.BlockDoor;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.block.BlockTrapdoor;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.block.Blocks;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.block.state.properties.BlockPropertyDoubleBlockHalf;
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-13 08:43:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.GameMode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-31 19:55:04 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.block.CraftBlock;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.block.BlockBreakEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.event.CraftEventFactory;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.Event;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.block.Action;
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-13 08:43:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.player.PlayerGameModeChangeEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.player.PlayerInteractEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-09 08:47:33 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 public class PlayerInteractManager {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-01 02:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     private static final Logger LOGGER = LogUtils.getLogger();
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -56,9 +77,16 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-13 08:43:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (enumgamemode == this.gameModeForPlayer) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(player.getBukkitEntity(), GameMode.getByValue(enumgamemode.getId()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            level.getCraftServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             this.setGameModeForPlayer(enumgamemode, this.previousGameModeForPlayer);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             this.player.onUpdateAbilities();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_GAME_MODE, this.player));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             this.level.updateSleepingPlayerList();
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-13 08:43:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-01 02:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -88,7 +116,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void tick() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        ++this.gameTicks;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         IBlockData iblockdata;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (this.hasDelayedDestroy) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -142,11 +170,33 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (!this.level.mayInteract(this.player, blockposition)) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit start - fire PlayerInteractEvent
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     this.debugLogging(blockposition, false, j, "may not interact");
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // Update any tile entity data for this block
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    TileEntity tileentity = level.getBlockEntity(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (tileentity != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(tileentity.getUpdatePacket());
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // Let the client know the block still exists
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // Update any tile entity data for this block
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    TileEntity tileentity = this.level.getBlockEntity(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (tileentity != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(tileentity.getUpdatePacket());
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (this.isCreative()) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.destroyAndAck(blockposition, j, "creative destroy");
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     return;
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -162,11 +212,43 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 float f = 1.0F;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 iblockdata = this.level.getBlockState(blockposition);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                if (!iblockdata.isAir()) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start - Swings at air do *NOT* exist.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (event.useInteractedBlock() == Event.Result.DENY) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    IBlockData data = this.level.getBlockState(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (data.getBlock() instanceof BlockDoor) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        // For some reason *BOTH* the bottom/top part have to be marked updated.
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        boolean bottom = data.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.above() : blockposition.below()));
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    } else if (data.getBlock() instanceof BlockTrapdoor) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                } else if (!iblockdata.isAir()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     iblockdata.attack(this.level, blockposition, this.player);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (event.useItemInHand() == Event.Result.DENY) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // If we 'insta destroyed' then the client needs to be informed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    if (f > 1.0f) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:24 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelected(), f >= 1.0f);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (blockEvent.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // Let the client know the block still exists
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (blockEvent.getInstaBreak()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    f = 2.0f;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (!iblockdata.isAir() && f >= 1.0F) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     this.destroyAndAck(blockposition, j, "insta mine");
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 } else {
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -211,13 +293,15 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-25 10:28:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 this.isDestroyingBlock = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 if (!Objects.equals(this.destroyPos, blockposition)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                    PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.debugLogging(blockposition, true, j, "aborted mismatched destroying");
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-25 10:28:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 this.level.destroyBlockProgress(this.player.getId(), blockposition, -1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 this.debugLogging(blockposition, true, j, "aborted destroying");
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelected()); // CraftBukkit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -235,10 +319,65 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public boolean destroyBlock(BlockPosition blockposition) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         IBlockData iblockdata = this.level.getBlockState(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start - fire BlockBreakEvent
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        BlockBreakEvent event = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (this.player instanceof EntityPlayer) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // Sword + Creative mode pre-cancel
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // Tell client the block is gone immediately then process events
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // Don't tell the client if its a creative sword break because its not broken!
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (level.getBlockEntity(blockposition) == null && !isSwordNoBreak) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.defaultBlockState());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.player.connection.send(packet);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-31 19:55:04 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // Sword + Creative mode pre-cancel
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            event.setCancelled(isSwordNoBreak);
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // Calculate default block experience
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            IBlockData nmsData = this.level.getBlockState(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            Block nmsBlock = nmsData.getBlock();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            ItemStack itemstack = this.player.getItemBySlot(EnumItemSlot.MAINHAND);
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack, true));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-13 08:43:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.level.getCraftServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-04 06:39:01 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (isSwordNoBreak) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // Let the client know the block still exists
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-        if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-03 11:34:26 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // Brute force all possible updates
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                for (EnumDirection dir : EnumDirection.values()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    this.player.connection.send(new PacketPlayOutBlockChange(level, blockposition.relative(dir)));
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-10 16:58:14 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 08:56:23 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // Update any tile entity data for this block
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                TileEntity tileentity = this.level.getBlockEntity(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (tileentity != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    this.player.connection.send(tileentity.getUpdatePacket());
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-07 13:57:35 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (false && !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             TileEntity tileentity = this.level.getBlockEntity(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             Block block = iblockdata.getBlock();
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -248,6 +387,10 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-31 19:55:04 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                org.bukkit.block.BlockState state = bblock.getState();
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                level.captureDrops = new ArrayList<>();
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 boolean flag = this.level.removeBlock(blockposition, false);
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-08 02:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -256,19 +399,32 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 if (this.isCreative()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                    return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // return true; // CraftBukkit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     ItemStack itemstack = this.player.getMainHandItem();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     ItemStack itemstack1 = itemstack.copy();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     boolean flag1 = this.player.hasCorrectToolForDrops(iblockdata);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     itemstack.mineBlock(this.level, iblockdata, blockposition, this.player);
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-27 21:16:13 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                    if (flag && flag1) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         block.playerDestroy(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1);
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-27 21:16:13 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     }
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                    return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // return true; // CraftBukkit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-30 11:20:39 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (event.isDropItems()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops);
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                level.captureDrops = null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // Drop event experience
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (flag && event != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    iblockdata.getBlock().popExperience(this.level, blockposition, event.getExpToDrop());
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-20 09:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -313,14 +469,54 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-09 09:38:52 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start - whole method
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-04 06:39:01 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean interactResult = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public boolean firedInteract = false;
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-12 08:36:10 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public BlockPosition interactPosition;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public EnumHand interactHand;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public ItemStack interactItemStack;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public EnumInteractionResult useItemOn(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         IBlockData iblockdata = world.getBlockState(blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-22 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        boolean cancelledBlock = false;
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 21:01:15 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (!iblockdata.getBlock().isEnabled(world.enabledFeatures())) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             return EnumInteractionResult.FAIL;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            cancelledBlock = !(itileinventory instanceof ITileInventory);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            cancelledBlock = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-04 06:39:01 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        firedInteract = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        interactResult = event.useItemInHand() == Event.Result.DENY;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        interactPosition = blockposition.immutable();
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-12 08:36:10 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        interactHand = enumhand;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        interactItemStack = itemstack.copy();
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 21:01:15 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (event.useInteractedBlock() == Event.Result.DENY) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (iblockdata.getBlock() instanceof BlockDoor) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                boolean bottom = iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                entityplayer.connection.send(new PacketPlayOutBlockChange(world, bottom ? blockposition.above() : blockposition.below()));
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            } else if (iblockdata.getBlock() instanceof BlockCake) {
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 11:37:52 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            } else if (interactItemStack.getItem() instanceof ItemBisected) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // send a correcting update to the client, as it already placed the upper half of the bisected item
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.relative(movingobjectpositionblock.getDirection()).above()));
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-27 11:37:52 +10: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)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.above()));
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition);
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (itileinventory != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 entityplayer.openMenu(itileinventory);
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -334,7 +530,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             ItemStack itemstack1 = itemstack.copy();
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (!flag1) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                EnumInteractionResult enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock);
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (enuminteractionresult.consumesAction()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -342,17 +538,17 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-22 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 EnumInteractionResult enuminteractionresult1;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 if (this.isCreative()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     int i = itemstack.getCount();
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-28 17:23:39 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                    enuminteractionresult1 = itemstack.useOn(itemactioncontext);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     itemstack.setCount(i);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                    enuminteractionresult1 = itemstack.useOn(itemactioncontext);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (enuminteractionresult1.consumesAction()) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-08 03:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -360,10 +556,10 @@
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 return enuminteractionresult1;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-22 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                return EnumInteractionResult.PASS;
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        return enuminteractionresult;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void setLevel(WorldServer worldserver) {
							 |