9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-24 01:19:30 +00:00

Add option to change crops to go from first age to last age directly, to avoid useless block updates

This commit is contained in:
MrPowerGamerBR
2023-11-21 16:14:45 -03:00
parent d80994bccc
commit 96c5de6f94
3 changed files with 21 additions and 12 deletions

View File

@@ -225,10 +225,10 @@ index 0000000000000000000000000000000000000000..6398c7b40ba82ffc8588eca458ce92c2
\ No newline at end of file
diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
new file mode 100644
index 0000000000000000000000000000000000000000..250b19027db75b1ba44383621215fd2c3370c967
index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b91874ba8e
--- /dev/null
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
@@ -0,0 +1,55 @@
@@ -0,0 +1,56 @@
+package net.sparklypower.sparklypaper.configs
+
+import com.charleskorn.kaml.Yaml
@@ -257,9 +257,10 @@ index 0000000000000000000000000000000000000000..250b19027db75b1ba44383621215fd2c
+ "default" to SparklyPaperWorldConfig(
+ skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer = true,
+ blazinglySimpleFarmChecks = SparklyPaperWorldConfig.BlazinglySimpleFarmChecks(
+ false,
+ 1.0f,
+ 5.0f,
+ enabled = false,
+ defaultGrowthSpeed = 1.0f,
+ moistGrowthSpeed = 5.0f,
+ skipMiddleAgingStagesForCrops = true
+ ),
+ SparklyPaperWorldConfig.TickRates(
+ farmWhenMoisturised = 1
@@ -287,10 +288,10 @@ index 0000000000000000000000000000000000000000..250b19027db75b1ba44383621215fd2c
\ No newline at end of file
diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt
new file mode 100644
index 0000000000000000000000000000000000000000..41f2482097d7b835dcec85bb33ab0ce5f6f48eec
index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe54458015bfe8
--- /dev/null
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt
@@ -0,0 +1,29 @@
@@ -0,0 +1,31 @@
+package net.sparklypower.sparklypaper.configs
+
+import kotlinx.serialization.SerialName
@@ -311,7 +312,9 @@ index 0000000000000000000000000000000000000000..41f2482097d7b835dcec85bb33ab0ce5
+ @SerialName("default-growth-speed")
+ val defaultGrowthSpeed: Float,
+ @SerialName("moist-growth-speed")
+ val moistGrowthSpeed: Float
+ val moistGrowthSpeed: Float,
+ @SerialName("skip-middle-aging-stages-for-crops")
+ val skipMiddleAgingStagesForCrops: Boolean
+ )
+
+ @Serializable

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Blazingly Simple Farm Checks
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..0c210c7788a45c672abed20175dfc05bfea89d34 100644
index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..41a0a22bf28eec79bc6dd96622789a2fd2ec646d 100644
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
@@ -74,6 +74,52 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
@@ -74,6 +74,57 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
int i = this.getAge(state);
if (i < this.getMaxAge()) {
@@ -27,7 +27,12 @@ index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..0c210c7788a45c672abed20175dfc05b
+ isCurrentFarmlandStateMoist = true;
+ }
+ }
+
+ // If we are skipping the middle aging stages, we need to change the growth speed and the next stage accordingly
+ if (world.sparklyPaperConfig.getBlazinglySimpleFarmChecks().getSkipMiddleAgingStagesForCrops()) {
+ f = f / getMaxAge();
+ i = getMaxAge() - 1;
+ }
+
+ // Spigot start
+ int modifier;
+ if (this == Blocks.BEETROOTS) {
@@ -61,7 +66,7 @@ index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..0c210c7788a45c672abed20175dfc05b
float f = CropBlock.getGrowthSpeed(this, world, pos);
// Spigot start
@@ -96,6 +142,8 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
@@ -96,6 +147,8 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
// Spigot end
CraftEventFactory.handleBlockGrowEvent(world, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
}