Skip to content

Commit

Permalink
Update Upstream
Browse files Browse the repository at this point in the history
Yet another patch merged into Paper, yay!
  • Loading branch information
MrPowerGamerBR committed Dec 3, 2023
1 parent 238b466 commit 95a2786
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 56 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ This does not include all patches included in SparklyPaper, only the patches han

SparklyPaper's config file is `sparklypaper.yml`, the file is, by default, placed on the root of your server.

* Configurable Farm Land moisture tick rate when the block is already moisturised
* The `isNearWater` check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive `isNearWater` checks.
* (Incompatible with the Blazingly Simple Farm Checks feature)
* Skip `distanceToSqr` call in `ServerEntity#sendChanges` if the delta movement hasn't changed
* The `distanceToSqr` call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check. Currently, we only check if both Vec3 objects have the same identity, that means, if they are literally the same object. (that works because Minecraft's code reuses the Vec3 object when caching the current delta movement)
* Skip `MapItem#update()` if the map does not have the default `CraftMapRenderer` present
Expand Down Expand Up @@ -46,6 +43,7 @@ SparklyPaper's config file is `sparklypaper.yml`, the file is, by default, place
* The growth speed of crops and stems are now fixed based on if the block below them is moist or not, instead of doing vanilla's behavior of "check all blocks nearby to see if at least one of them is moist" and "if the blocks nearby are of the same time, make them grow slower".
* In my opinion: Who cares about the vanilla behavior lol, most players only care about farm land + crop = crop go brrrr
* Another optimization is that crop behavior can be changed to skip from age zero to the last age directly, while still keeping the original growth duration of the crop. This way, useless block updates due to crop growth can be avoided!
* (Incompatible with Paper's Dry and Wet Farmland custom tick rates)
* Spooky month optimizations
* The quintessential patch that other performance forks also have for... some reason??? I thought that this optimization was too funny to not do it in SparklyPaper.
* Caches when Bat's spooky season starts and ends, and when Skeleton and Zombies halloween starts and ends. The epoch is updated every 90 days. If your server is running for 90+ days straight without restarts, congratulations!
Expand Down Expand Up @@ -88,7 +86,10 @@ These features were originally in SparklyPaper, but now they are in Paper, yay!
* To avoid this, we can just... not check for the item's durability! Don't worry, the durability of the item is checked when it checks if both item metas are equal.
* This is a leftover from when checking for the item's durability was "free" because the durability was stored in the `ItemStack` itself, this [was changed in Minecraft 1.13](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/f8b2086d60942eb2cd7ac25a2a1408cb790c222c#src/main/java/org/bukkit/inventory/ItemStack.java).
* (The reason I found out that this had a performance impact was because the `getDurability()` was using 0.08ms each tick according to spark... yeah, sadly it ain't a super big crazy optimization, the performance impact would be bigger if you have more plugins using `isSimilar(...)` tho)

* Configurable Farm Land moisture tick rate when the block is already moisturised (Merged in [Paper #9968](https://github.com/PaperMC/Paper/pull/9968))
* The `isNearWater` check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive `isNearWater` checks.
* (Incompatible with the Blazingly Simple Farm Checks feature)

We attempt to upstream everything that we know helps performance and makes the server go zoom, and not stuff that we only *hope* that it improves performance. I'm still learning after all. :)

## Support
Expand Down
29 changes: 13 additions & 16 deletions patches/server/0002-SparklyPaper-config-files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ 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..155ef71c119ebeb95fdfae9e681520b91874ba8e
index 0000000000000000000000000000000000000000..8b78f0e8b1de1a6a2506e686be9d71ced72352dd
--- /dev/null
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
@@ -0,0 +1,56 @@
@@ -0,0 +1,61 @@
+package net.sparklypower.sparklypaper.configs
+
+import com.charleskorn.kaml.Yaml
+import com.charleskorn.kaml.YamlConfiguration
+import com.google.common.base.Throwables
+import kotlinx.serialization.SerializationException
+import kotlinx.serialization.decodeFromString
Expand All @@ -241,7 +242,11 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9
+import java.util.logging.Level
+
+object SparklyPaperConfigUtils {
+ val yaml = Yaml()
+ val yaml = Yaml(
+ configuration = YamlConfiguration(
+ strictMode = false
+ )
+ )
+ lateinit var config: SparklyPaperConfig
+
+ fun init(configFile: File) {
Expand All @@ -261,9 +266,6 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9
+ defaultGrowthSpeed = 1.0f,
+ moistGrowthSpeed = 5.0f,
+ skipMiddleAgingStagesForCrops = true
+ ),
+ SparklyPaperWorldConfig.TickRates(
+ farmWhenMoisturised = 1
+ )
+ )
+ )
Expand All @@ -278,6 +280,9 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load sparklypaper.yml, please correct your syntax errors", e)
+ throw Throwables.propagate(e)
+ }
+ // Rewrite the config file to remove old fields and stuff
+ // TODO: Maybe handle this in another way? This feels kinda bad
+ configFile.writeText(yaml.encodeToString(loadedConfig))
+ config = loadedConfig
+ }
+
Expand All @@ -288,10 +293,10 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9
\ 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..d2c53262581710d2ca4b588331fe54458015bfe8
index 0000000000000000000000000000000000000000..0909362629aa4f6cdfd4052b4b1dc847cbdb57d8
--- /dev/null
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt
@@ -0,0 +1,31 @@
@@ -0,0 +1,23 @@
+package net.sparklypower.sparklypaper.configs
+
+import kotlinx.serialization.SerialName
Expand All @@ -303,8 +308,6 @@ index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe5445
+ val skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer: Boolean,
+ @SerialName("blazingly-simple-farm-checks")
+ val blazinglySimpleFarmChecks: BlazinglySimpleFarmChecks,
+ @SerialName("tick-rates")
+ val tickRates: TickRates
+) {
+ @Serializable
+ data class BlazinglySimpleFarmChecks(
Expand All @@ -316,11 +319,5 @@ index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe5445
+ @SerialName("skip-middle-aging-stages-for-crops")
+ val skipMiddleAgingStagesForCrops: Boolean
+ )
+
+ @Serializable
+ data class TickRates(
+ @SerialName("farm-when-moisturised")
+ val farmWhenMoisturised: Int
+ )
+}
\ No newline at end of file

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,10 @@ index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..41a0a22bf28eec79bc6dd96622789a2f
}

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 590a573a9b5099d3062031dc54978993cdd912ad..544131216aff2b2b54b8690d4321a194deab1589 100644
index 502dcba14da9d3dcefc61fdc349a4e1e1d94b478..fc8d56f02e8b22261cf2f205b39dfa1aeea5a7ff 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -1,6 +1,5 @@
package net.minecraft.world.level.block;

