mirror of
https://github.com/PaperMC/Paper.git
synced 2025-04-12 08:57:39 +02:00
SPIGOT-794: Add boats to EntityPlaceEvent
This commit is contained in:
parent
fb7abcb37a
commit
90ef74efbe
2 changed files with 17 additions and 5 deletions
|
@ -15,12 +15,20 @@
|
||||||
EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z);
|
EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z);
|
||||||
|
|
||||||
entityboat.setType(this.b);
|
entityboat.setType(this.b);
|
||||||
@@ -49,7 +57,7 @@
|
@@ -49,7 +57,15 @@
|
||||||
return InteractionResultWrapper.d(itemstack);
|
return InteractionResultWrapper.d(itemstack);
|
||||||
} else {
|
} else {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
- world.addEntity(entityboat);
|
- 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) {
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||||
itemstack.subtract(1);
|
itemstack.subtract(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,9 +342,13 @@ public class CraftEventFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) {
|
public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) {
|
||||||
Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity();
|
return callEntityPlaceEvent(itemactioncontext.getWorld(), itemactioncontext.getClickPosition(), itemactioncontext.getClickedFace(), itemactioncontext.getEntity(), entity);
|
||||||
org.bukkit.block.Block blockClicked = CraftBlock.at(itemactioncontext.getWorld(), itemactioncontext.getClickPosition());
|
}
|
||||||
org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(itemactioncontext.getClickedFace());
|
|
||||||
|
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);
|
EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace);
|
||||||
entity.world.getServer().getPluginManager().callEvent(event);
|
entity.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
Loading…
Add table
Reference in a new issue