From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
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/CaveVinesBlock.java b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
index f63e79ff0df4b4f152f74e55134dc72932e6ae55..905ef84a959833c38898670126e0ac08da8d4ca2 100644
--- a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
@@ -85,5 +85,9 @@ public class CaveVinesBlock extends GrowingPlantHeadBlock implements Bonemealabl
     public double getGrowthModifier(net.minecraft.server.level.ServerLevel world) {
         return world.purpurConfig.caveVinesGrowthModifier;
     }
+
+    public int getMaxGrowthAge(net.minecraft.server.level.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 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 7d5493fea2b7cfb26221e8592c7c3ef9cb65d05d..7afbb2fb08fa651a11da52582f2b50188e24d086 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -419,8 +419,10 @@ public class PurpurWorldConfig {
     }
 
     public double caveVinesGrowthModifier = 0.10D;
+    public int caveVinesMaxGrowthAge = 25;
     private void caveVinesSettings() {
         caveVinesGrowthModifier = getDouble("blocks.cave_vines.growth-modifier", caveVinesGrowthModifier);
+        caveVinesMaxGrowthAge = getInt("blocks.cave_vines.max-growth-age", caveVinesMaxGrowthAge);
     }
 
     public boolean dispenserApplyCursedArmor = true;
@@ -459,6 +461,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;
@@ -493,13 +500,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;
