From 701b06494ddf4a807788f159fe5aa7e63dff7a42 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 3 Jun 2017 17:39:03 +1000 Subject: [PATCH] SPIGOT-3286: Call BlockFormEvent for Concrete Powder -> Concrete --- nms-patches/BlockConcretePowder.patch | 22 +++++++++++++++++++ nms-patches/BlockFlowing.patch | 2 +- nms-patches/BlockFluids.patch | 4 ++-- nms-patches/EnchantmentFrostWalker.patch | 2 +- nms-patches/EntitySnowman.patch | 2 +- nms-patches/WorldServer.patch | 4 ++-- .../craftbukkit/event/CraftEventFactory.java | 5 +++-- 7 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 nms-patches/BlockConcretePowder.patch diff --git a/nms-patches/BlockConcretePowder.patch b/nms-patches/BlockConcretePowder.patch new file mode 100644 index 0000000000..dd2708f7a3 --- /dev/null +++ b/nms-patches/BlockConcretePowder.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/server/BlockConcretePowder.java ++++ b/net/minecraft/server/BlockConcretePowder.java +@@ -11,8 +11,8 @@ + } + + public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) { +- if (iblockdata1.getMaterial().isLiquid()) { +- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3); ++ if (iblockdata1.getMaterial().isLiquid() && world.getType(blockposition).getBlock() != Blocks.dR) { // CraftBukkit - don't double concrete ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit + } + + } +@@ -36,7 +36,7 @@ + } + + if (flag) { +- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit + } + + return flag; diff --git a/nms-patches/BlockFlowing.patch b/nms-patches/BlockFlowing.patch index d6253aff88..55906695fe 100644 --- a/nms-patches/BlockFlowing.patch +++ b/nms-patches/BlockFlowing.patch @@ -33,7 +33,7 @@ - world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData()); - this.fizz(world, blockposition.down()); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE, null)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE.getBlockData(), null)) { + this.fizz(world, blockposition.down()); + } + // CraftBukkit end diff --git a/nms-patches/BlockFluids.patch b/nms-patches/BlockFluids.patch index 8708adc585..cccec39459 100644 --- a/nms-patches/BlockFluids.patch +++ b/nms-patches/BlockFluids.patch @@ -7,7 +7,7 @@ - world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN, null)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData(), null)) { + this.fizz(world, blockposition); + } + // CraftBukkit end @@ -18,7 +18,7 @@ - world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE, null)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData(), null)) { + this.fizz(world, blockposition); + } + // CraftBukkit end diff --git a/nms-patches/EnchantmentFrostWalker.patch b/nms-patches/EnchantmentFrostWalker.patch index fedf1a39b2..c4f9f2b8db 100644 --- a/nms-patches/EnchantmentFrostWalker.patch +++ b/nms-patches/EnchantmentFrostWalker.patch @@ -16,7 +16,7 @@ - world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData()); - world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, Blocks.FROSTED_ICE, entityliving)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData(), entityliving)) { + world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + } + // CraftBukkit End diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch index 244f48b184..029613e448 100644 --- a/nms-patches/EntitySnowman.patch +++ b/nms-patches/EntitySnowman.patch @@ -26,7 +26,7 @@ if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) { - this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER, this); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER.getBlockData(), this); // CraftBukkit } } } diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 0939b13952..a5a556f000 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -284,12 +284,12 @@ if (this.v(blockposition1)) { - this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE, null); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit } if (flag && this.f(blockposition, true)) { - this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW_LAYER, null); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW_LAYER.getBlockData(), null); // CraftBukkit } if (flag && this.getBiome(blockposition1).d()) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 1c0dc7d6b4..be0f46f925 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1041,9 +1041,10 @@ public class CraftEventFactory { 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, IBlockData block, @Nullable Entity entity) { BlockState blockState = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(block)); + blockState.setType(CraftMagicNumbers.getMaterial(block.getBlock())); + blockState.setRawData((byte) block.getBlock().toLegacyData(block)); BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState); world.getServer().getPluginManager().callEvent(event);