Warn with unmapped id when missing

This commit is contained in:
KennyTV 2020-09-04 10:31:16 +02:00 committed by Nassim
parent a709382d25
commit b7bf993795
2 changed files with 7 additions and 7 deletions

View File

@ -47,19 +47,20 @@ public class MappingData {
}
public int getNewBlockStateId(int id) {
return checkValidity(blockStateMappings.getNewId(id), "blockstate");
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
}
public int getNewBlockId(int id) {
return checkValidity(blockMappings.getNewId(id), "block");
return checkValidity(id, blockMappings.getNewId(id), "block");
}
public int getNewItemId(int id) {
return checkValidity(itemMappings.get(id), "item");
return checkValidity(id, itemMappings.get(id), "item");
}
public int getOldItemId(int id) {
int oldId = itemMappings.inverse().get(id);
// Remap new items to stone
return oldId != -1 ? oldId : 1;
}
@ -108,12 +109,12 @@ public class MappingData {
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
}
protected int checkValidity(int id, String type) {
if (id == -1) {
protected int checkValidity(int id, int mappedId, String type) {
if (mappedId == -1) {
Via.getPlatform().getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
return 0;
}
return id;
return mappedId;
}
/**

View File

@ -465,7 +465,6 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
@Nullable
public MappingData getMappingData() {
//TODO Fully hold the instance here and get rid of all static usages (at some point:tm:)
return null; // Let the protocols hold the mappings to still have easy, static singleton access there
}