craftbukkit/nms-patches/net/minecraft/world/item/ItemBoat.patch

34 lines
1.9 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemBoat.java
+++ b/net/minecraft/world/item/ItemBoat.java
@@ -54,6 +54,13 @@
2019-04-23 12:00:00 +10:00
}
2020-06-25 10:00:00 +10:00
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
2016-03-01 08:32:46 +11:00
+ // CraftBukkit start - Boat placement
2019-04-23 12:00:00 +10:00
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, enumhand);
+
2016-03-01 08:32:46 +11:00
+ if (event.isCancelled()) {
2021-03-16 09:00:00 +11:00
+ return InteractionResultWrapper.pass(itemstack);
2016-03-01 08:32:46 +11:00
+ }
+ // CraftBukkit end
2020-06-25 10:00:00 +10:00
EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z);
2019-04-23 12:00:00 +10:00
entityboat.setType(this.b);
2021-03-16 09:00:00 +11:00
@@ -62,7 +69,15 @@
2020-01-22 08:00:00 +11:00
return InteractionResultWrapper.fail(itemstack);
} else {
if (!world.isClientSide) {
- world.addEntity(entityboat);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) {
2020-01-22 08:00:00 +11:00
+ return InteractionResultWrapper.fail(itemstack);
+ }
+
+ if (!world.addEntity(entityboat)) {
2021-03-16 09:00:00 +11:00
+ return InteractionResultWrapper.pass(itemstack);
+ }
+ // CraftBukkit end
2019-12-11 09:00:00 +11:00
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
}