summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authorNathan Wolf <nathan@elmakers.com>2018-08-02 14:24:19 -0700
committermd_5 <git@md-5.net>2018-08-03 08:58:15 +1000
commit391e018a7902d05684f43433d0398287d92499dc (patch)
tree62ff6a40261e887be1d35008af9afbb1eacc2622 /nms-patches
parent4587569c061b07043b3b04c8fce6bcf25a1262f7 (diff)
downloadcraftbukkit-391e018a7902d05684f43433d0398287d92499dc.tar
craftbukkit-391e018a7902d05684f43433d0398287d92499dc.tar.gz
craftbukkit-391e018a7902d05684f43433d0398287d92499dc.tar.lz
craftbukkit-391e018a7902d05684f43433d0398287d92499dc.tar.xz
craftbukkit-391e018a7902d05684f43433d0398287d92499dc.zip
SPIGOT-4220: Player/Entity interact events when turtle eggs are stepped on
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/BlockTurtleEgg.patch35
1 files changed, 34 insertions, 1 deletions
diff --git a/nms-patches/BlockTurtleEgg.patch b/nms-patches/BlockTurtleEgg.patch
index 6dd32865..4c40badf 100644
--- a/nms-patches/BlockTurtleEgg.patch
+++ b/nms-patches/BlockTurtleEgg.patch
@@ -1,6 +1,39 @@
--- a/net/minecraft/server/BlockTurtleEgg.java
+++ b/net/minecraft/server/BlockTurtleEgg.java
-@@ -72,7 +72,7 @@
+@@ -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 @@
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);