From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 22 Nov 2020 20:13:27 -0600 Subject: [PATCH] Kelp, cave, weeping, and twisting vines configurable max growth age diff --git a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java index 4940e101250874111e9c55aeb5b87b28602246f0..1963831ccef0ea1e2ee519c8b3a53d245c80aa63 100644 --- a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java @@ -88,4 +88,11 @@ public class CaveVinesBlock extends GrowingPlantHeadBlock implements Bonemealabl public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { world.setBlock(pos, (BlockState) state.setValue(CaveVinesBlock.BERRIES, true), 2); } + + // Purpur start + @Override + public int getMaxGrowthAge(ServerLevel world) { + return world.purpurConfig.caveVinesMaxGrowthAge; + } + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java index 4d1e1cf4c541793492a02681087a6242e7977acd..5f4a37d350dc6db2531cf5f9cfe91545cc5cacbb 100644 --- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java @@ -30,7 +30,7 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @Override public BlockState getStateForPlacement(LevelAccessor world) { - return (BlockState) this.defaultBlockState().setValue(GrowingPlantHeadBlock.AGE, world.getRandom().nextInt(25)); + return (BlockState) this.defaultBlockState().setValue(GrowingPlantHeadBlock.AGE, world.getRandom().nextInt(getMaxGrowthAge(world.getMinecraftWorld()))); // Purpur } @Override @@ -38,6 +38,8 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements return (Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25; } + public abstract int getMaxGrowthAge(ServerLevel world); // Purpur + @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { // Paper start @@ -53,7 +55,7 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements } else { modifier = 100; // Above cases are exhaustive as of 1.18 } - if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < (modifier / 100.0D) * this.growPerTickProbability) { // Spigot // Paper - fix growth modifier having the reverse effect + if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < getMaxGrowthAge(world) && random.nextDouble() < (modifier / 100.0D) * this.growPerTickProbability) { // Spigot // Paper - fix growth modifier having the reverse effect // Purpur // Paper end BlockPos blockposition1 = pos.relative(this.growthDirection); @@ -121,13 +123,13 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @Override public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { BlockPos blockposition1 = pos.relative(this.growthDirection); - int i = Math.min((Integer) state.getValue(GrowingPlantHeadBlock.AGE) + 1, 25); + int i = Math.min((Integer) state.getValue(GrowingPlantHeadBlock.AGE) + 1, getMaxGrowthAge(world)); int j = this.getBlocksToGrowWhenBonemealed(random); for (int k = 0; k < j && this.canGrowInto(world.getBlockState(blockposition1)); ++k) { world.setBlockAndUpdate(blockposition1, (BlockState) state.setValue(GrowingPlantHeadBlock.AGE, i)); blockposition1 = blockposition1.relative(this.growthDirection); - i = Math.min(i + 1, 25); + i = Math.min(i + 1, getMaxGrowthAge(world)); } } diff --git a/src/main/java/net/minecraft/world/level/block/KelpBlock.java b/src/main/java/net/minecraft/world/level/block/KelpBlock.java index bc66fa91ec3e13431d5d9b6e17935cab73066be7..6776ca3340f710cea4bf90b610def9e51051cf75 100644 --- a/src/main/java/net/minecraft/world/level/block/KelpBlock.java +++ b/src/main/java/net/minecraft/world/level/block/KelpBlock.java @@ -64,4 +64,11 @@ public class KelpBlock extends GrowingPlantHeadBlock implements LiquidBlockConta public FluidState getFluidState(BlockState state) { return Fluids.WATER.getSource(false); } + + // Purpur start + @Override + public int getMaxGrowthAge(net.minecraft.server.level.ServerLevel world) { + return world.purpurConfig.kelpMaxGrowthAge; + } + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java b/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java index 6866605c7ef5361b21130a19a59c3fa3660dfb19..c3f42d587de584406ebb6a68d9529c0410a6554d 100644 --- a/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java @@ -27,4 +27,11 @@ public class TwistingVinesBlock extends GrowingPlantHeadBlock { protected boolean canGrowInto(BlockState state) { return NetherVines.isValidGrowthState(state); } + + // Purpur start + @Override + public int getMaxGrowthAge(net.minecraft.server.level.ServerLevel world) { + return world.purpurConfig.twistingVinesMaxGrowthAge; + } + // Purpur end } diff --git a/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java b/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java index e5c135ec059746b75fe58516809584221285cdbe..0f4af88d7cd2c2dc69820078de40be544c8263be 100644 --- a/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java @@ -27,4 +27,11 @@ public class WeepingVinesBlock extends GrowingPlantHeadBlock { protected boolean canGrowInto(BlockState state) { return NetherVines.isValidGrowthState(state); } + + // Purpur start + @Override + public int getMaxGrowthAge(net.minecraft.server.level.ServerLevel world) { + return world.purpurConfig.weepingVinesMaxGrowthAge; + } + // Purpur end } diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 407cdadb54eee58a415504c2219829054b40204a..c0c95fdc9b58c6df2c9bf5b43fc132f53336aa00 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -786,6 +786,11 @@ public class PurpurWorldConfig { composterBulkProcess = getBoolean("blocks.composter.sneak-to-bulk-process", composterBulkProcess); } + public int caveVinesMaxGrowthAge = 25; + private void caveVinesSettings() { + caveVinesMaxGrowthAge = getInt("blocks.cave_vines.max-growth-age", caveVinesMaxGrowthAge); + } + public boolean dispenserApplyCursedArmor = true; public boolean dispenserPlaceAnvils = false; private void dispenserSettings() { @@ -880,6 +885,16 @@ public class PurpurWorldConfig { mobsSpawnOnBlueIce = getBoolean("blocks.blue_ice.allow-mob-spawns", mobsSpawnOnBlueIce); } + public int kelpMaxGrowthAge = 25; + private void kelpSettings() { + kelpMaxGrowthAge = getInt("blocks.kelp.max-growth-age", kelpMaxGrowthAge); + if (kelpMaxGrowthAge > 25) { + kelpMaxGrowthAge = 25; + log(Level.WARNING, "blocks.kelp.max-growth-age is set to above maximum allowed value of 25"); + log(Level.WARNING, "Using value of 25 anyway to prevent issues"); + } + } + public boolean lavaInfinite = false; public int lavaInfiniteRequiredSources = 2; public int lavaSpeedNether = 10; @@ -969,6 +984,16 @@ public class PurpurWorldConfig { turtleEggsBypassMobGriefing = getBoolean("blocks.turtle_egg.bypass-mob-griefing", turtleEggsBypassMobGriefing); } + public int twistingVinesMaxGrowthAge = 25; + private void twistingVinesSettings() { + twistingVinesMaxGrowthAge = getInt("blocks.twisting_vines.max-growth-age", twistingVinesMaxGrowthAge); + if (twistingVinesMaxGrowthAge > 25) { + twistingVinesMaxGrowthAge = 25; + log(Level.WARNING, "blocks.twisting_vines.max-growth-age is set to above maximum allowed value of 25"); + log(Level.WARNING, "Using value of 25 anyway to prevent issues"); + } + } + public boolean waterInfinite = true; public int waterInfiniteRequiredSources = 2; private void waterSources() { @@ -976,6 +1001,16 @@ public class PurpurWorldConfig { waterInfiniteRequiredSources = getInt("blocks.water.infinite-required-sources", waterInfiniteRequiredSources); } + public int weepingVinesMaxGrowthAge = 25; + private void weepingVinesSettings() { + weepingVinesMaxGrowthAge = getInt("blocks.weeping_vines.max-growth-age", weepingVinesMaxGrowthAge); + if (weepingVinesMaxGrowthAge > 25) { + weepingVinesMaxGrowthAge = 25; + log(Level.WARNING, "blocks.weeping_vines.max-growth-age is set to above maximum allowed value of 25"); + log(Level.WARNING, "Using value of 25 anyway to prevent issues"); + } + } + public boolean babiesAreRidable = true; public boolean untamedTamablesAreRidable = true; public boolean useNightVisionWhenRiding = false;