Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 039e35b

Browse files
BillyGalbreathgranny
authored andcommitted
Kelp, cave, weeping, and twisting vines configurable max growth age
1 parent 9532ff0 commit 039e35b

7 files changed

Lines changed: 147 additions & 182 deletions

File tree

patches/server/0215-Kelp-cave-weeping-and-twisting-vines-configurable-ma.patch

Lines changed: 0 additions & 182 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/net/minecraft/world/level/block/CaveVinesBlock.java
2+
+++ b/net/minecraft/world/level/block/CaveVinesBlock.java
3+
@@ -92,4 +_,11 @@
4+
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
5+
level.setBlock(pos, state.setValue(BERRIES, Boolean.valueOf(true)), 2);
6+
}
7+
+
8+
+ // Purpur start - cave vines configurable max growth age
9+
+ @Override
10+
+ public int getMaxGrowthAge() {
11+
+ return org.purpurmc.purpur.PurpurConfig.caveVinesMaxGrowthAge;
12+
+ }
13+
+ // Purpur end - cave vines configurable max growth age
14+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
2+
+++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
3+
@@ -34,12 +_,12 @@
4+
5+
@Override
6+
public BlockState getStateForPlacement(RandomSource random) {
7+
- return this.defaultBlockState().setValue(AGE, Integer.valueOf(random.nextInt(25)));
8+
+ return this.defaultBlockState().setValue(AGE, Integer.valueOf(random.nextInt(getMaxGrowthAge()))); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
9+
}
10+
11+
@Override
12+
protected boolean isRandomlyTicking(BlockState state) {
13+
- return state.getValue(AGE) < 25;
14+
+ return state.getValue(AGE) < getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
15+
}
16+
17+
@Override
18+
@@ -55,7 +_,7 @@
19+
} else if (this == Blocks.CAVE_VINES) {
20+
modifier = level.spigotConfig.caveVinesModifier;
21+
}
22+
- if (state.getValue(AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
23+
+ 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
24+
// Spigot end
25+
BlockPos blockPos = pos.relative(this.growthDirection);
26+
if (this.canGrowInto(level.getBlockState(blockPos))) {
27+
@@ -75,11 +_,11 @@
28+
}
29+
30+
public BlockState getMaxAgeState(BlockState state) {
31+
- return state.setValue(AGE, Integer.valueOf(25));
32+
+ return state.setValue(AGE, Integer.valueOf(getMaxGrowthAge())); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
33+
}
34+
35+
public boolean isMaxAge(BlockState state) {
36+
- return state.getValue(AGE) == 25;
37+
+ return state.getValue(AGE) >= getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
38+
}
39+
40+
protected BlockState updateBodyAfterConvertedFromHead(BlockState head, BlockState body) {
41+
@@ -130,13 +_,13 @@
42+
@Override
43+
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
44+
BlockPos blockPos = pos.relative(this.growthDirection);
45+
- int min = Math.min(state.getValue(AGE) + 1, 25);
46+
+ int min = Math.min(state.getValue(AGE) + 1, getMaxGrowthAge()); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
47+
int blocksToGrowWhenBonemealed = this.getBlocksToGrowWhenBonemealed(random);
48+
49+
for (int i = 0; i < blocksToGrowWhenBonemealed && this.canGrowInto(level.getBlockState(blockPos)); i++) {
50+
level.setBlockAndUpdate(blockPos, state.setValue(AGE, Integer.valueOf(min)));
51+
blockPos = blockPos.relative(this.growthDirection);
52+
- min = Math.min(min + 1, 25);
53+
+ min = Math.min(min + 1, getMaxGrowthAge()); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
54+
}
55+
}
56+
57+
@@ -148,4 +_,6 @@
58+
protected GrowingPlantHeadBlock getHeadBlock() {
59+
return this;
60+
}
61+
+
62+
+ public abstract int getMaxGrowthAge(); // Purpur - kelp, cave, weeping, and twisting configurable max growth age
63+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/net/minecraft/world/level/block/KelpBlock.java
2+
+++ b/net/minecraft/world/level/block/KelpBlock.java
3+
@@ -72,4 +_,11 @@
4+
protected FluidState getFluidState(BlockState state) {
5+
return Fluids.WATER.getSource(false);
6+
}
7+
+
8+
+ // Purpur start - kelp vines configurable max growth age
9+
+ @Override
10+
+ public int getMaxGrowthAge() {
11+
+ return org.purpurmc.purpur.PurpurConfig.kelpMaxGrowthAge;
12+
+ }
13+
+ // Purpur end - kelp vines configurable max growth age
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/net/minecraft/world/level/block/TwistingVinesBlock.java
2+
+++ b/net/minecraft/world/level/block/TwistingVinesBlock.java
3+
@@ -34,4 +_,11 @@
4+
protected boolean canGrowInto(BlockState state) {
5+
return NetherVines.isValidGrowthState(state);
6+
}
7+
+
8+
+ // Purpur start - twisting vines configurable max growth age
9+
+ @Override
10+
+ public int getMaxGrowthAge() {
11+
+ return org.purpurmc.purpur.PurpurConfig.twistingVinesMaxGrowthAge;
12+
+ }
13+
+ // Purpur end - twisting vines configurable max growth age
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/net/minecraft/world/level/block/WeepingVinesBlock.java
2+
+++ b/net/minecraft/world/level/block/WeepingVinesBlock.java
3+
@@ -34,4 +_,11 @@
4+
protected boolean canGrowInto(BlockState state) {
5+
return NetherVines.isValidGrowthState(state);
6+
}
7+
+
8+
+ // Purpur start - weeping vines configurable max growth age
9+
+ @Override
10+
+ public int getMaxGrowthAge() {
11+
+ return org.purpurmc.purpur.PurpurConfig.weepingVinesMaxGrowthAge;
12+
+ }
13+
+ // Purpur end - weeping vines configurable max growth age
14+
}

purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ private static void commandSettings() {
307307
public static Set<Enchantment> grindstoneIgnoredEnchants = new HashSet<>();
308308
public static boolean grindstoneRemoveAttributes = false;
309309
public static boolean grindstoneRemoveDisplay = false;
310+
public static int caveVinesMaxGrowthAge = 25;
311+
public static int kelpMaxGrowthAge = 25;
312+
public static int twistingVinesMaxGrowthAge = 25;
313+
public static int weepingVinesMaxGrowthAge = 25;
310314
private static void blockSettings() {
311315
if (version < 3) {
312316
boolean oldValue = getBoolean("settings.barrel.packed-barrels", true);
@@ -356,6 +360,30 @@ private static void blockSettings() {
356360
});
357361
grindstoneRemoveAttributes = getBoolean("settings.blocks.grindstone.remove-attributes", grindstoneRemoveAttributes);
358362
grindstoneRemoveDisplay = getBoolean("settings.blocks.grindstone.remove-name-and-lore", grindstoneRemoveDisplay);
363+
caveVinesMaxGrowthAge = getInt("settings.blocks.cave_vines.max-growth-age", caveVinesMaxGrowthAge);
364+
if (caveVinesMaxGrowthAge > 25) {
365+
caveVinesMaxGrowthAge = 25;
366+
log(Level.WARNING, "blocks.cave_vines.max-growth-age is set to above maximum allowed value of 25");
367+
log(Level.WARNING, "Using value of 25 to prevent issues");
368+
}
369+
kelpMaxGrowthAge = getInt("settings.blocks.kelp.max-growth-age", kelpMaxGrowthAge);
370+
if (kelpMaxGrowthAge > 25) {
371+
kelpMaxGrowthAge = 25;
372+
log(Level.WARNING, "blocks.kelp.max-growth-age is set to above maximum allowed value of 25");
373+
log(Level.WARNING, "Using value of 25 to prevent issues");
374+
}
375+
twistingVinesMaxGrowthAge = getInt("settings.blocks.twisting_vines.max-growth-age", twistingVinesMaxGrowthAge);
376+
if (twistingVinesMaxGrowthAge > 25) {
377+
twistingVinesMaxGrowthAge = 25;
378+
log(Level.WARNING, "blocks.twisting_vines.max-growth-age is set to above maximum allowed value of 25");
379+
log(Level.WARNING, "Using value of 25 to prevent issues");
380+
}
381+
weepingVinesMaxGrowthAge = getInt("settings.blocks.weeping_vines.max-growth-age", weepingVinesMaxGrowthAge);
382+
if (weepingVinesMaxGrowthAge > 25) {
383+
weepingVinesMaxGrowthAge = 25;
384+
log(Level.WARNING, "blocks.weeping_vines.max-growth-age is set to above maximum allowed value of 25");
385+
log(Level.WARNING, "Using value of 25 to prevent issues");
386+
}
359387
}
360388

361389
public static boolean allowInapplicableEnchants = false;

0 commit comments

Comments
 (0)