Better resize loop

This commit is contained in:
themode 2022-01-03 22:07:54 +01:00 committed by TheMode
parent 9689c89010
commit 7fb0ac8fd0

View File

@ -3,7 +3,6 @@ package net.minestom.server.instance.palette;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.instance.Chunk;
import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -215,9 +214,9 @@ final class PaletteImpl implements Palette, Cloneable {
private void resize(int newBitsPerEntry) { private void resize(int newBitsPerEntry) {
newBitsPerEntry = fixBitsPerEntry(newBitsPerEntry); newBitsPerEntry = fixBitsPerEntry(newBitsPerEntry);
PaletteImpl palette = new PaletteImpl(dimension, maxBitsPerEntry, newBitsPerEntry, bitsIncrement); PaletteImpl palette = new PaletteImpl(dimension, maxBitsPerEntry, newBitsPerEntry, bitsIncrement);
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) { for (int y = 0; y < dimension; y++) {
for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) { for (int x = 0; x < dimension; x++) {
for (int z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { for (int z = 0; z < dimension; z++) {
palette.set(x, y, z, get(x, y, z)); palette.set(x, y, z, get(x, y, z));
} }
} }