mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
SPIGOT-3215: Call BlockPhysicsEvent for tall plants
By: BlackHole <black-hole@live.com>
This commit is contained in:
parent
de05a02353
commit
8803cfc46a
3 changed files with 24 additions and 18 deletions
|
@ -1,26 +1,11 @@
|
||||||
--- a/net/minecraft/server/BlockPlant.java
|
--- a/net/minecraft/server/BlockPlant.java
|
||||||
+++ b/net/minecraft/server/BlockPlant.java
|
+++ b/net/minecraft/server/BlockPlant.java
|
||||||
@@ -2,6 +2,10 @@
|
@@ -40,6 +40,11 @@
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+// CraftBukkit start
|
|
||||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
||||||
+import org.bukkit.event.block.BlockPhysicsEvent;
|
|
||||||
+// CraftBukkit end
|
|
||||||
|
|
||||||
public class BlockPlant extends Block {
|
|
||||||
|
|
||||||
@@ -40,6 +44,15 @@
|
|
||||||
|
|
||||||
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||||
if (!this.f(world, blockposition, iblockdata)) {
|
if (!this.f(world, blockposition, iblockdata)) {
|
||||||
+ // CraftBukkit Start
|
+ // CraftBukkit start
|
||||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
|
||||||
+ BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
|
|
||||||
+ world.getServer().getPluginManager().callEvent(event);
|
|
||||||
+
|
|
||||||
+ if (event.isCancelled()) {
|
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
14
paper-server/nms-patches/BlockTallPlant.patch
Normal file
14
paper-server/nms-patches/BlockTallPlant.patch
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
--- a/net/minecraft/server/BlockTallPlant.java
|
||||||
|
+++ b/net/minecraft/server/BlockTallPlant.java
|
||||||
|
@@ -48,6 +48,11 @@
|
||||||
|
|
||||||
|
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||||
|
if (!this.f(world, blockposition, iblockdata)) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
boolean flag = iblockdata.get(BlockTallPlant.HALF) == BlockTallPlant.EnumTallPlantHalf.UPPER;
|
||||||
|
BlockPosition blockposition1 = flag ? blockposition : blockposition.up();
|
||||||
|
BlockPosition blockposition2 = flag ? blockposition.down() : blockposition;
|
|
@ -1039,6 +1039,13 @@ public class CraftEventFactory {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockPhysicsEvent callBlockPhysicsEvent(World world, BlockPosition blockposition) {
|
||||||
|
org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||||
|
BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean handleBlockFormEvent(World world, BlockPosition pos, net.minecraft.server.Block block, @Nullable Entity entity) {
|
public static boolean handleBlockFormEvent(World world, BlockPosition pos, net.minecraft.server.Block block, @Nullable Entity entity) {
|
||||||
BlockState blockState = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState();
|
BlockState blockState = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState();
|
||||||
blockState.setType(CraftMagicNumbers.getMaterial(block));
|
blockState.setType(CraftMagicNumbers.getMaterial(block));
|
||||||
|
|
Loading…
Reference in a new issue