3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-25 15:50:10 +01:00

Use ByteBuf#order, more sanity check on block entity handler

Dieser Commit ist enthalten in:
creeper123123321 2019-02-10 15:22:34 -02:00
Ursprung f1743e5912
Commit 4eb4b2c37f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
4 geänderte Dateien mit 20 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -4,9 +4,7 @@ import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.type.Type;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
public class ChunkSectionType1_8 extends Type<ChunkSection> {
@ -19,12 +17,10 @@ public class ChunkSectionType1_8 extends Type<ChunkSection> {
ChunkSection chunkSection = new ChunkSection();
chunkSection.clearPalette();
byte[] blockData = new byte[ChunkSection.SIZE * 2];
buffer.readBytes(blockData);
ShortBuffer blockBuf = ByteBuffer.wrap(blockData).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
ByteBuf littleEndianView = buffer.order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < ChunkSection.SIZE; i++) {
int mask = blockBuf.get();
int mask = littleEndianView.readShort();
int type = mask >> 4;
int data = mask & 0xF;
chunkSection.setBlock(i, type, data);

Datei anzeigen

@ -29,7 +29,11 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
int blockId = storage.get(position).getOriginal();
int color = (int) tag.get("Base").getValue();
Tag base = tag.get("Base");
int color = 0;
if (base != null) {
color = ((Number) tag.get("Base").getValue()).intValue();
}
// Standing banner
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
blockId += ((15 - color) * 16);
@ -43,8 +47,10 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
if (tag.get("Patterns") instanceof ListTag) {
for (Tag pattern : (ListTag) tag.get("Patterns")) {
if (pattern instanceof CompoundTag) {
IntTag c = ((CompoundTag) pattern).get("Color");
c.setValue(15 - c.getValue()); // Invert color id
Tag c = ((CompoundTag) pattern).get("Color");
if (c instanceof IntTag) {
((IntTag)c).setValue(15 - (int) c.getValue()); // Invert color id
}
}
}
}

Datei anzeigen

@ -23,8 +23,10 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
// RED_BED + FIRST_BED
int blockId = storage.get(position).getOriginal() - 972 + 748;
int color = (int) tag.get("color").getValue();
blockId += (color * 16);
Tag color = tag.get("color");
if (color != null) {
blockId += (((Number) color.getValue()).intValue() * 16);
}
return blockId;
}

Datei anzeigen

@ -25,9 +25,12 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
int id = storage.get(position).getOriginal();
if (id >= SKULL_WALL_START && id <= SKULL_END) {
id += (byte) tag.get("SkullType").getValue() * 20;
Tag skullType = tag.get("SkullType");
if (skullType != null) {
id += ((Number) tag.get("SkullType").getValue()).intValue() * 20;
}
if (tag.contains("Rot")) {
id += (byte) tag.get("Rot").getValue();
id += ((Number) tag.get("Rot").getValue()).intValue();
}
} else {
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);