2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockGrass.java
|
|
|
|
+++ b/net/minecraft/server/BlockGrass.java
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -3,6 +3,14 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.Random;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// 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");
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -23,7 +31,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!world.isClientSide) {
|
2016-02-29 22:32:46 +01:00
|
|
|
if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- 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) {
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -37,7 +57,19 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
IBlockData iblockdata2 = world.getType(blockposition1);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (iblockdata2.getBlock() == Blocks.DIRT && iblockdata2.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata1.c() <= 2) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -81,13 +113,15 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
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 {
|
2015-02-26 23:41:06 +01:00
|
|
|
IBlockData iblockdata2 = Blocks.TALLGRASS.getBlockData().set(BlockLongGrass.TYPE, BlockLongGrass.EnumTallGrassType.GRASS);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) {
|
|
|
|
- world.setTypeAndData(blockposition2, iblockdata2, 3);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // world.setTypeAndData(blockposition2, iblockdata2, 3); // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata2.getBlock(), iblockdata2.getBlock().toLegacyData(iblockdata2)); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|