SPIGOT-4099: Missing BlockFormEvent for concrete powder

This commit is contained in:
md_5 2018-07-21 10:03:08 +10:00
parent 889e17f99d
commit a8dc8d31d3

View file

@ -11,18 +11,42 @@
public class BlockConcretePowder extends BlockFalling { public class BlockConcretePowder extends BlockFalling {
private final IBlockData a; private final IBlockData a;
@@ -10,8 +15,8 @@ @@ -11,7 +16,7 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) { public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {
- if (iblockdata1.getMaterial().isLiquid()) { if (iblockdata1.getMaterial().isLiquid()) {
- world.setTypeAndData(blockposition, this.a, 3); - world.setTypeAndData(blockposition, this.a, 3);
+ if (iblockdata1.getMaterial().isLiquid() && !(world.getType(blockposition).getBlock() instanceof BlockConcretePowder)) { // CraftBukkit - don't double concrete + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3);
} }
} }
@@ -45,6 +50,20 @@ @@ -20,7 +25,24 @@
World world = blockactioncontext.getWorld();
BlockPosition blockposition = blockactioncontext.getClickPosition();
- return !blockactioncontext.getWorld().getType(blockactioncontext.getClickPosition()).getMaterial().isLiquid() && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a;
+ // CraftBukkit start
+ if (!blockactioncontext.getWorld().getType(blockactioncontext.getClickPosition()).getMaterial().isLiquid() && !a((IBlockAccess) world, blockposition)) {
+ return super.getPlacedState(blockactioncontext);
+ }
+
+ // TODO: An event factory call for methods like this
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
+ blockState.setData(this.a);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
+ world.getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ return blockState.getHandle();
+ }
+
+ return super.getPlacedState(blockactioncontext);
+ // CraftBukkit end
}
private static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) {
@@ -45,6 +67,20 @@
} }
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {