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

34 lines
2 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
2021-06-11 15:00:00 +10:00
@@ -56,6 +56,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
2021-06-11 15:00:00 +10:00
entityboat.setType(this.type);
@@ -64,7 +71,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
2021-06-11 15:00:00 +10:00
world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, new BlockPosition(movingobjectpositionblock.getPos()));
if (!entityhuman.getAbilities().instabuild) {
2019-12-11 09:00:00 +11:00
itemstack.subtract(1);