Correctly handle interactions with items on cooldown
This commit is contained in:
@@ -555,6 +555,12 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 targetPos) {
|
||||
// Paper start - cancelledItem param
|
||||
return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, false, hand, targetPos);
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, boolean cancelledItem, InteractionHand hand, Vec3 targetPos) {
|
||||
// Paper end - cancelledItem param
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
|
||||
@@ -589,6 +595,11 @@ public class CraftEventFactory {
|
||||
if (cancelledBlock) {
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
}
|
||||
// Paper start
|
||||
if (cancelledItem) {
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
}
|
||||
// Paper end
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
|
||||
Reference in New Issue
Block a user