Paper/nms-patches/BlockStem.patch

42 lines
2.3 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockStem.java
+++ b/net/minecraft/server/BlockStem.java
2019-04-23 04:00:00 +02:00
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
2020-06-25 02:00:00 +02:00
public static final BlockStateInteger AGE = BlockProperties.ai;
@@ -34,14 +36,18 @@
if (i < 7) {
2018-12-06 00:00:00 +01:00
iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1);
2019-12-10 23:00:00 +01:00
- worldserver.setTypeAndData(blockposition, iblockdata, 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit
} else {
2018-07-15 02:00:00 +02:00
EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
BlockPosition blockposition1 = blockposition.shift(enumdirection);
2020-06-25 02:00:00 +02:00
IBlockData iblockdata1 = worldserver.getType(blockposition1.down());
2020-06-25 02:00:00 +02:00
if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a(Blocks.DIRT) || iblockdata1.a(Blocks.COARSE_DIRT) || iblockdata1.a(Blocks.PODZOL) || iblockdata1.a(Blocks.GRASS_BLOCK))) {
2019-12-10 23:00:00 +01:00
- worldserver.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
+ // CraftBukkit start
2019-12-10 23:00:00 +01:00
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.blockFruit.getBlockData())) {
+ return;
+ }
+ // CraftBukkit end
2019-12-10 23:00:00 +01:00
worldserver.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
}
}
2020-06-25 02:00:00 +02:00
@@ -65,7 +71,7 @@
2019-12-10 23:00:00 +01:00
int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5));
2018-12-06 00:00:00 +01:00
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i);
2019-12-10 23:00:00 +01:00
- worldserver.setTypeAndData(blockposition, iblockdata1, 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2); // CraftBukkit
2018-07-15 02:00:00 +02:00
if (i == 7) {
2020-06-25 02:00:00 +02:00
iblockdata1.b(worldserver, blockposition, worldserver.random);
2018-07-15 02:00:00 +02:00
}