2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockTurtleEgg.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockTurtleEgg.java
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -28,6 +28,12 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2018-08-02 23:24:19 +02:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
2021-03-08 22:47:33 +01:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
2018-08-02 23:24:19 +02:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2018-08-02 23:24:19 +02:00
|
|
|
public class BlockTurtleEgg extends Block {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final int MAX_HATCH_LEVEL = 2;
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -61,6 +67,19 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
private void destroyEgg(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) {
|
|
|
|
if (this.canDestroyEgg(world, entity)) {
|
|
|
|
if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.is(Blocks.TURTLE_EGG)) {
|
2021-06-11 07:00:00 +02: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));
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ }
|
2018-08-16 12:23:17 +02:00
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
+ if (cancellable.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
this.decreaseEggs(world, blockposition, iblockdata);
|
2018-08-02 23:24:19 +02:00
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -86,9 +105,19 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
int i = (Integer) iblockdata.getValue(BlockTurtleEgg.HATCH);
|
2019-01-17 03:02:34 +01:00
|
|
|
|
|
|
|
if (i < 2) {
|
|
|
|
+ // CraftBukkit start - Call BlockGrowEvent
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2)) {
|
2019-01-17 03:02:34 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
2021-11-21 23:00:00 +01:00
|
|
|
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2);
|
|
|
|
+ // worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2); // CraftBukkit - handled above
|
2019-01-17 03:02:34 +01:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start - Call BlockFadeEvent
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
|
2019-01-17 03:02:34 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
2021-11-21 23:00:00 +01:00
|
|
|
worldserver.removeBlock(blockposition, false);
|
2019-12-10 23:00:00 +01:00
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -99,7 +128,7 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
entityturtle.setAge(-24000);
|
2020-06-25 02:00:00 +02:00
|
|
|
entityturtle.setHomePos(blockposition);
|
2021-11-21 23:00:00 +01:00
|
|
|
entityturtle.moveTo((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F);
|
|
|
|
- worldserver.addFreshEntity(entityturtle);
|
|
|
|
+ worldserver.addFreshEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit
|
2018-07-29 02:50:56 +02:00
|
|
|
}
|
|
|
|
}
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|