9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00
Files
Leaf/patches/server/0158-Cache-random-tick-block-status.patch
Dreeam 4ff90891a5 Fix Nova incompatibility
* Remove C2ME: Reduce Allocations in ver/1.21.1 branch
* Revert int to short change for specialCollidingBlocks in moonrise optimization
2025-04-27 13:14:53 -04:00

52 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sat, 23 Nov 2024 09:04:46 -0500
Subject: [PATCH] Cache random tick block status
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index 855b49e819498951163bc814a05e8d3e18e6b338..ce97ec2af013af052734814404b4f5fd8c9d66ed 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -22,6 +22,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
short nonEmptyBlockCount; // Paper - package private
private short tickingBlockCount;
private short tickingFluidCount;
+ private boolean isRandomlyTickingBlocksStatus; // Leaf - Cache random tick block status
public final PalettedContainer<BlockState> states;
// CraftBukkit start - read/write
private PalettedContainer<Holder<Biome>> biomes;
@@ -167,6 +168,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
}
this.updateBlockCallback(x, y, z, state, iblockdata1); // Moonrise - block counting optimisations
+ this.isRandomlyTickingBlocksStatus = this.tickingBlockCount > 0; // Leaf - Cache random tick block status
return iblockdata1;
}
@@ -180,7 +182,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
}
public boolean isRandomlyTickingBlocks() {
- return this.tickingBlockCount > 0;
+ return isRandomlyTickingBlocksStatus; // Leaf - Cache random tick block status
}
public boolean isRandomlyTickingFluids() {
@@ -197,6 +199,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
this.specialCollidingBlocks = (short) 0;
// Moonrise end - block counting optimisations
this.tickingBlocks.clear();
+ this.isRandomlyTickingBlocksStatus = false; // Leaf - Cache random tick block status
if (this.maybeHas((final BlockState state) -> !state.isAir())) {
final PalettedContainer.Data<BlockState> data = this.states.data;
@@ -233,6 +236,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
if (state.isRandomlyTicking()) {
// Moonrise start - block counting optimisations
this.tickingBlockCount += (short) paletteCount;
+ this.isRandomlyTickingBlocksStatus = this.tickingBlockCount > 0; // Leaf - Cache random tick block status
final short[] raw = coordinates.elements();
final int rawLen = raw.length;