Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Readd warnings for missing mappings
Dieser Commit ist enthalten in:
Ursprung
897e9545c2
Commit
91b81ebb24
@ -84,11 +84,35 @@ public class BackwardsMappings extends MappingData {
|
|||||||
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
|
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be overridden.
|
||||||
|
*/
|
||||||
|
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean shouldWarnOnMissing(String key) {
|
protected boolean shouldWarnOnMissing(String key) {
|
||||||
return !key.equals("blocks") && !key.equals("statistics");
|
return !key.equals("blocks") && !key.equals("statistics");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
/**
|
||||||
|
* @see #getMappedItem(int) for custom backwards mappings
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getNewItemId(int id) {
|
||||||
|
// Don't warn on missing here
|
||||||
|
return this.itemMappings.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewBlockId(int id) {
|
||||||
|
// Don't warn on missing here
|
||||||
|
return this.blockMappings.getNewId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOldItemId(final int id) {
|
||||||
|
// Warn on missing
|
||||||
|
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -101,11 +125,6 @@ public class BackwardsMappings extends MappingData {
|
|||||||
return backwardsSoundMappings != null ? backwardsSoundMappings.get(id) : null;
|
return backwardsSoundMappings != null ? backwardsSoundMappings.get(id) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int checkValidity(int id, String type) {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
public Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
||||||
return backwardsItemMappings;
|
return backwardsItemMappings;
|
||||||
|
@ -25,9 +25,8 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
|||||||
public Item handleItemToClient(Item item) {
|
public Item handleItemToClient(Item item) {
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
|
|
||||||
CompoundTag display = null;
|
CompoundTag display = item.getTag() != null ? item.getTag().get("display") : null;
|
||||||
if (translatableRewriter != null
|
if (translatableRewriter != null && display != null) {
|
||||||
&& item.getTag() != null && (display = item.getTag().get("display")) != null) {
|
|
||||||
// Handle name and lore components
|
// Handle name and lore components
|
||||||
StringTag name = display.get("Name");
|
StringTag name = display.get("Name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -84,12 +84,6 @@ public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOldItemId(final int id) {
|
|
||||||
// Return -1 when missing
|
|
||||||
return this.itemMappings.inverse().get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||||
@ -103,6 +97,12 @@ public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int checkValidity(int id, int mappedId, String type) {
|
||||||
|
// Don't warn for missing ids here
|
||||||
|
return mappedId;
|
||||||
|
}
|
||||||
|
|
||||||
public Int2ObjectMap<String> getStatisticMappings() {
|
public Int2ObjectMap<String> getStatisticMappings() {
|
||||||
return statisticMappings;
|
return statisticMappings;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren