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 weeping and twisting vines configurable max growth age 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 9f1d43ad720750f9d50cc3cfbe1fc9b335cffd0d..1c3284f8bf7923361797a73077af0699fa58db29 100644 --- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java @@ -31,7 +31,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 @@ -41,9 +41,11 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements public abstract double getGrowthModifier(ServerLevel world); // Purpur + public abstract int getMaxGrowthAge(ServerLevel world); // Purpur + @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { - if (state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < (100.0D / this.getGrowthModifier(world)) * this.growPerTickProbability) { // Spigot // Purpur + if (state.getValue(GrowingPlantHeadBlock.AGE) < getMaxGrowthAge(world) && random.nextDouble() < (100.0D / this.getGrowthModifier(world)) * this.growPerTickProbability) { // Spigot // Purpur BlockPos blockposition1 = pos.relative(this.growthDirection); if (this.canGrowInto(world.getBlockState(blockposition1))) { @@ -96,13 +98,13 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @Override public void performBonemeal(ServerLevel world, Random 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)); // Purpur 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)); // Purpur } } 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 5f9a8dd6b4f7c9285ffcce8bbe0e334a28cc9699..486a62617b594b66341fb9ef2f88c3f328cb943d 100644 --- a/src/main/java/net/minecraft/world/level/block/KelpBlock.java +++ b/src/main/java/net/minecraft/world/level/block/KelpBlock.java @@ -69,5 +69,9 @@ public class KelpBlock extends GrowingPlantHeadBlock implements LiquidBlockConta public double getGrowthModifier(net.minecraft.server.level.ServerLevel world) { return world.spigotConfig.kelpModifier; } + + 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 c877f7e4e55c63d91ce58c15850e279be3e159a7..c8ca3b9da2df89540a80c08042ca9aee28f274ea 100644 --- a/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TwistingVinesBlock.java @@ -32,5 +32,9 @@ public class TwistingVinesBlock extends GrowingPlantHeadBlock { public double getGrowthModifier(net.minecraft.server.level.ServerLevel world) { return world.purpurConfig.twistingVinesGrowthModifier; } + + 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 d2cb1a7e7ea364cb8e2af4c4e756d8e45bc0ca10..bb99dda3c5167f23b2500a1f37cbc1ca285f123a 100644 --- a/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WeepingVinesBlock.java @@ -32,5 +32,9 @@ public class WeepingVinesBlock extends GrowingPlantHeadBlock { public double getGrowthModifier(net.minecraft.server.level.ServerLevel world) { return world.purpurConfig.weepingVinesGrowthModifier; } + + public int getMaxGrowthAge(net.minecraft.server.level.ServerLevel world) { + return world.purpurConfig.weepingVinesMaxGrowthAge; + } // Purpur end } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 6168b3c2a8d700653f181f692e7011a611b2f82b..af5d052ad3f5948ed198091964006dc33de09d78 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -424,6 +424,11 @@ public class PurpurWorldConfig { lavaSpeedNotNether = getInt("blocks.lava.speed.not-nether", lavaSpeedNotNether); } + public int kelpMaxGrowthAge = 25; + private void kelpSettings() { + kelpMaxGrowthAge = getInt("blocks.kelp.max-growth-age", kelpMaxGrowthAge); + } + public boolean respawnAnchorExplode = true; public double respawnAnchorExplosionPower = 5.0D; public boolean respawnAnchorExplosionFire = true; @@ -458,13 +463,17 @@ public class PurpurWorldConfig { } public double twistingVinesGrowthModifier = 0.10D; + public int twistingVinesMaxGrowthAge = 25; private void twistingVinesSettings() { twistingVinesGrowthModifier = getDouble("blocks.twisting_vines.growth-modifier", twistingVinesGrowthModifier); + twistingVinesMaxGrowthAge = getInt("blocks.twisting_vines.max-growth-age", twistingVinesMaxGrowthAge); } public double weepingVinesGrowthModifier = 0.10D; + public int weepingVinesMaxGrowthAge = 25; private void weepingVinesSettings() { weepingVinesGrowthModifier = getDouble("blocks.weeping_vines.growth-modifier", weepingVinesGrowthModifier); + weepingVinesMaxGrowthAge = getInt("blocks.weeping_vines.max-growth-age", weepingVinesMaxGrowthAge); } public boolean babiesAreRidable = true;