diff --git a/core/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java b/core/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java index b0053dfb..75e90842 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/data/MappedLegacyBlockItem.java @@ -9,13 +9,14 @@ public class MappedLegacyBlockItem { private final int id; private final short data; private final String name; - private Block block; + private final Block block; private BlockEntityHandler blockEntityHandler; - public MappedLegacyBlockItem(int id, short data, String name) { + public MappedLegacyBlockItem(int id, short data, String name, boolean block) { this.id = id; this.data = data; this.name = name != null ? ChatColor.RESET + name : null; + this.block = block ? new Block(id, data) : null; } public int getId() { @@ -34,11 +35,6 @@ public class MappedLegacyBlockItem { return block != null; } - // Mark this as a block item - public void setBlock() { - block = new Block(id, data); - } - public Block getBlock() { return block; } diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java index e343ffc0..e519f21d 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/LegacyBlockItemRewriter.java @@ -47,6 +47,7 @@ public abstract class LegacyBlockItemRewriter exten JsonPrimitive jsonData = object.getAsJsonPrimitive("data"); short data = jsonData != null ? jsonData.getAsShort() : 0; String name = object.getAsJsonPrimitive("name").getAsString(); + boolean block = object.getAsJsonPrimitive("block").getAsBoolean(); if (dataEntry.getKey().contains("-")) { // Range of ids @@ -57,16 +58,16 @@ public abstract class LegacyBlockItemRewriter exten // Special block color handling if (name.contains("%color%")) { for (int i = from; i <= to; i++) { - mappings.put(i, new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)))); + mappings.put(i, new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), block)); } } else { - MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name); + MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, block); for (int i = from; i <= to; i++) { mappings.put(i, mappedBlockItem); } } } else { - mappings.put(Integer.parseInt(dataEntry.getKey()), new MappedLegacyBlockItem(id, data, name)); + mappings.put(Integer.parseInt(dataEntry.getKey()), new MappedLegacyBlockItem(id, data, name, block)); } } } @@ -81,12 +82,6 @@ public abstract class LegacyBlockItemRewriter exten this(protocol, null, null); } - protected void markAsBlock(int... ids) { - for (int id : ids) { - replacementData.get(id).setBlock(); - } - } - @Override public Item handleItemToClient(Item item) { if (item == null) return null; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java index d70593c8..6fcdb82d 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java @@ -352,7 +352,8 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter new MappedLegacyBlockItem(52, (short) -1, null)).setBlockEntityHandler((b, tag) -> { + MappedLegacyBlockItem data = replacementData.computeIfAbsent(52, s -> new MappedLegacyBlockItem(52, (short) -1, null, false)); + data.setBlockEntityHandler((b, tag) -> { EntityTypeNames.toClientSpawner(tag); return tag; }); diff --git a/core/src/main/resources/assets/viabackwards/data/legacy-mappings.json b/core/src/main/resources/assets/viabackwards/data/legacy-mappings.json index 960c952c..c16ccae2 100644 --- a/core/src/main/resources/assets/viabackwards/data/legacy-mappings.json +++ b/core/src/main/resources/assets/viabackwards/data/legacy-mappings.json @@ -3,12 +3,14 @@ "251": { "id": 159, "data": -1, - "name": "1.12 %vb_color% Concrete" + "name": "1.12 %vb_color% Concrete", + "block": true }, "252": { "id": 35, "data": -1, - "name": "1.12 %vb_color% Concrete Powder" + "name": "1.12 %vb_color% Concrete Powder", + "block": true }, "453": { "id": 340, @@ -20,7 +22,8 @@ }, "235-250": { "id": 159, - "name": "1.12 %color% Glazed Terracotta" + "name": "1.12 %color% Glazed Terracotta", + "block": true } }, "1.11.1": { @@ -33,7 +36,8 @@ "218": { "id": 23, "data": -1, - "name": "1.11 Observer" + "name": "1.11 Observer", + "block": true }, "449": { "id": 32, @@ -45,7 +49,8 @@ }, "219-234": { "id": 158, - "name": "1.11 %color% Shulker Box" + "name": "1.11 %color% Shulker Box", + "block": true } }, "1.10": { @@ -55,25 +60,30 @@ }, "217": { "id": 287, - "name": "1.10 Structure Void" + "name": "1.10 Structure Void", + "block": true }, "213": { "id": 159, "data": 1, - "name": "1.10 Magma Block" + "name": "1.10 Magma Block", + "block": true }, "214": { "id": 159, "data": 14, - "name": "1.10 Nether Wart Block" + "name": "1.10 Nether Wart Block", + "block": true }, "215": { "id": 112, - "name": "1.10 Red Nether Bricks" + "name": "1.10 Red Nether Bricks", + "block": true }, "216": { "id": 155, - "name": "1.10 Bone Block" + "name": "1.10 Bone Block", + "block": true } } } \ No newline at end of file