mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2025-01-10 20:08:26 +01:00
Actually set legacy block remaps
This commit is contained in:
parent
01121dedf3
commit
152b9db80f
@ -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;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> 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<T extends BackwardsProtocol> 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<T extends BackwardsProtocol> 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;
|
||||
|
@ -352,7 +352,8 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// 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);
|
||||
return tag;
|
||||
});
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user