0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 15:06:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockStem.patch
2023-12-06 03:40:00 +11:00

43 lines
2.4 KiB
Diff

--- a/net/minecraft/world/level/block/BlockStem.java
+++ b/net/minecraft/world/level/block/BlockStem.java
@@ -27,6 +27,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final MapCodec<BlockStem> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -79,7 +81,7 @@
if (i < 7) {
iblockdata = (IBlockData) iblockdata.setValue(BlockStem.AGE, i + 1);
- worldserver.setBlock(blockposition, iblockdata, 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit
} else {
EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.getRandomDirection(randomsource);
BlockPosition blockposition1 = blockposition.relative(enumdirection);
@@ -91,7 +93,11 @@
Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
if (optional.isPresent() && optional1.isPresent()) {
- worldserver.setBlockAndUpdate(blockposition1, ((Block) optional.get()).defaultBlockState());
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, ((Block) optional.get()).defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setBlockAndUpdate(blockposition, (IBlockData) ((Block) optional1.get()).defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection));
}
}
@@ -121,7 +127,7 @@
int i = Math.min(7, (Integer) iblockdata.getValue(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5));
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockStem.AGE, i);
- worldserver.setBlock(blockposition, iblockdata1, 2);
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2); // CraftBukkit
if (i == 7) {
iblockdata1.randomTick(worldserver, blockposition, worldserver.random);
}