9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0196-Cache-random-tick-block-status.patch
2025-06-03 09:49:56 +08:00

60 lines
3.2 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/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
index df717c545472006b99532280c38c1fbef12bcf82..36c033b0ee63dfc273d721fb4b614733e8fdef19 100644
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -21,6 +21,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;
private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
@@ -54,6 +55,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
this.tickingFluidCount = section.tickingFluidCount;
this.states = section.states.copy();
this.biomes = section.biomes.copy();
+ this.isRandomlyTickingBlocksStatus = this.tickingBlockCount > 0; // Leaf - Cache random tick block status
}
public LevelChunkSection(PalettedContainer<BlockState> states, PalettedContainer<Holder<Biome>> biomes) { // CraftBukkit - read/write
@@ -165,6 +167,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
}
this.updateBlockCallback(x, y, z, state, blockState); // Paper - block counting
+ this.isRandomlyTickingBlocksStatus = this.tickingBlockCount > 0; // Leaf - Cache random tick block status
return blockState;
}
@@ -178,7 +181,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() {
@@ -193,6 +196,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
this.tickingFluidCount = (short)0;
this.specialCollidingBlocks = (short)0;
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;
@@ -226,6 +230,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
this.nonEmptyBlockCount += (short)paletteCount;
if (state.isRandomlyTicking()) {
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;