Fix item mappings with explicit data (0) (#738)

This commit is contained in:
EnZaXD 2024-05-07 18:54:38 +02:00 committed by GitHub
parent 072b59060c
commit 7f0982e59c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 7 deletions

View File

@ -105,7 +105,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
unmappedId = Integer.parseInt(key.substring(0, dataSeparatorIndex));
unmappedId = IdAndData.toRawData(unmappedId, unmappedData);
} else {
unmappedId = IdAndData.toRawData(Integer.parseInt(key));
unmappedId = IdAndData.toRawData(Integer.parseInt(key), -1);
}
mappings.put(unmappedId, new MappedLegacyBlockItem(id, data, name, type));
@ -120,12 +120,12 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
// Special block color handling
if (name != null && name.contains("%color%")) {
for (int i = from; i <= to; i++) {
mappings.put(IdAndData.toRawData(i), new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), type));
mappings.put(IdAndData.toRawData(i, -1), new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), type));
}
} else {
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, type);
for (int i = from; i <= to; i++) {
mappings.put(IdAndData.toRawData(i), mappedBlockItem);
mappings.put(IdAndData.toRawData(i, -1), mappedBlockItem);
}
}
}
@ -361,17 +361,18 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
private @Nullable MappedLegacyBlockItem getMappedBlock(int id, int data) {
MappedLegacyBlockItem mapping = blockReplacements.get(IdAndData.toRawData(id, data));
return mapping != null || data == 0 ? mapping : blockReplacements.get(IdAndData.toRawData(id));
return mapping != null ? mapping : blockReplacements.get(IdAndData.toRawData(id, -1));
}
private @Nullable MappedLegacyBlockItem getMappedItem(int id, int data) {
MappedLegacyBlockItem mapping = itemReplacements.get(IdAndData.toRawData(id, data));
return mapping != null || data == 0 ? mapping : itemReplacements.get(IdAndData.toRawData(id));
return mapping != null ? mapping : itemReplacements.get(IdAndData.toRawData(id, -1));
}
private @Nullable MappedLegacyBlockItem getMappedBlock(int rawId) {
MappedLegacyBlockItem mapping = blockReplacements.get(rawId);
return mapping != null ? mapping : blockReplacements.get(IdAndData.removeData(rawId));
int id = IdAndData.getId(rawId);
int data = IdAndData.getData(rawId);
return getMappedBlock(id, data);
}
protected JsonObject readMappingsFile(final String name) {