use of net.modificationstation.stationapi.impl.nbt.LongArrayCompound in project StationAPI by ModificationStation.
the class PalettedContainer method write.
public void write(CompoundTag compoundTag, String string, String string2) {
this.lock();
BiMapPalette<T> biMapPalette = new BiMapPalette<>(this.idList, this.paletteSize, this.noOpPaletteResizeHandler, this.elementDeserializer, this.elementSerializer);
T object = this.defaultValue;
int i = biMapPalette.getIndex(this.defaultValue);
int[] is = new int[4096];
for (int j = 0; j < 4096; ++j) {
T object2 = this.get(j);
if (object2 != object) {
object = object2;
i = biMapPalette.getIndex(object2);
}
is[j] = i;
}
ListTag listTag = new ListTag();
biMapPalette.toTag(listTag);
compoundTag.put(string, listTag);
int k = Math.max(4, MathHelper.log2DeBruijn(listTag.size()));
PackedIntegerArray packedIntegerArray = new PackedIntegerArray(k, 4096);
for (int l = 0; l < is.length; ++l) {
packedIntegerArray.set(l, is[l]);
}
((LongArrayCompound) compoundTag).put(string2, packedIntegerArray.getStorage());
this.unlock();
}
Aggregations