mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 00:47:38 +01:00
SPIGOT-794: Add boats to EntityPlaceEvent
This commit is contained in:
parent
fb7abcb37a
commit
90ef74efbe
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user