From 097b7fd7527ee9e7b75227a5f0b20b652e3e0c64 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Tue, 1 Mar 2016 13:02:51 -0600 Subject: [PATCH] Configurable cactus bamboo and reed growth height Bamboo - Both the minimum fully-grown height and the maximum are configurable - Machine_Maker --- .../level/block/BambooStalkBlock.java.patch | 42 ++++++++++++++++--- .../world/level/block/CactusBlock.java.patch | 8 +++- .../level/block/SugarCaneBlock.java.patch | 8 +++- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch index 36b85ce839..eb12b201ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -134,7 +134,7 @@ +@@ -134,10 +134,10 @@ @Override protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if ((Integer) state.getValue(BambooStalkBlock.STAGE) == 0) { @@ -8,13 +8,26 @@ + if (random.nextFloat() < (world.spigotConfig.bambooModifier / (100.0f * 3)) && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution int i = this.getHeightBelowUpToMax(world, pos) + 1; - if (i < 16) { +- if (i < 16) { ++ if (i < world.paperConfig().maxGrowthHeight.bamboo.max) { // Paper - Configurable cactus/bamboo/reed growth height + this.growBamboo(state, world, pos, random, i); + } + } +@@ -164,7 +164,7 @@ + int i = this.getHeightAboveUpToMax(world, pos); + int j = this.getHeightBelowUpToMax(world, pos); + +- return i + j + 1 < 16 && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1; ++ return i + j + 1 < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1; // Paper - Configurable cactus/bamboo/reed growth height + } + + @Override @@ -183,7 +183,7 @@ BlockPos blockposition1 = pos.above(i); BlockState iblockdata1 = world.getBlockState(blockposition1); - if (k >= 16 || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { -+ if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here ++ if (k >= world.paperConfig().maxGrowthHeight.bamboo.max || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here // Paper - Configurable cactus/bamboo/reed growth height return; } @@ -39,9 +52,12 @@ } } } else { -@@ -222,7 +226,14 @@ +@@ -220,15 +224,22 @@ + } + int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; - int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1; +- int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1; ++ int k = (height < world.paperConfig().maxGrowthHeight.bamboo.min || random.nextFloat() >= 0.25F) && height != (world.paperConfig().maxGrowthHeight.bamboo.max - 1) ? 0 : 1; // Paper - Configurable cactus/bamboo/reed growth height - world.setBlock(pos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3); + // CraftBukkit start @@ -55,3 +71,19 @@ } protected int getHeightAboveUpToMax(BlockGetter world, BlockPos pos) { + int i; + +- for (i = 0; i < 16 && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) { ++ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper - Configurable cactus/bamboo/reed growth height + ; + } + +@@ -238,7 +249,7 @@ + protected int getHeightBelowUpToMax(BlockGetter world, BlockPos pos) { + int i; + +- for (i = 0; i < 16 && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) { ++ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper - Configurable cactus/bamboo/reed growth height + ; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch index f5a12c0dcb..2b35adad86 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch @@ -8,8 +8,12 @@ public class CactusBlock extends Block { -@@ -64,13 +65,14 @@ - if (i < 3) { +@@ -61,16 +62,17 @@ + ; + } + +- if (i < 3) { ++ if (i < world.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height int j = (Integer) state.getValue(CactusBlock.AGE); - if (j == 15) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch index ec6ff2f591..903b77b2e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -1,7 +1,11 @@ --- a/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/net/minecraft/world/level/block/SugarCaneBlock.java -@@ -62,10 +62,11 @@ - if (i < 3) { +@@ -59,13 +59,14 @@ + ; + } + +- if (i < 3) { ++ if (i < world.paperConfig().maxGrowthHeight.reeds) { // Paper - Configurable cactus/bamboo/reed growth heigh int j = (Integer) state.getValue(SugarCaneBlock.AGE); - if (j == 15) {