Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Use ByteBuf#order, more sanity check on block entity handler
Dieser Commit ist enthalten in:
Ursprung
f1743e5912
Commit
4eb4b2c37f
@ -4,9 +4,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.ShortBuffer;
|
|
||||||
|
|
||||||
public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
||||||
|
|
||||||
@ -19,12 +17,10 @@ public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
|||||||
ChunkSection chunkSection = new ChunkSection();
|
ChunkSection chunkSection = new ChunkSection();
|
||||||
chunkSection.clearPalette();
|
chunkSection.clearPalette();
|
||||||
|
|
||||||
byte[] blockData = new byte[ChunkSection.SIZE * 2];
|
ByteBuf littleEndianView = buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
buffer.readBytes(blockData);
|
|
||||||
ShortBuffer blockBuf = ByteBuffer.wrap(blockData).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
|
|
||||||
|
|
||||||
for (int i = 0; i < ChunkSection.SIZE; i++) {
|
for (int i = 0; i < ChunkSection.SIZE; i++) {
|
||||||
int mask = blockBuf.get();
|
int mask = littleEndianView.readShort();
|
||||||
int type = mask >> 4;
|
int type = mask >> 4;
|
||||||
int data = mask & 0xF;
|
int data = mask & 0xF;
|
||||||
chunkSection.setBlock(i, type, data);
|
chunkSection.setBlock(i, type, data);
|
||||||
|
@ -29,7 +29,11 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
|
|
||||||
int blockId = storage.get(position).getOriginal();
|
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
|
// Standing banner
|
||||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||||
blockId += ((15 - color) * 16);
|
blockId += ((15 - color) * 16);
|
||||||
@ -43,8 +47,10 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
if (tag.get("Patterns") instanceof ListTag) {
|
if (tag.get("Patterns") instanceof ListTag) {
|
||||||
for (Tag pattern : (ListTag) tag.get("Patterns")) {
|
for (Tag pattern : (ListTag) tag.get("Patterns")) {
|
||||||
if (pattern instanceof CompoundTag) {
|
if (pattern instanceof CompoundTag) {
|
||||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
Tag c = ((CompoundTag) pattern).get("Color");
|
||||||
c.setValue(15 - c.getValue()); // Invert color id
|
if (c instanceof IntTag) {
|
||||||
|
((IntTag)c).setValue(15 - (int) c.getValue()); // Invert color id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,10 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
// RED_BED + FIRST_BED
|
// RED_BED + FIRST_BED
|
||||||
int blockId = storage.get(position).getOriginal() - 972 + 748;
|
int blockId = storage.get(position).getOriginal() - 972 + 748;
|
||||||
|
|
||||||
int color = (int) tag.get("color").getValue();
|
Tag color = tag.get("color");
|
||||||
blockId += (color * 16);
|
if (color != null) {
|
||||||
|
blockId += (((Number) color.getValue()).intValue() * 16);
|
||||||
|
}
|
||||||
|
|
||||||
return blockId;
|
return blockId;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,12 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
int id = storage.get(position).getOriginal();
|
int id = storage.get(position).getOriginal();
|
||||||
|
|
||||||
if (id >= SKULL_WALL_START && id <= SKULL_END) {
|
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")) {
|
if (tag.contains("Rot")) {
|
||||||
id += (byte) tag.get("Rot").getValue();
|
id += ((Number) tag.get("Rot").getValue()).intValue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
|
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren