Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Replace some generic CompoundTag get usages
Dieser Commit ist enthalten in:
Ursprung
c6ea04fd33
Commit
ced1a65230
@ -57,19 +57,19 @@ public class BackwardsMappings extends MappingDataBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadExtras(final CompoundTag data) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
final CompoundTag itemNames = data.get("itemnames");
|
final CompoundTag itemNames = data.getCompoundTag("itemnames");
|
||||||
if (itemNames != null) {
|
if (itemNames != null) {
|
||||||
Preconditions.checkNotNull(itemMappings);
|
Preconditions.checkNotNull(itemMappings);
|
||||||
backwardsItemMappings = new Int2ObjectOpenHashMap<>(itemNames.size());
|
backwardsItemMappings = new Int2ObjectOpenHashMap<>(itemNames.size());
|
||||||
|
|
||||||
final CompoundTag extraItemData = data.get("itemdata");
|
final CompoundTag extraItemData = data.getCompoundTag("itemdata");
|
||||||
for (final Map.Entry<String, Tag> entry : itemNames.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : itemNames.entrySet()) {
|
||||||
final StringTag name = (StringTag) entry.getValue();
|
final StringTag name = (StringTag) entry.getValue();
|
||||||
final int id = Integer.parseInt(entry.getKey());
|
final int id = Integer.parseInt(entry.getKey());
|
||||||
Integer customModelData = null;
|
Integer customModelData = null;
|
||||||
if (extraItemData != null && extraItemData.contains(entry.getKey())) {
|
if (extraItemData != null && extraItemData.contains(entry.getKey())) {
|
||||||
final CompoundTag entryTag = extraItemData.get(entry.getKey());
|
final CompoundTag entryTag = extraItemData.getCompoundTag(entry.getKey());
|
||||||
final NumberTag customModelDataTag = entryTag.get("custom_model_data");
|
final NumberTag customModelDataTag = entryTag.getNumberTag("custom_model_data");
|
||||||
customModelData = customModelDataTag != null ? customModelDataTag.asInt() : null;
|
customModelData = customModelDataTag != null ? customModelDataTag.asInt() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class BackwardsMappings extends MappingDataBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag entityNames = data.get("entitynames");
|
final CompoundTag entityNames = data.getCompoundTag("entitynames");
|
||||||
if (entityNames != null) {
|
if (entityNames != null) {
|
||||||
this.entityNames = new HashMap<>(entityNames.size());
|
this.entityNames = new HashMap<>(entityNames.size());
|
||||||
for (final Map.Entry<String, Tag> entry : entityNames.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : entityNames.entrySet()) {
|
||||||
@ -86,7 +86,7 @@ public class BackwardsMappings extends MappingDataBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag soundNames = data.get("soundnames");
|
final CompoundTag soundNames = data.getCompoundTag("soundnames");
|
||||||
if (soundNames != null) {
|
if (soundNames != null) {
|
||||||
backwardsSoundMappings = new HashMap<>(soundNames.size());
|
backwardsSoundMappings = new HashMap<>(soundNames.size());
|
||||||
for (final Map.Entry<String, Tag> entry : soundNames.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : soundNames.entrySet()) {
|
||||||
|
@ -79,7 +79,7 @@ public final class VBMappingDataLoader {
|
|||||||
for (final Map.Entry<String, Tag> entry : extra.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : extra.entrySet()) {
|
||||||
if (entry.getValue() instanceof CompoundTag) {
|
if (entry.getValue() instanceof CompoundTag) {
|
||||||
// For compound tags, don't replace the entire tag
|
// For compound tags, don't replace the entire tag
|
||||||
final CompoundTag originalEntry = original.get(entry.getKey());
|
final CompoundTag originalEntry = original.getCompoundTag(entry.getKey());
|
||||||
if (originalEntry != null) {
|
if (originalEntry != null) {
|
||||||
mergeTags(originalEntry, (CompoundTag) entry.getValue());
|
mergeTags(originalEntry, (CompoundTag) entry.getValue());
|
||||||
continue;
|
continue;
|
||||||
|
@ -75,13 +75,13 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
CompoundTag registry = wrapper.read(Type.NAMED_COMPOUND_TAG);
|
CompoundTag registry = wrapper.read(Type.NAMED_COMPOUND_TAG);
|
||||||
if (wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_15_2.getVersion()) {
|
if (wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_15_2.getVersion()) {
|
||||||
// Store biomes for <1.16 client handling
|
// Store biomes for <1.16 client handling
|
||||||
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
|
||||||
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
|
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
|
||||||
biomeStorage.clear();
|
biomeStorage.clear();
|
||||||
for (CompoundTag biome : biomes) {
|
for (CompoundTag biome : biomes) {
|
||||||
StringTag name = biome.get("name");
|
StringTag name = biome.getStringTag("name");
|
||||||
NumberTag id = biome.get("id");
|
NumberTag id = biome.getNumberTag("id");
|
||||||
biomeStorage.addBiome(name.getValue(), id.asInt());
|
biomeStorage.addBiome(name.getValue(), id.asInt());
|
||||||
}
|
}
|
||||||
} else if (!warned) {
|
} else if (!warned) {
|
||||||
@ -114,7 +114,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
|
|
||||||
private String getDimensionFromData(CompoundTag dimensionData) {
|
private String getDimensionFromData(CompoundTag dimensionData) {
|
||||||
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
|
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
|
||||||
StringTag effectsLocation = dimensionData.get("effects");
|
StringTag effectsLocation = dimensionData.getStringTag("effects");
|
||||||
return effectsLocation != null && oldDimensions.contains(effectsLocation.getValue()) ?
|
return effectsLocation != null && oldDimensions.contains(effectsLocation.getValue()) ?
|
||||||
effectsLocation.getValue() : "minecraft:overworld";
|
effectsLocation.getValue() : "minecraft:overworld";
|
||||||
}
|
}
|
||||||
|
@ -84,20 +84,20 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(worldDataTrackerHandler(1));
|
handler(worldDataTrackerHandler(1));
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
|
||||||
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (CompoundTag biome : biomes) {
|
for (CompoundTag biome : biomes) {
|
||||||
CompoundTag biomeCompound = biome.get("element");
|
CompoundTag biomeCompound = biome.getCompoundTag("element");
|
||||||
StringTag category = biomeCompound.get("category");
|
StringTag category = biomeCompound.getStringTag("category");
|
||||||
if (category.getValue().equalsIgnoreCase("underground")) {
|
if (category.getValue().equalsIgnoreCase("underground")) {
|
||||||
category.setValue("none");
|
category.setValue("none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag dimensionRegistry = registry.get("minecraft:dimension_type");
|
CompoundTag dimensionRegistry = registry.getCompoundTag("minecraft:dimension_type");
|
||||||
ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
|
ListTag<CompoundTag> dimensions = dimensionRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (CompoundTag dimension : dimensions) {
|
for (CompoundTag dimension : dimensions) {
|
||||||
CompoundTag dimensionCompound = dimension.get("element");
|
CompoundTag dimensionCompound = dimension.getCompoundTag("element");
|
||||||
reduceExtendedHeight(dimensionCompound, false);
|
reduceExtendedHeight(dimensionCompound, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(worldDataTrackerHandler(1));
|
handler(worldDataTrackerHandler(1));
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
|
||||||
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag biome : biomes) {
|
for (final CompoundTag biome : biomes) {
|
||||||
final CompoundTag biomeCompound = biome.get("element");
|
final CompoundTag biomeCompound = biome.getCompoundTag("element");
|
||||||
final StringTag category = biomeCompound.get("category");
|
final StringTag category = biomeCompound.getStringTag("category");
|
||||||
if (category.getValue().equals("mountain")) {
|
if (category.getValue().equals("mountain")) {
|
||||||
category.setValue("extreme_hills");
|
category.setValue("extreme_hills");
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
|||||||
|
|
||||||
final ListTag<CompoundTag> chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
final ListTag<CompoundTag> chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
||||||
for (final CompoundTag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.get("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
defaultChatTypes.put(idTag.asInt(), chatType);
|
defaultChatTypes.put(idTag.asInt(), chatType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,11 +131,11 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
// Cache dimensions and find current dimension
|
// Cache dimensions and find current dimension
|
||||||
final String dimensionKey = wrapper.read(Type.STRING);
|
final String dimensionKey = wrapper.read(Type.STRING);
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag<CompoundTag> dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> dimensions = registry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (final CompoundTag dimension : dimensions) {
|
for (final CompoundTag dimension : dimensions) {
|
||||||
final StringTag nameTag = dimension.get("name");
|
final StringTag nameTag = dimension.getStringTag("name");
|
||||||
final CompoundTag dimensionData = dimension.get("element");
|
final CompoundTag dimensionData = dimension.getCompoundTag("element");
|
||||||
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy());
|
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy());
|
||||||
|
|
||||||
if (!found && nameTag.getValue().equals(dimensionKey)) {
|
if (!found && nameTag.getValue().equals(dimensionKey)) {
|
||||||
@ -148,10 +148,10 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add biome category and track biomes
|
// Add biome category and track biomes
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
|
||||||
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag biome : biomes.getValue()) {
|
for (final CompoundTag biome : biomes) {
|
||||||
final CompoundTag biomeCompound = biome.get("element");
|
final CompoundTag biomeCompound = biome.getCompoundTag("element");
|
||||||
biomeCompound.putString("category", "none");
|
biomeCompound.putString("category", "none");
|
||||||
}
|
}
|
||||||
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
||||||
@ -159,7 +159,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
// Cache and remove chat types
|
// Cache and remove chat types
|
||||||
final ListTag<CompoundTag> chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.get("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
dimensionRegistryStorage.addChatType(idTag.asInt(), chatType);
|
dimensionRegistryStorage.addChatType(idTag.asInt(), chatType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -81,10 +81,10 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
|
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
|
final CompoundTag dimensionsHolder = registry.getCompoundTag("minecraft:dimension_type");
|
||||||
final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> dimensions = dimensionsHolder.getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag dimension : dimensions) {
|
for (final CompoundTag dimension : dimensions) {
|
||||||
removeTagPrefix(dimension.get("element"));
|
removeTagPrefix(dimension.getCompoundTag("element"));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
|
||||||
@ -96,10 +96,9 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeTagPrefix(CompoundTag tag) {
|
private void removeTagPrefix(CompoundTag tag) {
|
||||||
final Tag infiniburnTag = tag.get("infiniburn");
|
final StringTag infiniburnTag = tag.getStringTag("infiniburn");
|
||||||
if (infiniburnTag instanceof StringTag) {
|
if (infiniburnTag != null) {
|
||||||
final StringTag infiniburn = (StringTag) infiniburnTag;
|
infiniburnTag.setValue(infiniburnTag.getValue().substring(1));
|
||||||
infiniburn.setValue(infiniburn.getValue().substring(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
|||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.get("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -67,11 +67,11 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
|||||||
registry.remove("minecraft:trim_material");
|
registry.remove("minecraft:trim_material");
|
||||||
registry.remove("minecraft:damage_type");
|
registry.remove("minecraft:damage_type");
|
||||||
|
|
||||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
|
||||||
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> biomes = biomeRegistry.getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag biomeTag : biomes) {
|
for (final CompoundTag biomeTag : biomes) {
|
||||||
final CompoundTag biomeData = biomeTag.get("element");
|
final CompoundTag biomeData = biomeTag.getCompoundTag("element");
|
||||||
final NumberTag hasPrecipitation = biomeData.get("has_precipitation");
|
final NumberTag hasPrecipitation = biomeData.getNumberTag("has_precipitation");
|
||||||
biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none");
|
biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -89,12 +89,12 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
|||||||
} else {
|
} else {
|
||||||
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
||||||
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
||||||
values = trimPatternRegistry.get("value");
|
values = trimPatternRegistry.getListTag("value", CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final CompoundTag entry : values) {
|
for (final CompoundTag entry : values) {
|
||||||
final CompoundTag element = entry.get("element");
|
final CompoundTag element = entry.getCompoundTag("element");
|
||||||
final StringTag templateItem = element.get("template_item");
|
final StringTag templateItem = element.getStringTag("template_item");
|
||||||
if (newTrimPatterns.contains(Key.stripMinecraftNamespace(templateItem.getValue()))) {
|
if (newTrimPatterns.contains(Key.stripMinecraftNamespace(templateItem.getValue()))) {
|
||||||
templateItem.setValue("minecraft:spire_armor_trim_smithing_template");
|
templateItem.setValue("minecraft:spire_armor_trim_smithing_template");
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class);
|
||||||
for (final CompoundTag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.get("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren