lithium serialization optimizations

also nuked option which made minecraft 2 real
This commit is contained in:
Ivan Pekov 2020-08-22 22:11:04 +03:00
parent c32fe11abd
commit 21c8252193
9 changed files with 417 additions and 51 deletions

View File

@ -119,5 +119,6 @@ # Patches
| server | lithium VoxelShapesMixin | JellySquid | Ivan Pekov |
| server | lithium collision optimizations | JellySquid | Ivan Pekov |
| server | lithium enum_values | JellySquid | |
| server | lithium serialization improvements | JellySquid | |
| server | lithium-MixinChunkGeneratorAbstract | JellySquid | tr7zw |
| server | lithium-MixinDataWatcher | JellySquid | tr7zw |

View File

@ -165,10 +165,10 @@ index 0000000000000000000000000000000000000000..0ada1657122fd973bbb8ec8b7c7be83d
+}
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a62f2314c8f62cef83ed4b68cb45368bad62628
index 0000000000000000000000000000000000000000..b67a82569747fb8f4a349b7f81fe502cc4e2a792
--- /dev/null
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -0,0 +1,215 @@
@@ -0,0 +1,213 @@
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Throwables;
@ -244,6 +244,9 @@ index 0000000000000000000000000000000000000000..6a62f2314c8f62cef83ed4b68cb45368
+ if (config.get("settings.onlyPlayerCollisions") != null) {
+ set("settings.onlyPlayerCollisions", null);
+ }
+ if (config.get("settings.disableEntityCollisionboxes") != null) {
+ set("settings.disableEntityCollisionboxes", null);
+ }
+ }
+
+ protected static void logError(String s) {
@ -378,11 +381,6 @@ index 0000000000000000000000000000000000000000..6a62f2314c8f62cef83ed4b68cb45368
+ disableEntityStuckChecks = getBoolean("settings.disableEntityStuckChecks", false);
+ }
+
+ public static boolean disableEntityCollisionboxes = false;
+ private static void disableEntityCollisionboxes() {
+ disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
+ }
+
+}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index a60634fc455e8a59399020689b70eb64b6824d12..cb4a89940cf02de5c3eefc5c746397a931c96b7a 100644
@ -404,19 +402,6 @@ index a60634fc455e8a59399020689b70eb64b6824d12..cb4a89940cf02de5c3eefc5c746397a9
this.setPVP(dedicatedserverproperties.pvp);
this.setAllowFlight(dedicatedserverproperties.allowFlight);
this.setResourcePack(dedicatedserverproperties.resourcePack, this.aZ());
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 4cab3f19366a1ea0d6708011e83e4e44b7eff875..4adfd017c5759af8f038e44a02228400717849a2 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -701,7 +701,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// Paper end
vec3d = this.a(vec3d, enummovetype);
- Vec3D vec3d1 = this.performCollision(vec3d); // Tuinity - optimise collisions
+ Vec3D vec3d1 = dev.tr7zw.yatopia.YatopiaConfig.disableEntityCollisionboxes ? vec3d : this.performCollision(vec3d); // Tuinity - optimise collisions // Yatopia
if (vec3d1.g() > 1.0E-7D) {
this.a(this.getBoundingBox().c(vec3d1));
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index f24f7f1230a380f46112e886fb5dff7c33edb2ce..88f4c30a03e9139b0284ff1a545ad80941dbd46c 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java

View File

@ -5,11 +5,11 @@ Subject: [PATCH] Allow to change the piston push limit
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index 6a62f2314c8f62cef83ed4b68cb45368bad62628..f23c13d14649e92e747b45d93a06bd5726bab00b 100644
index b67a82569747fb8f4a349b7f81fe502cc4e2a792..fd33954eb91339a8568610f515ee164527d7406b 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -212,4 +212,8 @@ public class YatopiaConfig {
disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
@@ -210,4 +210,8 @@ public class YatopiaConfig {
disableEntityStuckChecks = getBoolean("settings.disableEntityStuckChecks", false);
}
+ public static int pistonPushLimit = 12;

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Item stuck sleep config
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index f23c13d14649e92e747b45d93a06bd5726bab00b..4d718370eb544fb4eb6a1d051512f63414df8c7e 100644
index fd33954eb91339a8568610f515ee164527d7406b..d70b6af62f7e9a0b49c38fae1170f0eb0584c781 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -216,4 +216,9 @@ public class YatopiaConfig {
@@ -214,4 +214,9 @@ public class YatopiaConfig {
private static void pistonPushLimit() {
pistonPushLimit = getInt("settings.pistonPushLimit", 12);
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Option for simpler Villagers
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index 4d718370eb544fb4eb6a1d051512f63414df8c7e..39477fcec9ea1e09b9019534f09fe3ff03bdc886 100644
index d70b6af62f7e9a0b49c38fae1170f0eb0584c781..039255d795f0e00b2a40861aa05c38c11db425cd 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -221,4 +221,11 @@ public class YatopiaConfig {
@@ -219,4 +219,11 @@ public class YatopiaConfig {
private static void itemStuckSleepTicks() {
itemStuckSleepTicks = getInt("settings.itemStuckSleepTicks", 1);
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fix lead fall dmg config
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index 39477fcec9ea1e09b9019534f09fe3ff03bdc886..0543de8ea80322028729723fd2b500ee7921ffd5 100644
index 039255d795f0e00b2a40861aa05c38c11db425cd..729e6d5fa5d3abd77d07defb0dbd5b2c960a0889 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -228,4 +228,9 @@ public class YatopiaConfig {
@@ -226,4 +226,9 @@ public class YatopiaConfig {
simplerVillagerBehavior = getBoolean("settings.villager.simplerVillagerBehavior", false);
villagersHideAtNight = getBoolean("settings.villager.villagersHideAtNight", false);
}
@ -19,7 +19,7 @@ index 39477fcec9ea1e09b9019534f09fe3ff03bdc886..0543de8ea80322028729723fd2b500ee
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 4adfd017c5759af8f038e44a02228400717849a2..d7bd1b7791a15f0cce51a9d1a42fe0bf4d63307b 100644
index 4cab3f19366a1ea0d6708011e83e4e44b7eff875..55916c77365076450e6c1b6c7e530433172d95c7 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1266,6 +1266,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke

View File

@ -20,10 +20,10 @@ Thanks to Gabriele C <sgdc3.mail@gmail.com> for pointing this issue to us, as he
have any interest fixing this.
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index 0543de8ea80322028729723fd2b500ee7921ffd5..74bff3264d50d5352398d94526239c3c7507a5e4 100644
index 729e6d5fa5d3abd77d07defb0dbd5b2c960a0889..ef7d683db9e92dc6d64e9d7b4225c87637db8de2 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -233,4 +233,26 @@ public class YatopiaConfig {
@@ -231,4 +231,26 @@ public class YatopiaConfig {
private static void fixFallDistance() {
fixFallDistance = getBoolean("settings.fixFallDistance", false);
}

View File

@ -10,27 +10,27 @@ Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
diff --git a/src/main/java/dev/tr7zw/yatopia/HoldingConsumer.java b/src/main/java/dev/tr7zw/yatopia/HoldingConsumer.java
new file mode 100644
index 0000000000000000000000000000000000000000..2fe5f953126abfa69368a8432d0092faefd4f048
index 0000000000000000000000000000000000000000..f0ead67b4c5354c4077c615dd873bc4ec7b81676
--- /dev/null
+++ b/src/main/java/dev/tr7zw/yatopia/HoldingConsumer.java
@@ -0,0 +1,17 @@
+package dev.tr7zw.yatopia;
+
+import java.util.function.Consumer;
+
+public final class HoldingConsumer<T> implements Consumer<T> {
+
+ private T value;
+
+ @Override
+ public void accept(T t) {
+ this.value = t;
+ }
+
+ public T getValue() {
+ return value;
+ }
+}
+package dev.tr7zw.yatopia;
+
+import java.util.function.Consumer;
+
+public final class HoldingConsumer<T> implements Consumer<T> {
+
+ private T value;
+
+ @Override
+ public void accept(T t) {
+ this.value = t;
+ }
+
+ public T getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java
new file mode 100644
index 0000000000000000000000000000000000000000..b400a5870b64b9eb92b6a8311793f5c8ea8df9af
@ -831,7 +831,7 @@ index ac6e5e3309affc830d4db07fd9b8d809c3085033..37a3b26cdeb02acb8051f0a99313de79
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index d7bd1b7791a15f0cce51a9d1a42fe0bf4d63307b..b1a0a8340c3198e993ff2e1528fbb0b5643caa11 100644
index 55916c77365076450e6c1b6c7e530433172d95c7..60d040eb58c44790214f0869e7294bc70b021ec5 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -75,7 +75,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke

View File

@ -0,0 +1,380 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Sat, 22 Aug 2020 20:49:11 +0300
Subject: [PATCH] lithium serialization improvements
Original code by JellySquid, licensed under LGPLv3
you can find the original code on https://github.com/jellysquid3/lithium-fabric/ (Yarn mappings)
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f00db6560f9d9802774fe755f7adc4ab1142124
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java
@@ -0,0 +1,11 @@
+package me.jellysquid.mods.lithium.common.world.chunk;
+
+import net.minecraft.server.DataPalette;
+
+public interface CompactingPackedIntegerArray {
+ /**
+ * Copies the data out of this array into a new non-packed array. The returned array contains a copy of this array
+ * re-mapped using {@param destPalette}.
+ */
+ <T> void compact(DataPalette<T> srcPalette, DataPalette<T> dstPalette, short[] out);
+}
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java
new file mode 100644
index 0000000000000000000000000000000000000000..79bb15e7af8e67c08214537eec35f4fc025a0635
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java
@@ -0,0 +1,156 @@
+package me.jellysquid.mods.lithium.common.world.chunk;
+
+import it.unimi.dsi.fastutil.HashCommon;
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import java.util.Arrays;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import net.minecraft.server.DataPalette;
+import net.minecraft.server.DataPaletteExpandable;
+import net.minecraft.server.NBTTagCompound;
+import net.minecraft.server.NBTTagList;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.RegistryBlockID;
+
+import static it.unimi.dsi.fastutil.Hash.FAST_LOAD_FACTOR;
+
+public class LithiumHashPalette<T> implements DataPalette<T> {
+ private static final int ABSENT_VALUE = -1;
+
+ private final RegistryBlockID<T> idList;
+ private final DataPaletteExpandable<T> resizeHandler;
+ private final Function<NBTTagCompound, T> elementDeserializer;
+ private final Function<T, NBTTagCompound> elementSerializer;
+ private final int indexBits;
+
+ private final Reference2IntMap<T> table;
+ private T[] entries;
+ private int size = 0;
+
+ @SuppressWarnings("unchecked")
+ public LithiumHashPalette(RegistryBlockID<T> idList, int bits, DataPaletteExpandable<T> paletteListener, Function<NBTTagCompound, T> elementDeserializer, Function<T, NBTTagCompound> elementSerializer) {
+ this.idList = idList;
+ this.resizeHandler = paletteListener;
+ this.elementDeserializer = elementDeserializer;
+ this.elementSerializer = elementSerializer;
+ this.indexBits = bits;
+
+ int capacity = 1 << bits;
+ this.entries = (T[]) new Object[capacity];
+ this.table = new Reference2IntOpenHashMap<>(capacity, FAST_LOAD_FACTOR);
+ this.table.defaultReturnValue(ABSENT_VALUE);
+ }
+
+ @Override
+ public int a(T t0) {
+ int id = this.table.getInt(t0);
+
+ if (id == ABSENT_VALUE) {
+ id = this.computeEntry(t0);
+ }
+
+ return id;
+ }
+
+ private int computeEntry(T obj) {
+ int id = this.addEntry(obj);
+
+ if (id >= 1 << this.indexBits) {
+ if (this.resizeHandler == null) {
+ throw new IllegalStateException("Cannot grow");
+ } else {
+ id = this.resizeHandler.onResize(this.indexBits + 1, obj);
+ }
+ }
+
+ return id;
+ }
+
+ private int addEntry(T obj) {
+ int nextId = this.size;
+
+ if (nextId >= this.entries.length) {
+ this.resize(this.size);
+ }
+
+ this.table.put(obj, nextId);
+ this.entries[nextId] = obj;
+
+ this.size++;
+
+ return nextId;
+ }
+
+ private void resize(int neededCapacity) {
+ this.entries = Arrays.copyOf(this.entries, HashCommon.nextPowerOfTwo(neededCapacity + 1));
+ }
+
+ @Override
+ public boolean a(Predicate<T> predicate) {
+ for (int i = 0; i < this.size; ++i) {
+ if (predicate.test(this.entries[i])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public T a(int id) {
+ T[] entries = this.entries;
+
+ if (id >= 0 && id < entries.length) {
+ return entries[id];
+ }
+
+ return null;
+ }
+
+ @Override
+ public void b(PacketDataSerializer buf) {
+ int size = this.size;
+ buf.writeVarInt(size);
+
+ for (int i = 0; i < size; ++i) {
+ buf.writeVarInt(this.idList.getId(this.a(i)));
+ }
+ }
+
+ @Override
+ public int a() {
+ int size = PacketDataSerializer.countBytes(this.size);
+
+ for (int i = 0; i < this.size; ++i) {
+ size += PacketDataSerializer.countBytes(this.idList.getId(this.a(i)));
+ }
+
+ return size;
+ }
+
+ @Override
+ public void a(NBTTagList list) {
+ this.clear();
+
+ for (int i = 0; i < list.size(); ++i) {
+ this.addEntry(this.elementDeserializer.apply(list.getCompound(i)));
+ }
+ }
+
+ public void toTag(NBTTagList list) {
+ for (int i = 0; i < this.size; ++i) {
+ list.add(this.elementSerializer.apply(this.a(i)));
+ }
+ }
+
+ public int getSize() {
+ return this.size;
+ }
+
+ private void clear() {
+ Arrays.fill(this.entries, null);
+ this.table.clear();
+ this.size = 0;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java
index 353b61aa57501fa76ce42dff5ba61bdb6a1e302e..1257871044e66f5b2334c0d708218454051e65b6 100644
--- a/src/main/java/net/minecraft/server/DataBits.java
+++ b/src/main/java/net/minecraft/server/DataBits.java
@@ -4,14 +4,14 @@ import java.util.function.IntConsumer;
import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
-public class DataBits {
+public class DataBits implements me.jellysquid.mods.lithium.common.world.chunk.CompactingPackedIntegerArray { // Yatopia
private static final int[] a = new int[]{-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, 0, 5};
- private final long[] b;
- private final int c;
- private final long d;
- private final int e;
- private final int f;
+ private final long[] b; // Yatopia - storage
+ private final int c; // Yatopia - elementBits
+ private final long d; // Yatopia - maxValue
+ private final int e; // Yatopia - size
+ private final int f; // Yatopia - yarn field_24079
private final int g;
private final int h;
private final int i;
@@ -142,4 +142,38 @@ public class DataBits {
}
// Paper end
+
+ // Yatopia start
+ @Override
+ public <T> void compact(DataPalette<T> srcPalette, DataPalette<T> dstPalette, short[] out) {
+ if (e >= Short.MAX_VALUE) throw new IllegalStateException("Array too large");
+ if (e != out.length) throw new IllegalStateException("Array size mismatch");
+
+ short[] mappings = new short[(int) (this.d + 1)];
+
+ int idx = 0;
+ for (long word : b) {
+ long bits = word;
+
+ for (int i = 0; i < f; i++) {
+ int value = (int) (bits & d);
+ int remappedId = mappings[value];
+
+ if (remappedId == 0) {
+ remappedId = dstPalette.a(srcPalette.a(value)) + 1;
+ mappings[value] = (short) remappedId;
+ }
+
+ out[idx] = (short) (remappedId - 1);
+ bits >>= c;
+
+ ++idx;
+
+ if (idx >= this.e) {
+ return;
+ }
+ }
+ }
+ }
+ // Yatopia end
}
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
index 52948a84b89554646c9ec1fd13d6d3c9e7cbf996..42aa0828a4598df507eb0bcaa6b35cb88c143ed8 100644
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
@@ -11,6 +11,10 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
+ // Yatopia start
+ private static final ThreadLocal<short[]> cachedCompactionArrays = ThreadLocal.withInitial(() -> new short[4096]);
+ private static final long[] EMPTY_PALETTE_DATA = new long[(4 * 4096) / 64];
+ // Yatopia end
private final DataPalette<T> b; private final DataPalette<T> getDataPaletteGlobal() { return this.b; } // Paper - OBFHELPER
private final DataPaletteExpandable<T> c = (i, object) -> {
@@ -228,6 +232,44 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
}
public synchronized void a(NBTTagCompound nbttagcompound, String s, String s1) { // Paper - synchronize
+ // Yatopia start - rewrite
+ me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T> palette = null;
+ long[] dataArray = null;
+
+ if (h instanceof me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette) {
+ palette = (me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T>) h;
+
+ if (palette.getSize() == 1 && palette.a(0) == g) {
+ dataArray = EMPTY_PALETTE_DATA;
+ }
+ }
+
+ if (dataArray == null) {
+ me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T> compactedPalette =
+ new me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<>(d, i, null, e, f);
+ short[] array = cachedCompactionArrays.get();
+ ((me.jellysquid.mods.lithium.common.world.chunk.CompactingPackedIntegerArray)a).compact(h, compactedPalette, array);
+
+ if (h != null && h.a() == compactedPalette.getSize()) {
+ dataArray = a.getDataBits().clone();
+ } else {
+ int size = Math.max(4, MathHelper.e(compactedPalette.getSize()));
+ DataBits copy = new DataBits(size, 4096);
+ for (int i = 0; i < array.length; i++) {
+ copy.set(i, array[i]);
+ }
+
+ dataArray = copy.getDataBits();
+ palette = compactedPalette;
+ }
+ }
+ NBTTagList paletteTag = new NBTTagList();
+ palette.toTag(paletteTag);
+
+ nbttagcompound.set(s, paletteTag);
+ nbttagcompound.setLongArray(s1, dataArray);
+
+ /*
this.a();
DataPaletteHash<T> datapalettehash = new DataPaletteHash<>(this.d, this.i, this.c, this.e, this.f);
T t0 = this.g;
@@ -258,6 +300,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
nbttagcompound.a(s1, databits.a());
this.b();
+ */ // Yatopia end
}
public int c() {
@@ -281,9 +324,24 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
// Paper start
public void forEachLocation(DataPaletteBlock.a<T> datapaletteblock_a) {
+ // Yatopia start
+ int len = (1 << i);
+ if (len > 4096) return;
+
+ short[] counts = new short[len];
+
+ getDataBits().a((l) -> counts[l]++);
+
+ for (int i = 0; i < counts.length; i++) {
+ T obj = h.a(i);
+ if (obj != null) datapaletteblock_a.accept(obj, counts[i]);
+ }
+ /*
this.getDataBits().forEach((int location, int data) -> {
datapaletteblock_a.accept(this.getDataPalette().getObject(data), location);
});
+ */
+ // Yatopia end
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/DataPaletteExpandable.java b/src/main/java/net/minecraft/server/DataPaletteExpandable.java
index a550b21a9756ff1dcb4a21d8116f0a393ee88282..c2441e3f75805bc604411da66cb02b8ec148b031 100644
--- a/src/main/java/net/minecraft/server/DataPaletteExpandable.java
+++ b/src/main/java/net/minecraft/server/DataPaletteExpandable.java
@@ -1,6 +1,6 @@
package net.minecraft.server;
-interface DataPaletteExpandable<T> {
+public interface DataPaletteExpandable<T> { // Yatopia - wtf?
int onResize(int i, T t0);
}
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
index 06d5acab794e3ee139a11f9b068e8a359c46db2c..e94bf9dbc8d965c5b3dbcec177fd6ed1c76bcb18 100644
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
@@ -193,6 +193,7 @@ public class NBTTagCompound implements NBTBase {
this.map.put(s, new NBTTagIntArray(list));
}
+ public final void setLongArray(String s, long[] arr) { a(s, arr); } // Yatopia - OBFHELPER
public void a(String s, long[] along) {
this.map.put(s, new NBTTagLongArray(along));
}
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index f43193c1090238f2241b878120247d1b3d0d4e57..9942ac3e1bf7fb997fee4719e6d98dc6fb912a4f 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -210,6 +210,7 @@ public class PacketDataSerializer extends ByteBuf {
return new UUID(this.readLong(), this.readLong());
}
+ public final PacketDataSerializer writeVarInt(int i) { return d(i); } // Yatopia - OBFHELPER
public PacketDataSerializer d(int i) {
while ((i & -128) != 0) {
this.writeByte(i & 127 | 128);