2018-07-29 08:50:56 +08:00
|
|
|
--- a/net/minecraft/server/BlockTurtleEgg.java
|
|
|
|
+++ b/net/minecraft/server/BlockTurtleEgg.java
|
2018-08-16 18:23:17 +08:00
|
|
|
@@ -2,6 +2,12 @@
|
|
|
|
|
2018-08-03 05:24:19 +08:00
|
|
|
import java.util.Random;
|
|
|
|
import javax.annotation.Nullable;
|
2018-08-16 18:23:17 +08:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
|
|
+
|
2018-08-03 05:24:19 +08:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
2018-08-16 18:23:17 +08:00
|
|
|
|
2018-08-03 05:24:19 +08:00
|
|
|
public class BlockTurtleEgg extends Block {
|
|
|
|
|
2018-08-26 10:00:00 +08:00
|
|
|
@@ -33,6 +39,19 @@
|
2018-08-03 05:24:19 +08:00
|
|
|
super.stepOn(world, blockposition, entity);
|
|
|
|
} else {
|
|
|
|
if (!world.isClientSide && world.random.nextInt(i) == 0) {
|
2018-08-16 18:23:17 +08:00
|
|
|
+ // 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(), CraftBlock.at(world, blockposition));
|
|
|
|
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (cancellable.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-08-26 10:00:00 +08:00
|
|
|
this.a(world, blockposition, world.getType(blockposition));
|
2018-08-03 05:24:19 +08:00
|
|
|
}
|
2018-08-16 18:23:17 +08:00
|
|
|
|
2018-08-26 10:00:00 +08:00
|
|
|
@@ -70,7 +89,7 @@
|
2018-07-29 08:50:56 +08: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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|