Configurable Dry and Wet Farmland Tick Rates (#9968)

* Configurable Dry and Wet Farm Land Nearby Water Tick Rates

* Rebase and squash

---------
This commit is contained in:
MrPowerGamerBR 2023-12-02 22:00:17 -03:00 committed by GitHub
parent 40872ece07
commit ffa4115239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -1390,10 +1390,10 @@ index 0000000000000000000000000000000000000000..351fbbc577556ebbd62222615801a96b
+}
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..84e6fc5bac43ee0499b391827726bc02f6d3e46f
index 0000000000000000000000000000000000000000..dbcab5a6095d1f318fd333e24f1aa54da7edcaf5
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -0,0 +1,539 @@
@@ -0,0 +1,541 @@
+package io.papermc.paper.configuration;
+
+import com.google.common.collect.HashBasedTable;
@ -1895,6 +1895,8 @@ index 0000000000000000000000000000000000000000..84e6fc5bac43ee0499b391827726bc02
+ public int grassSpread = 1;
+ public int containerUpdate = 1;
+ public int mobSpawner = 1;
+ public int wetFarmland = 1;
+ public int dryFarmland = 1;
+ public Table<EntityType<?>, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40));
+ public Table<EntityType<?>, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "validatenearbypoi", -1));
+ }

View File

@ -1,9 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Apr 2016 16:28:17 -0400
Subject: [PATCH] Configurable Grass Spread Tick Rate
Subject: [PATCH] Configurable random tick rates for blocks
A general purpose patch that includes config options for the tick rate
of a variety of blocks that are random ticked.
Co-authored-by: MrPowerGamerBR <git@mrpowergamerbr.com>
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index 3b4d8a47e7fe08284b79fab2d147629e902db026..eb6056c5051e5e8a872a10dc993dbd5232787663 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -85,6 +85,8 @@ public class FarmBlock extends Block {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
int i = (Integer) state.getValue(FarmBlock.MOISTURE);
+ if (i > 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper
+ if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper
if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) {
if (i > 0) {
diff --git a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
index 1df22561b2d39066b6b30f10ea43edd734e3b50a..1fe07f8f9b28faf076209f7ad235fd5dc948b294 100644
--- a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java

View File

@ -7,10 +7,10 @@ Apparently the abstract block iteration was taking about
75% of the method call.
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index 3b4d8a47e7fe08284b79fab2d147629e902db026..5946f06f63b5694034bd027984a4925b0831d439 100644
index eb6056c5051e5e8a872a10dc993dbd5232787663..502dcba14da9d3dcefc61fdc349a4e1e1d94b478 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -142,19 +142,27 @@ public class FarmBlock extends Block {
@@ -144,19 +144,27 @@ public class FarmBlock extends Block {
}
private static boolean isNearWater(LevelReader world, BlockPos pos) {