diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch index 3382277d27..2839c87a25 100644 --- a/nms-patches/ItemBoat.patch +++ b/nms-patches/ItemBoat.patch @@ -15,12 +15,20 @@ EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z); entityboat.setType(this.b); -@@ -49,7 +57,7 @@ +@@ -49,7 +57,15 @@ return InteractionResultWrapper.d(itemstack); } else { if (!world.isClientSide) { - world.addEntity(entityboat); -+ if (!world.addEntity(entityboat)) return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); // CraftBukkit ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) { ++ return InteractionResultWrapper.d(itemstack); ++ } ++ ++ if (!world.addEntity(entityboat)) { ++ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); ++ } ++ // CraftBukkit end if (!entityhuman.abilities.canInstantlyBuild) { itemstack.subtract(1); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 698ab262a2..1c8fb24d45 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -342,9 +342,13 @@ public class CraftEventFactory { } public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) { - Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity(); - org.bukkit.block.Block blockClicked = CraftBlock.at(itemactioncontext.getWorld(), itemactioncontext.getClickPosition()); - org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(itemactioncontext.getClickedFace()); + return callEntityPlaceEvent(itemactioncontext.getWorld(), itemactioncontext.getClickPosition(), itemactioncontext.getClickedFace(), itemactioncontext.getEntity(), entity); + } + + public static EntityPlaceEvent callEntityPlaceEvent(World world, BlockPosition clickPosition, EnumDirection clickedFace, EntityHuman human, Entity entity) { + Player who = (human == null) ? null : (Player) human.getBukkitEntity(); + org.bukkit.block.Block blockClicked = CraftBlock.at(world, clickPosition); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace); EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace); entity.world.getServer().getPluginManager().callEvent(event);