mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-22 08:19:19 +00:00
ModernFix: compact_bit_storage
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
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 58fe9e7aebeadc36f5f8f6f1073100c21e521e9d..352caf649a8b2fefef3825bdf71b0ddd5f77b528 100644
|
||||||
|
--- a/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
+++ b/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
@@ -275,6 +275,28 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||||
|
data.palette.read(buffer);
|
||||||
|
buffer.readLongArray(data.storage.getRaw());
|
||||||
|
this.data = data;
|
||||||
|
+ // DivineMC start - ModernFix: compact_bit_storage
|
||||||
|
+ if (org.bxteam.divinemc.DivineConfig.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);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // 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 {
|
||||||
@@ -289,6 +289,7 @@ public class DivineConfig {
|
|||||||
public static boolean ignoreMovedTooQuicklyWhenLagging = true;
|
public static boolean ignoreMovedTooQuicklyWhenLagging = true;
|
||||||
public static boolean alwaysAllowWeirdMovement = true;
|
public static boolean alwaysAllowWeirdMovement = true;
|
||||||
public static boolean updateSuppressionCrashFix = true;
|
public static boolean updateSuppressionCrashFix = true;
|
||||||
|
public static boolean useCompactBitStorage = false;
|
||||||
private static void miscSettings() {
|
private static void miscSettings() {
|
||||||
skipUselessSecondaryPoiSensor = getBoolean("settings.misc.skip-useless-secondary-poi-sensor", skipUselessSecondaryPoiSensor);
|
skipUselessSecondaryPoiSensor = getBoolean("settings.misc.skip-useless-secondary-poi-sensor", skipUselessSecondaryPoiSensor);
|
||||||
clumpOrbs = getBoolean("settings.misc.clump-orbs", clumpOrbs,
|
clumpOrbs = getBoolean("settings.misc.clump-orbs", clumpOrbs,
|
||||||
@@ -298,6 +299,8 @@ public class DivineConfig {
|
|||||||
alwaysAllowWeirdMovement = getBoolean("settings.misc.always-allow-weird-movement", alwaysAllowWeirdMovement,
|
alwaysAllowWeirdMovement = getBoolean("settings.misc.always-allow-weird-movement", alwaysAllowWeirdMovement,
|
||||||
"Means ignoring messages like 'moved too quickly' and 'moved wrongly'");
|
"Means ignoring messages like 'moved too quickly' and 'moved wrongly'");
|
||||||
updateSuppressionCrashFix = getBoolean("settings.misc.update-suppression-crash-fix", updateSuppressionCrashFix);
|
updateSuppressionCrashFix = getBoolean("settings.misc.update-suppression-crash-fix", updateSuppressionCrashFix);
|
||||||
|
useCompactBitStorage = getBoolean("settings.misc.use-compact-bit-storage", useCompactBitStorage,
|
||||||
|
"Fixes memory waste caused by sending empty chunks as if they contain blocks. Can significantly reduce memory usage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean disableDisconnectSpam = false;
|
public static boolean disableDisconnectSpam = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user