PaperMC/nms-patches/BlockMycel.patch

59 lines
3.1 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockMycel.java
+++ b/net/minecraft/server/BlockMycel.java
2016-11-17 02:41:03 +01:00
@@ -2,6 +2,13 @@
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockMycel extends Block {
public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
2016-11-17 02:41:03 +01:00
@@ -22,7 +29,19 @@
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) {
2015-02-26 23:41:06 +01:00
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
+ // CraftBukkit start
2016-02-29 22:32:46 +01:00
+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
+ 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-11-17 02:41:03 +01:00
@@ -31,7 +50,19 @@
2016-02-29 22:32:46 +01:00
IBlockData iblockdata2 = world.getType(blockposition1.up());
2016-02-29 22:32:46 +01:00
if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata2.c() <= 2) {
- world.setTypeUpdate(blockposition1, this.getBlockData());
+ // CraftBukkit start
+ // world.setTypeUpdate(blockposition1, this.getBlockData());
+ org.bukkit.World bworld = world.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(this));
+
+ 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
}
}
}