PaperMC/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch
CraftBukkit/Spigot 25f3b50f6b Update to Minecraft 1.19
By: md_5 <git@md-5.net>
2022-06-08 02:00:00 +10:00

41 lines
2.3 KiB
Diff

--- a/net/minecraft/world/level/block/BlockStem.java
+++ b/net/minecraft/world/level/block/BlockStem.java
@@ -20,6 +20,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 int MAX_AGE = 7;
@@ -56,14 +58,18 @@
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);
IBlockData iblockdata1 = worldserver.getBlockState(blockposition1.below());
if (worldserver.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(TagsBlock.DIRT))) {
- worldserver.setBlockAndUpdate(blockposition1, this.fruit.defaultBlockState());
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
worldserver.setBlockAndUpdate(blockposition, (IBlockData) this.fruit.getAttachedStem().defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection));
}
}
@@ -92,7 +98,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);
}