Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Ursprung
c8a010c390
Commit
c2ee558235
@ -51,7 +51,12 @@ public final class PaletteType1_18 extends Type<DataPalette> {
|
|||||||
//TODO Create proper singleton palette Object
|
//TODO Create proper singleton palette Object
|
||||||
palette = new DataPaletteImpl(type.size(), 1);
|
palette = new DataPaletteImpl(type.size(), 1);
|
||||||
palette.addId(Type.VAR_INT.readPrimitive(buffer));
|
palette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||||
Type.VAR_INT.readPrimitive(buffer); // 0 values length
|
|
||||||
|
// Just eat it if not 0 - thanks, Hypixel
|
||||||
|
final int valuesLength = Type.VAR_INT.readPrimitive(buffer);
|
||||||
|
for (int i = 0; i < valuesLength; i++) {
|
||||||
|
buffer.readLong();
|
||||||
|
}
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,18 +79,17 @@ public final class PaletteType1_18 extends Type<DataPalette> {
|
|||||||
// Read values
|
// Read values
|
||||||
final int valuesLength = Type.VAR_INT.readPrimitive(buffer);
|
final int valuesLength = Type.VAR_INT.readPrimitive(buffer);
|
||||||
if (valuesLength > 0) {
|
if (valuesLength > 0) {
|
||||||
final int valuesPerLong = (char) (64 / bitsPerValue);
|
|
||||||
final int expectedLength = (type.size() + valuesPerLong - 1) / valuesPerLong;
|
|
||||||
if (valuesLength != expectedLength) {
|
|
||||||
throw new IllegalStateException("Palette data length (" + valuesLength + ") does not match expected length (" + expectedLength + ")! bitsPerValue=" + bitsPerValue + ", originalBitsPerValue=" + originalBitsPerValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
final long[] values = new long[valuesLength];
|
final long[] values = new long[valuesLength];
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < valuesLength; i++) {
|
||||||
values[i] = buffer.readLong();
|
values[i] = buffer.readLong();
|
||||||
}
|
}
|
||||||
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerValue, type.size(), values,
|
|
||||||
bitsPerValue == globalPaletteBits ? palette::setIdAt : palette::setPaletteIndexAt);
|
final int valuesPerLong = (char) (64 / bitsPerValue);
|
||||||
|
final int expectedLength = (type.size() + valuesPerLong - 1) / valuesPerLong;
|
||||||
|
if (valuesLength == expectedLength) { // Thanks, Hypixel
|
||||||
|
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerValue, type.size(), values,
|
||||||
|
bitsPerValue == globalPaletteBits ? palette::setIdAt : palette::setPaletteIndexAt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren