9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-03 22:26:12 +00:00

Start 1.20

This commit is contained in:
violetc
2023-06-10 12:47:52 +08:00
parent 48d4542cc3
commit 6cbeac7802
50 changed files with 304 additions and 371 deletions

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] Optimize random calls in chunk ticking
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..188a0e1b8b9c30ad9e3f88301a91aa4809818d2d 100644
index 488a253e218409b5f0b4a872cee0928578fa7582..a55ed382125310dfdfaeb7e80de2634a8d67f929 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -703,6 +703,11 @@ public class ServerChunkCache extends ChunkSource {
@@ -553,6 +553,11 @@ public class ServerChunkCache extends ChunkSource {
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
gameprofilerfiller.push("pollingChunks");
@@ -22,10 +22,10 @@ index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..188a0e1b8b9c30ad9e3f88301a91aa48
boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8925adb86fb0a9f163030d8ed73bb47b8266b7b0..b06a79cbf4ab0fe3ff6f2f9a2d4697e6bf237d60 100644
index b6ad64f0bed9459aa2ecb4f80b71653691a8359f..bf05f321373c9cb5d42fd6cace010a75dc98b90a 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -796,6 +796,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -937,6 +937,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
// private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Leaves - moved to super
// Paper end
@@ -39,7 +39,7 @@ index 8925adb86fb0a9f163030d8ed73bb47b8266b7b0..b06a79cbf4ab0fe3ff6f2f9a2d4697e6
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
ChunkPos chunkcoordintpair = chunk.getPos();
boolean flag = this.isRaining();
@@ -806,7 +813,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -947,7 +954,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.push("thunder");
final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change
@@ -48,9 +48,9 @@ index 8925adb86fb0a9f163030d8ed73bb47b8266b7b0..b06a79cbf4ab0fe3ff6f2f9a2d4697e6
blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper
if (this.isRainingAt(blockposition)) {
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
@@ -836,7 +843,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.popPush("iceandsnow");
@@ -978,7 +985,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
int l;
int i1;
- if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow
+ if (!this.paperConfig().environment.disableIceAndSnow && (top.leavesmc.leaves.LeavesConfig.optimizeChunkTicking ? (this.currentIceAndSnowTick++ & 15) == 0 : this.random.nextInt(16) == 0)) { // Paper - Disable ice and snow // Paper - optimise random ticking // Leaves - optimize further random ticking
@@ -58,10 +58,10 @@ index 8925adb86fb0a9f163030d8ed73bb47b8266b7b0..b06a79cbf4ab0fe3ff6f2f9a2d4697e6
this.getRandomBlockPosition(j, 0, k, 15, blockposition);
int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition.getX() & 15, blockposition.getZ() & 15) + 1;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index d190bad5d287766ed4165ed827d9901a9d878687..19012c60ea6f725248f7e4a18d78eb1025f4b3a4 100644
index 4ff0d2fc9fd76e92e64abd69f2c9e299aa08ac32..cc224af0139a6e3adefd22cbfa0cd519735b7191 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -88,6 +88,18 @@ public class LevelChunk extends ChunkAccess {
@@ -85,6 +85,18 @@ public class LevelChunk extends ChunkAccess {
private final LevelChunkTicks<Block> blockTicks;
private final LevelChunkTicks<Fluid> fluidTicks;
@@ -80,7 +80,7 @@ index d190bad5d287766ed4165ed827d9901a9d878687..19012c60ea6f725248f7e4a18d78eb10
public LevelChunk(Level world, ChunkPos pos) {
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
}
@@ -116,6 +128,12 @@ public class LevelChunk extends ChunkAccess {
@@ -112,6 +124,12 @@ public class LevelChunk extends ChunkAccess {
this.postLoad = entityLoader;
this.blockTicks = blockTickScheduler;
this.fluidTicks = fluidTickScheduler;