summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockGrass.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches/BlockGrass.patch')
-rw-r--r--nms-patches/BlockGrass.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch
new file mode 100644
index 00000000..b52f01fd
--- /dev/null
+++ b/nms-patches/BlockGrass.patch
@@ -0,0 +1,77 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/BlockGrass.java 2014-11-27 08:59:46.533422586 +1100
++++ src/main/java/net/minecraft/server/BlockGrass.java 2014-11-27 08:42:10.172850872 +1100
+@@ -2,6 +2,14 @@
+
+ import java.util.Random;
+
++// CraftBukkit start
++import org.bukkit.block.BlockState;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.craftbukkit.util.CraftMagicNumbers;
++import org.bukkit.event.block.BlockSpreadEvent;
++import org.bukkit.event.block.BlockFadeEvent;
++// CraftBukkit end
++
+ public class BlockGrass extends Block implements IBlockFragilePlantElement {
+
+ public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
+@@ -22,7 +30,19 @@
+ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ if (!world.isStatic) {
+ if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).getBlock().n() > 2) {
+- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
++ // CraftBukkit start
++ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
++ org.bukkit.World bworld = world.getWorld();
++ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
++ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
++
++ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
++ world.getServer().getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ blockState.update(true);
++ }
++ // CraftBukkit end
+ } else {
+ if (world.getLightLevel(blockposition.up()) >= 9) {
+ for (int i = 0; i < 4; ++i) {
+@@ -31,7 +51,19 @@
+ IBlockData iblockdata1 = world.getType(blockposition1);
+
+ if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.n() <= 2) {
+- world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
++ // CraftBukkit start
++ // world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
++ org.bukkit.World bworld = world.getWorld();
++ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
++ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.GRASS));
++
++ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
++ world.getServer().getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ blockState.update(true);
++ }
++ // CraftBukkit end
+ }
+ }
+ }
+@@ -74,13 +106,15 @@
+ IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.l(), enumflowervarient);
+
+ if (blockflowers.f(world, blockposition2, iblockdata1)) {
+- world.setTypeAndData(blockposition2, iblockdata1, 3);
++ // world.setTypeAndData(blockposition2, iblockdata1, 3); // CraftBukkit
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata1.getBlock(), iblockdata1.getBlock().toLegacyData(iblockdata1)); // CraftBukkit
+ }
+ } else {
+ IBlockData iblockdata2 = Blocks.TALLGRASS.getBlockData().set(BlockLongGrass.TYPE, EnumTallGrassType.GRASS);
+
+ if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) {
+- world.setTypeAndData(blockposition2, iblockdata2, 3);
++ // world.setTypeAndData(blockposition2, iblockdata2, 3); // CRaftBukkit
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata2.getBlock(), iblockdata2.getBlock().toLegacyData(iblockdata2)); // CraftBukkit
+ }
+ }
+ }