mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 12:36:07 +01:00
SPIGOT-4279: Move turtle egg interact event
This commit is contained in:
parent
7c341e9beb
commit
1728eb298e
@ -1,38 +1,38 @@
|
|||||||
--- a/net/minecraft/server/BlockTurtleEgg.java
|
--- a/net/minecraft/server/BlockTurtleEgg.java
|
||||||
+++ b/net/minecraft/server/BlockTurtleEgg.java
|
+++ b/net/minecraft/server/BlockTurtleEgg.java
|
||||||
@@ -3,6 +3,11 @@
|
@@ -2,6 +2,12 @@
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
|
+
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
|
||||||
public class BlockTurtleEgg extends Block {
|
public class BlockTurtleEgg extends Block {
|
||||||
|
|
||||||
private static final VoxelShape c = Block.a(3.0D, 0.0D, 3.0D, 12.0D, 7.0D, 12.0D);
|
@@ -35,6 +41,19 @@
|
||||||
@@ -34,6 +39,20 @@
|
|
||||||
if (entity instanceof EntityTurtle) {
|
|
||||||
super.stepOn(world, blockposition, entity);
|
super.stepOn(world, blockposition, entity);
|
||||||
} else {
|
} 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) {
|
if (!world.isClientSide && world.random.nextInt(i) == 0) {
|
||||||
|
+ // 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
|
||||||
this.a(world, blockposition, iblockdata);
|
this.a(world, blockposition, iblockdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +91,7 @@
|
@@ -72,7 +91,7 @@
|
||||||
entityturtle.setAgeRaw(-24000);
|
entityturtle.setAgeRaw(-24000);
|
||||||
entityturtle.g(blockposition);
|
entityturtle.g(blockposition);
|
||||||
|
Loading…
Reference in New Issue
Block a user