9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 00:49:31 +00:00
Files
Leaf/patches/server/0159-Cache-random-tick-block-status.patch
Dreeam 0510b51ed3 Fix terminal color on Windows (#176)
* Fix terminal color on Windows

Windows doesn't have environment variables TERM and COLORTERM by default, but we assuming that it supports the `truecolor` for terminal.

* Add back revert to original java console on Java 22
2024-11-30 20:01:54 -05: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 5b54d956486cec3c39824b15e37bf090798c5047..9e6779d305a6690be8ea756b77dcdfdf69f93087 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;
@@ -166,6 +167,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;
}
@@ -179,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() {
@@ -196,6 +198,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;
@@ -232,6 +235,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;