-import java.util.Iterator;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -85,6 +84,19 @@ public class FarmBlock extends Block {
@@ -85,6 +85,19 @@ public class FarmBlock extends Block {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
int i = (Integer) state.getValue(FarmBlock.MOISTURE);
Expand All @@ -103,10 +96,10 @@ index 590a573a9b5099d3062031dc54978993cdd912ad..544131216aff2b2b54b8690d4321a194
+ return;
+ }
+ // SparklyPaper end
if (i > 0 && world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 1 && (world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 0)) { return; } // SparklyPaper
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())) {
@@ -142,7 +154,7 @@ public class FarmBlock extends Block {
@@ -143,7 +156,7 @@ public class FarmBlock extends Block {
return world.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2235,12 +2235,12 @@ index 0000000000000000000000000000000000000000..3d536f724ffdae462e3af39e85e4e391
+}
\ 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
index 155ef71c119ebeb95fdfae9e681520b91874ba8e..e1f898bd806f6bcdde477eb9af18cc4b2ff6446e 100644
index 8b78f0e8b1de1a6a2506e686be9d71ced72352dd..ce608ca9640cdea0fe690ef61021355822284cf6 100644
--- a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
@@ -12,6 +12,7 @@ import java.util.logging.Level
object SparklyPaperConfigUtils {
val yaml = Yaml()
@@ -17,6 +17,7 @@ object SparklyPaperConfigUtils {
)
)
lateinit var config: SparklyPaperConfig
+ val logContainerCreationStacktraces = java.lang.Boolean.getBoolean("sparklypaper.logContainerCreationStacktraces")

Expand Down

0 comments on commit 95a2786

Please sign in to comment.