diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/chunks/ChunkSection1_9_1_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/chunks/ChunkSection1_9_1_2.java index f0df40b36..0c5cba766 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/chunks/ChunkSection1_9_1_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/chunks/ChunkSection1_9_1_2.java @@ -47,7 +47,13 @@ public class ChunkSection1_9_1_2 implements ChunkSection { @Override public void setFlatBlock(int x, int y, int z, int type) { - throw new UnsupportedOperationException(); + int index = palette.indexOf(type); + if (index == -1) { + index = palette.size(); + palette.add(type); + } + + blocks[index(x, y, z)] = index; } public int getBlockId(int x, int y, int z) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/chunks/ChunkSection1_9to1_8.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/chunks/ChunkSection1_9to1_8.java index ee54b293c..169da097e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/chunks/ChunkSection1_9to1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/chunks/ChunkSection1_9to1_8.java @@ -48,7 +48,13 @@ public class ChunkSection1_9to1_8 implements ChunkSection { @Override public void setFlatBlock(int x, int y, int z, int type) { - throw new UnsupportedOperationException(); + int index = palette.indexOf(type); + if (index == -1) { + index = palette.size(); + palette.add(type); + } + + blocks[index(x, y, z)] = index; } public int getBlockId(int x, int y, int z) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java index a5e561d4f..62d65170b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java @@ -198,14 +198,39 @@ public class InventoryPackets { public static void toClient(Item item) { if (item == null) return; - int rawId = (item.getId() << 4 | item.getData() & 0xF); - int originalId = (item.getId() << 16 | item.getData() & 0xFFFF); - // Save original id + + // create tag CompoundTag tag = item.getTag(); if (tag == null) { item.setTag(tag = new CompoundTag("tag")); } - item.getTag().put(new IntTag(NBT_TAG_NAME, originalId)); + + // Save original id + int originalId = (item.getId() << 16 | item.getData() & 0xFFFF); + tag.put(new IntTag(NBT_TAG_NAME, originalId)); + + if (isDamageable(item.getId())) { + tag.put(new IntTag("Damage", item.getData())); + } + + if (item.getId() == 358) { // map + tag.put(new IntTag("map", item.getData())); + } + + if (item.getId() == 442) { // shield + if (tag.get("BlockEntityTag") instanceof CompoundTag) { + CompoundTag blockEntityTag = tag.get("BlockEntityTag"); + if (blockEntityTag.get("Base") instanceof IntTag) { + IntTag base = blockEntityTag.get("Base"); + base.setValue(15 - base.getValue()); // invert color id + } + } + } + + // todo spawn egg + + int rawId = (item.getId() << 4 | item.getData() & 0xF); + if (!MappingData.oldToNewItems.containsKey(rawId)) { if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { rawId = item.getId() << 4; @@ -214,31 +239,19 @@ public class InventoryPackets { rawId = 16; // Stone } } - if (isDamageable(item.getId())) { - tag.put(new IntTag("Damage", item.getData())); - } - if (item.getId() == 358) { // map - tag.put(new IntTag("map", item.getData())); - } - if (item.getId() == 442) { // shield - if (tag.get("BlockEntityTag") instanceof CompoundTag) { - CompoundTag blockEntityTag = tag.get("BlockEntityTag"); - if (blockEntityTag.get("Base") instanceof IntTag) { - IntTag base = blockEntityTag.get("Base"); - base.setValue(15 - base.getValue()); - } - } - } - // todo spawn egg + item.setId(MappingData.oldToNewItems.get(rawId).shortValue()); item.setData((short) 0); } public static void toServer(Item item) { if (item == null) return; + Integer rawId = null; boolean gotRawIdFromTag = false; + CompoundTag tag = item.getTag(); + if (tag != null) { // Check for valid tag if (tag.contains(NBT_TAG_NAME)) { @@ -254,31 +267,40 @@ public class InventoryPackets { for (Map.Entry entry : MappingData.oldToNewItems.entrySet()) { if (entry.getValue() == item.getId()) { int oldId = entry.getKey(); - rawId = oldId >> 4 << 16 | oldId & 0xF; + rawId = (oldId >> 4) << 16 | oldId & 0xF; + break; } } } + if (rawId != null) { item.setId((short) (rawId >> 16)); item.setData((short) (rawId & 0xFFFF)); - if (!gotRawIdFromTag) { + + if (tag != null) { if (isDamageable(item.getId())) { - if (tag != null && tag.get("Damage") instanceof IntTag) { - item.setData((short) (int) tag.get("Damage").getValue()); + if (tag.get("Damage") instanceof IntTag) { + if (!gotRawIdFromTag) + item.setData((short) (int) tag.get("Damage").getValue()); + tag.remove("Damage"); } } + if (item.getId() == 358) { // map - if (tag != null && tag.get("map") instanceof IntTag) { - item.setData((short) (int) tag.get("map").getValue()); + if (tag.get("map") instanceof IntTag) { + if (!gotRawIdFromTag) + item.setData((short) (int) tag.get("map").getValue()); + tag.remove("map"); } } - } - if (item.getId() == 442) { // shield - if (tag != null && tag.get("BlockEntityTag") instanceof CompoundTag) { - CompoundTag blockEntityTag = tag.get("BlockEntityTag"); - if (blockEntityTag.get("Base") instanceof IntTag) { - IntTag base = blockEntityTag.get("Base"); - base.setValue(15 - base.getValue()); + + if (item.getId() == 442) { // shield + if (tag.get("BlockEntityTag") instanceof CompoundTag) { + CompoundTag blockEntityTag = tag.get("BlockEntityTag"); + if (blockEntityTag.get("Base") instanceof IntTag) { + IntTag base = blockEntityTag.get("Base"); + base.setValue(15 - base.getValue()); // invert color id + } } } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java index 752d739e5..ec6fe0bfb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/blockentities/SkullHandler.java @@ -10,7 +10,6 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStora public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { private final int SKULL_WALL_START = 5357; private final int SKULL_END = 5476; - // remember to change blockstorage @Override public int transform(UserConnection user, CompoundTag tag) { BlockStorage storage = user.get(BlockStorage.class); diff --git a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json index 655a78e08..2cc73df78 100644 --- a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json +++ b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json @@ -9170,6 +9170,7 @@ "763": "minecraft:music_disc_ward", "764": "minecraft:music_disc_11", "765": "minecraft:music_disc_wait", - "766": "minecraft:trident" + "766": "minecraft:trident", + "767": "minecraft:phantom_membrane" } } \ No newline at end of file