0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 08:56:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch
2024-10-23 02:15:00 +11:00

49 lines
3.5 KiB
Diff

--- a/net/minecraft/world/level/block/BlockBamboo.java
+++ b/net/minecraft/world/level/block/BlockBamboo.java
@@ -183,7 +183,7 @@
BlockPosition blockposition1 = blockposition.above(i);
IBlockData iblockdata1 = worldserver.getBlockState(blockposition1);
- if (k >= 16 || (Integer) iblockdata1.getValue(BlockBamboo.STAGE) == 1 || !worldserver.isEmptyBlock(blockposition1.above())) {
+ if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BlockBamboo.STAGE) == 1 || !worldserver.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here
return;
}
@@ -204,14 +204,18 @@
BlockPosition blockposition1 = blockposition.below(2);
IBlockData iblockdata2 = world.getBlockState(blockposition1);
BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE;
+ boolean shouldUpdateOthers = false; // CraftBukkit
if (i >= 1) {
if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) {
if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) {
blockpropertybamboosize = BlockPropertyBambooSize.LARGE;
if (iblockdata2.is(Blocks.BAMBOO)) {
- world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
- world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
+ // CraftBukkit start - moved down
+ // world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
+ // world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
+ shouldUpdateOthers = true;
+ // CraftBukkit end
}
}
} else {
@@ -222,7 +226,14 @@
int j = (Integer) iblockdata.getValue(BlockBamboo.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1;
int k = (i < 11 || randomsource.nextFloat() >= 0.25F) && i != 15 ? 0 : 1;
- world.setBlock(blockposition.above(), (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(BlockBamboo.AGE, j)).setValue(BlockBamboo.LEAVES, blockpropertybamboosize)).setValue(BlockBamboo.STAGE, k), 3);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.above(), (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(BlockBamboo.AGE, j)).setValue(BlockBamboo.LEAVES, blockpropertybamboosize)).setValue(BlockBamboo.STAGE, k), 3)) {
+ if (shouldUpdateOthers) {
+ world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
+ world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
+ }
+ }
+ // CraftBukkit end
}
protected int getHeightAboveUpToMax(IBlockAccess iblockaccess, BlockPosition blockposition) {