3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-09-16 17:31:21 +02:00

Actually set legacy block remaps

Dieser Commit ist enthalten in:
KennyTV 2020-02-01 12:07:27 +01:00
Ursprung 01121dedf3
Commit 152b9db80f
4 geänderte Dateien mit 29 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -9,13 +9,14 @@ public class MappedLegacyBlockItem {
private final int id; private final int id;
private final short data; private final short data;
private final String name; private final String name;
private Block block; private final Block block;
private BlockEntityHandler blockEntityHandler; 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.id = id;
this.data = data; this.data = data;
this.name = name != null ? ChatColor.RESET + name : null; this.name = name != null ? ChatColor.RESET + name : null;
this.block = block ? new Block(id, data) : null;
} }
public int getId() { public int getId() {
@ -34,11 +35,6 @@ public class MappedLegacyBlockItem {
return block != null; return block != null;
} }
// Mark this as a block item
public void setBlock() {
block = new Block(id, data);
}
public Block getBlock() { public Block getBlock() {
return block; return block;
} }

Datei anzeigen

@ -47,6 +47,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
JsonPrimitive jsonData = object.getAsJsonPrimitive("data"); JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
short data = jsonData != null ? jsonData.getAsShort() : 0; short data = jsonData != null ? jsonData.getAsShort() : 0;
String name = object.getAsJsonPrimitive("name").getAsString(); String name = object.getAsJsonPrimitive("name").getAsString();
boolean block = object.getAsJsonPrimitive("block").getAsBoolean();
if (dataEntry.getKey().contains("-")) { if (dataEntry.getKey().contains("-")) {
// Range of ids // Range of ids
@ -57,16 +58,16 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
// Special block color handling // Special block color handling
if (name.contains("%color%")) { if (name.contains("%color%")) {
for (int i = from; i <= to; i++) { 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 { } else {
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name); MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, block);
for (int i = from; i <= to; i++) { for (int i = from; i <= to; i++) {
mappings.put(i, mappedBlockItem); mappings.put(i, mappedBlockItem);
} }
} }
} else { } 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<T extends BackwardsProtocol> exten
this(protocol, null, null); this(protocol, null, null);
} }
protected void markAsBlock(int... ids) {
for (int id : ids) {
replacementData.get(id).setBlock();
}
}
@Override @Override
public Item handleItemToClient(Item item) { public Item handleItemToClient(Item item) {
if (item == null) return null; if (item == null) return null;

Datei anzeigen

@ -352,7 +352,8 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
// Handle spawner block entity (map to itself with custom handler) // Handle spawner block entity (map to itself with custom handler)
replacementData.computeIfAbsent(52, s -> 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); EntityTypeNames.toClientSpawner(tag);
return tag; return tag;
}); });

Datei anzeigen

@ -3,12 +3,14 @@
"251": { "251": {
"id": 159, "id": 159,
"data": -1, "data": -1,
"name": "1.12 %vb_color% Concrete" "name": "1.12 %vb_color% Concrete",
"block": true
}, },
"252": { "252": {
"id": 35, "id": 35,
"data": -1, "data": -1,
"name": "1.12 %vb_color% Concrete Powder" "name": "1.12 %vb_color% Concrete Powder",
"block": true
}, },
"453": { "453": {
"id": 340, "id": 340,
@ -20,7 +22,8 @@
}, },
"235-250": { "235-250": {
"id": 159, "id": 159,
"name": "1.12 %color% Glazed Terracotta" "name": "1.12 %color% Glazed Terracotta",
"block": true
} }
}, },
"1.11.1": { "1.11.1": {
@ -33,7 +36,8 @@
"218": { "218": {
"id": 23, "id": 23,
"data": -1, "data": -1,
"name": "1.11 Observer" "name": "1.11 Observer",
"block": true
}, },
"449": { "449": {
"id": 32, "id": 32,
@ -45,7 +49,8 @@
}, },
"219-234": { "219-234": {
"id": 158, "id": 158,
"name": "1.11 %color% Shulker Box" "name": "1.11 %color% Shulker Box",
"block": true
} }
}, },
"1.10": { "1.10": {
@ -55,25 +60,30 @@
}, },
"217": { "217": {
"id": 287, "id": 287,
"name": "1.10 Structure Void" "name": "1.10 Structure Void",
"block": true
}, },
"213": { "213": {
"id": 159, "id": 159,
"data": 1, "data": 1,
"name": "1.10 Magma Block" "name": "1.10 Magma Block",
"block": true
}, },
"214": { "214": {
"id": 159, "id": 159,
"data": 14, "data": 14,
"name": "1.10 Nether Wart Block" "name": "1.10 Nether Wart Block",
"block": true
}, },
"215": { "215": {
"id": 112, "id": 112,
"name": "1.10 Red Nether Bricks" "name": "1.10 Red Nether Bricks",
"block": true
}, },
"216": { "216": {
"id": 155, "id": 155,
"name": "1.10 Bone Block" "name": "1.10 Bone Block",
"block": true
} }
} }
} }