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