9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/divinemc-server/minecraft-patches/features/0022-ModernFix-compact_bit_storage.patch
NONPLAYT 9e496185fa Updated Upstream (Purpur)
Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@c8a4f0b6 Updated Upstream (Paper)
PurpurMC/Purpur@e8fe8ece forgot to commit this
PurpurMC/Purpur@45bc9f41 Updated Upstream (Paper)
2025-10-18 05:22:26 +03:00

45 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 8 Mar 2025 13:27:07 +0300
Subject: [PATCH] ModernFix: compact_bit_storage
This patch is based on following mixins:
* "org/embeddedt/modernfix/common/mixin/perf/compact_bit_storage/PalettedContainerMixin.java"
By: embeddedt <42941056+embeddedt@users.noreply.github.com>
As part of: ModernFix (https://github.com/embeddedt/ModernFix)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java
index 51ece91c956fd4d55eaef34a534fdb38c6d24446..2e2625dbb8f14b11156d16501f4a1e1dea7eaef1 100644
--- a/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -281,6 +281,28 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
data.palette.read(buffer, this.strategy.globalMap());
buffer.readFixedSizeLongArray(data.storage.getRaw());
this.data = data;
+ // DivineMC start - ModernFix: compact_bit_storage
+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.useCompactBitStorage && _byte > 1) {
+ long[] storageArray = this.data.storage.getRaw();
+ boolean empty = true;
+ for (long l : storageArray) {
+ if (l != 0) {
+ empty = false;
+ break;
+ }
+ }
+ if (empty && storageArray.length > 0) {
+ T value;
+ try {
+ value = this.data.palette.valueFor(0);
+ } catch (RuntimeException e) {
+ return;
+ }
+ this.data = this.createOrReuseData(null, 0);
+ this.data.palette.idFor(value, this);
+ }
+ }
+ // DivineMC end - ModernFix: compact_bit_storage
this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server)
this.updateData(this.data); // Paper - optimise palette reads
} finally {