PaperMC/nms-patches/ItemBoat.patch

27 lines
1.6 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemBoat.java
+++ b/net/minecraft/server/ItemBoat.java
2019-04-23 04:00:00 +02:00
@@ -41,6 +41,14 @@
}
if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start - Boat placement
2019-04-23 04:00:00 +02:00
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
+ 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-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ }
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z);
entityboat.setType(this.b);
@@ -49,7 +57,7 @@
2019-12-10 23:00:00 +01:00
return InteractionResultWrapper.d(itemstack);
} else {
if (!world.isClientSide) {
- world.addEntity(entityboat);
+ if (!world.addEntity(entityboat)) return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); // CraftBukkit
2019-12-10 23:00:00 +01:00
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
}