Kelp, cave, weeping, and twisting vines configurable max growth age

This commit is contained in:
William Blake Galbreath
2025-01-12 13:41:14 -08:00
committed by granny
parent 9532ff01ee
commit 039e35b681
7 changed files with 147 additions and 182 deletions

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/level/block/CaveVinesBlock.java
+++ b/net/minecraft/world/level/block/CaveVinesBlock.java
@@ -92,4 +_,11 @@
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
level.setBlock(pos, state.setValue(BERRIES, Boolean.valueOf(true)), 2);
}
+
+ // Purpur start - cave vines configurable max growth age
+ @Override
+ public int getMaxGrowthAge() {
+ return org.purpurmc.purpur.PurpurConfig.caveVinesMaxGrowthAge;
+ }
+ // Purpur end - cave vines configurable max growth age
}

View File

@@ -0,0 +1,63 @@
--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
+++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
@@ -34,12 +_,12 @@
@Override
public BlockState getStateForPlacement(RandomSource random) {
- return this.defaultBlockState().setValue(AGE, Integer.valueOf(random.nextInt(25)));
+ return this.defaultBlockState().setValue(AGE, Integer.valueOf(random.nextInt(getMaxGrowthAge()))); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}
@Override
protected boolean isRandomlyTicking(BlockState state) {
- return state.getValue(AGE) < 25;
+ return state.getValue(AGE) < getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}
@Override
@@ -55,7 +_,7 @@
} else if (this == Blocks.CAVE_VINES) {
modifier = level.spigotConfig.caveVinesModifier;
}
- if (state.getValue(AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
+ if (state.getValue(AGE) < getMaxGrowthAge() && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution // Purpur - kelp, cave, weeping, and twisting configurable max growth age
// Spigot end
BlockPos blockPos = pos.relative(this.growthDirection);
if (this.canGrowInto(level.getBlockState(blockPos))) {
@@ -75,11 +_,11 @@
}
public BlockState getMaxAgeState(BlockState state) {
- return state.setValue(AGE, Integer.valueOf(25));
+ return state.setValue(AGE, Integer.valueOf(getMaxGrowthAge())); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}
public boolean isMaxAge(BlockState state) {
- return state.getValue(AGE) == 25;
+ return state.getValue(AGE) >= getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}
protected BlockState updateBodyAfterConvertedFromHead(BlockState head, BlockState body) {
@@ -130,13 +_,13 @@
@Override
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
BlockPos blockPos = pos.relative(this.growthDirection);
- int min = Math.min(state.getValue(AGE) + 1, 25);
+ int min = Math.min(state.getValue(AGE) + 1, getMaxGrowthAge()); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
int blocksToGrowWhenBonemealed = this.getBlocksToGrowWhenBonemealed(random);
for (int i = 0; i < blocksToGrowWhenBonemealed && this.canGrowInto(level.getBlockState(blockPos)); i++) {
level.setBlockAndUpdate(blockPos, state.setValue(AGE, Integer.valueOf(min)));
blockPos = blockPos.relative(this.growthDirection);
- min = Math.min(min + 1, 25);
+ min = Math.min(min + 1, getMaxGrowthAge()); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}
}
@@ -148,4 +_,6 @@
protected GrowingPlantHeadBlock getHeadBlock() {
return this;
}
+
+ public abstract int getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
}

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/level/block/KelpBlock.java
+++ b/net/minecraft/world/level/block/KelpBlock.java
@@ -72,4 +_,11 @@
protected FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false);
}
+
+ // Purpur start - kelp vines configurable max growth age
+ @Override
+ public int getMaxGrowthAge() {
+ return org.purpurmc.purpur.PurpurConfig.kelpMaxGrowthAge;
+ }
+ // Purpur end - kelp vines configurable max growth age
}

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/level/block/TwistingVinesBlock.java
+++ b/net/minecraft/world/level/block/TwistingVinesBlock.java
@@ -34,4 +_,11 @@
protected boolean canGrowInto(BlockState state) {
return NetherVines.isValidGrowthState(state);
}
+
+ // Purpur start - twisting vines configurable max growth age
+ @Override
+ public int getMaxGrowthAge() {
+ return org.purpurmc.purpur.PurpurConfig.twistingVinesMaxGrowthAge;
+ }
+ // Purpur end - twisting vines configurable max growth age
}

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/level/block/WeepingVinesBlock.java
+++ b/net/minecraft/world/level/block/WeepingVinesBlock.java
@@ -34,4 +_,11 @@
protected boolean canGrowInto(BlockState state) {
return NetherVines.isValidGrowthState(state);
}
+
+ // Purpur start - weeping vines configurable max growth age
+ @Override
+ public int getMaxGrowthAge() {
+ return org.purpurmc.purpur.PurpurConfig.weepingVinesMaxGrowthAge;
+ }
+ // Purpur end - weeping vines configurable max growth age
}

View File

@@ -307,6 +307,10 @@ public class PurpurConfig {
public static Set<Enchantment> grindstoneIgnoredEnchants = new HashSet<>();
public static boolean grindstoneRemoveAttributes = false;
public static boolean grindstoneRemoveDisplay = false;
public static int caveVinesMaxGrowthAge = 25;
public static int kelpMaxGrowthAge = 25;
public static int twistingVinesMaxGrowthAge = 25;
public static int weepingVinesMaxGrowthAge = 25;
private static void blockSettings() {
if (version < 3) {
boolean oldValue = getBoolean("settings.barrel.packed-barrels", true);
@@ -356,6 +360,30 @@ public class PurpurConfig {
});
grindstoneRemoveAttributes = getBoolean("settings.blocks.grindstone.remove-attributes", grindstoneRemoveAttributes);
grindstoneRemoveDisplay = getBoolean("settings.blocks.grindstone.remove-name-and-lore", grindstoneRemoveDisplay);
caveVinesMaxGrowthAge = getInt("settings.blocks.cave_vines.max-growth-age", caveVinesMaxGrowthAge);
if (caveVinesMaxGrowthAge > 25) {
caveVinesMaxGrowthAge = 25;
log(Level.WARNING, "blocks.cave_vines.max-growth-age is set to above maximum allowed value of 25");
log(Level.WARNING, "Using value of 25 to prevent issues");
}
kelpMaxGrowthAge = getInt("settings.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 to prevent issues");
}
twistingVinesMaxGrowthAge = getInt("settings.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 to prevent issues");
}
weepingVinesMaxGrowthAge = getInt("settings.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 to prevent issues");
}
}
public static boolean allowInapplicableEnchants = false;