Paper/nms-patches/BlockTurtleEgg.patch

45 lines
2.0 KiB
Diff
Raw Normal View History

2018-07-29 02:50:56 +02:00
--- a/net/minecraft/server/BlockTurtleEgg.java
+++ b/net/minecraft/server/BlockTurtleEgg.java
@@ -3,6 +3,11 @@
import java.util.Random;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class BlockTurtleEgg extends Block {
private static final VoxelShape c = Block.a(3.0D, 0.0D, 3.0D, 12.0D, 7.0D, 12.0D);
@@ -34,6 +39,20 @@
if (entity instanceof EntityTurtle) {
super.stepOn(world, blockposition, entity);
} else {
+ // CraftBukkit start - Step on eggs
+ org.bukkit.event.Cancellable cancellable;
+ if (entity instanceof EntityHuman) {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ if (cancellable.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
if (!world.isClientSide && world.random.nextInt(i) == 0) {
this.a(world, blockposition, iblockdata);
}
@@ -72,7 +91,7 @@
2018-07-29 02:50:56 +02:00
entityturtle.setAgeRaw(-24000);
entityturtle.g(blockposition);
entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F);
- world.addEntity(entityturtle);
+ world.addEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit
}
}
}