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
2022-06-08 02:00:00 +10:00
@@ -58,6 +58,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
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, false, enumhand, movingobjectpositionblock.getLocation());
+
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
2022-06-08 02:00:00 +10:00
EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock);
2019-04-23 12:00:00 +10:00
2022-12-08 03:00:00 +11:00
entityboat.setVariant(this.type);
2022-06-08 02:00:00 +10:00
@@ -66,7 +73,15 @@
2020-01-22 08:00:00 +11:00
return InteractionResultWrapper.fail(itemstack);
} else {
if (!world.isClientSide) {
2021-11-22 09:00:00 +11:00
- world.addFreshEntity(entityboat);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat, enumhand).isCancelled()) {
2020-01-22 08:00:00 +11:00
+ return InteractionResultWrapper.fail(itemstack);
+ }
+
2021-11-22 09:00:00 +11:00
+ if (!world.addFreshEntity(entityboat)) {
2021-03-16 09:00:00 +11:00
+ return InteractionResultWrapper.pass(itemstack);
+ }
+ // CraftBukkit end
2022-06-08 02:00:00 +10:00
world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation());
2021-06-11 15:00:00 +10:00
if (!entityhuman.getAbilities().instabuild) {
2021-11-22 09:00:00 +11:00
itemstack.shrink(1);