mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 16:09:19 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@803baf0b Support hidden entities in Waypoints (#12715) PaperMC/Paper@1814d8b4 build: publish to fill (#12717) PaperMC/Paper@e454fef4 Add support for private constructors in plugin main classes (#12652) PaperMC/Paper@d0e808f4 Move player to correct position in vehicle move packet handler PaperMC/Paper@46b4b0b8 Improve keepalive ping system PaperMC/Paper@38c1ddb5 Add and use FeatureHooks.getAllEntities PaperMC/Paper@2f083acb Ensure player entity schedulers are ticked when they are dead PaperMC/Paper@7c90c7c4 Optimise EntityScheduler ticking PaperMC/Paper@aa6ee44a Re-add global region scheduler tick erroneously removed in last commit PaperMC/Paper@d7510efc Fix #12722 (#12726) PaperMC/Paper@0caf75f8 Fix #12721 (#12725) PaperMC/Paper@bee28792 Adventure 4.23.0 (#12690) PaperMC/Paper@692e93a9 Fix MC-299110 PaperMC/Paper@ea10fa4a Don't mutate the position of Items for MC-4 Fix (#12702) PaperMC/Paper@aa6cd74c Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668) PaperMC/Paper@c9e89f49 Expose arrow velocity in EntityShootBowEvent for mobs (#12688) PaperMC/Paper@7ec3174a Jump out of experimental phase PaperMC/Paper@4e1a2555 Update try catch for command handling PaperMC/Paper@e382e687 Fix 0 yield on explosion events PaperMC/Paper@35b2c6ec Use dropped item for stats info (#12747) PaperMC/Paper@bd79e20c [ci/skip] PluginManager#getPlugin and PluginManager#isPluginEnabled are case-insensitive (#12723) Purpur Changes: PurpurMC/Purpur@4a5974cf Updated Upstream (Paper) PurpurMC/Purpur@3893bba0 this is important... PurpurMC/Purpur@47e758fb Updated Upstream (Paper)
66 lines
3.9 KiB
Diff
66 lines
3.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: hayanesuru <hayanesuru@outlook.jp>
|
|
Date: Fri, 6 Jun 2025 20:46:10 +0900
|
|
Subject: [PATCH] optimize random tick
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index 1c23d82a2034bc4ae61ee9bc6c74b39940d4fc2b..57f45e571b92ff0b4499a97da33c8be746d8abd5 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -648,7 +648,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
list.clear();
|
|
}
|
|
|
|
- this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
|
|
+ // Leaf start - optimize random tick
|
|
+ if (org.dreeam.leaf.config.modules.opt.OptimizeRandomTick.enabled) {
|
|
+ this.level.randomTickSystem.tick(this.level);
|
|
+ } else {
|
|
+ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
|
|
+ }
|
|
+ // Leaf end - optimize random tick
|
|
if (_boolean) {
|
|
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
|
}
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 27da552e2542153a58d6177f592cf30d858c41a9..35fb0770eb385e3837cb29711905c41b899bac8f 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1114,6 +1114,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.simpleRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking
|
|
|
|
+ public org.dreeam.leaf.world.RandomTickSystem randomTickSystem = new org.dreeam.leaf.world.RandomTickSystem(); // Leaf - optimize random tick
|
|
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
|
final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting
|
|
ChunkPos pos = chunk.getPos();
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index a3674ddb883eecb255279375a5e2eece7e016c0f..963a882af639f1f69698bafad1d70eda6d22b846 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -152,6 +152,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
}
|
|
// Gale end - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively
|
|
|
|
+ // Leaf start - optimize random tick
|
|
+ public boolean leaf$tickingBlocksDirty = true;
|
|
+ public short[] leaf$tickingBlocksCount = {};
|
|
+ public short[] leaf$tickingIdx = {};
|
|
+ // Leaf end - optimize random tick
|
|
public LevelChunk(Level level, ChunkPos pos) {
|
|
this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null);
|
|
}
|
|
@@ -416,6 +421,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
if (blockState == state) {
|
|
return null;
|
|
} else {
|
|
+ // Leaf start - optimize random tick
|
|
+ if (blockState.isRandomlyTicking() != state.isRandomlyTicking()) {
|
|
+ leaf$tickingBlocksDirty = true;
|
|
+ }
|
|
+ // Leaf end - optimize random tick
|
|
Block block = state.getBlock();
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state);
|