3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-03-09 12:57:55 +01:00
Ursprung a9bfda4568
Commit 3442cda8ce
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
13 geänderte Dateien mit 41 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -92,13 +92,13 @@ public class MappingDataBase implements MappingData {
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size()); particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
} }
final List<String> identifiers = unmappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()); final List<String> identifiers = unmappedParticles.stream().map(StringTag::getValue).collect(Collectors.toList());
final List<String> mappedIdentifiers = mappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()); final List<String> mappedIdentifiers = mappedParticles.stream().map(StringTag::getValue).collect(Collectors.toList());
this.particleMappings = new ParticleMappings(identifiers, mappedIdentifiers, particleMappings); this.particleMappings = new ParticleMappings(identifiers, mappedIdentifiers, particleMappings);
} }
} }
final CompoundTag tagsTag = data.get("tags"); final CompoundTag tagsTag = data.getCompoundTag("tags");
if (tagsTag != null) { if (tagsTag != null) {
this.tags = new EnumMap<>(RegistryType.class); this.tags = new EnumMap<>(RegistryType.class);
loadTags(RegistryType.ITEM, tagsTag); loadTags(RegistryType.ITEM, tagsTag);
@ -126,7 +126,7 @@ public class MappingDataBase implements MappingData {
} }
private void loadTags(final RegistryType type, final CompoundTag data) { private void loadTags(final RegistryType type, final CompoundTag data) {
final CompoundTag tag = data.get(type.resourceLocation()); final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
if (tag == null) { if (tag == null) {
return; return;
} }

Datei anzeigen

@ -158,22 +158,22 @@ public final class MappingDataLoader {
final AddConsumer<V> addConsumer, final AddConsumer<V> addConsumer,
final MappingsSupplier<M, V> mappingsSupplier final MappingsSupplier<M, V> mappingsSupplier
) { ) {
final CompoundTag tag = mappingsTag.get(key); final CompoundTag tag = mappingsTag.getCompoundTag(key);
if (tag == null) { if (tag == null) {
return null; return null;
} }
final ByteTag serializationStragetyTag = tag.get("id"); final ByteTag serializationStragetyTag = tag.getUnchecked("id");
final IntTag mappedSizeTag = tag.get("mappedSize"); final IntTag mappedSizeTag = tag.getUnchecked("mappedSize");
final byte strategy = serializationStragetyTag.asByte(); final byte strategy = serializationStragetyTag.asByte();
final V mappings; final V mappings;
if (strategy == DIRECT_ID) { if (strategy == DIRECT_ID) {
final IntArrayTag valuesTag = tag.get("val"); final IntArrayTag valuesTag = tag.getIntArrayTag("val");
return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt()); return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt());
} else if (strategy == SHIFTS_ID) { } else if (strategy == SHIFTS_ID) {
final IntArrayTag shiftsAtTag = tag.get("at"); final IntArrayTag shiftsAtTag = tag.getIntArrayTag("at");
final IntArrayTag shiftsTag = tag.get("to"); final IntArrayTag shiftsTag = tag.getIntArrayTag("to");
final IntTag sizeTag = tag.get("size"); final IntTag sizeTag = tag.getUnchecked("size");
final int[] shiftsAt = shiftsAtTag.getValue(); final int[] shiftsAt = shiftsAtTag.getValue();
final int[] shiftsTo = shiftsTag.getValue(); final int[] shiftsTo = shiftsTag.getValue();
final int size = sizeTag.asInt(); final int size = sizeTag.asInt();
@ -197,9 +197,9 @@ public final class MappingDataLoader {
} }
} }
} else if (strategy == CHANGES_ID) { } else if (strategy == CHANGES_ID) {
final IntArrayTag changesAtTag = tag.get("at"); final IntArrayTag changesAtTag = tag.getIntArrayTag("at");
final IntArrayTag valuesTag = tag.get("val"); final IntArrayTag valuesTag = tag.getIntArrayTag("val");
final IntTag sizeTag = tag.get("size"); final IntTag sizeTag = tag.getUnchecked("size");
final boolean fillBetween = tag.get("nofill") == null; final boolean fillBetween = tag.get("nofill") == null;
final int[] changesAt = changesAtTag.getValue(); final int[] changesAt = changesAtTag.getValue();
final int[] values = valuesTag.getValue(); final int[] values = valuesTag.getValue();
@ -219,7 +219,7 @@ public final class MappingDataLoader {
addConsumer.addTo(mappings, id, values[i]); addConsumer.addTo(mappings, id, values[i]);
} }
} else if (strategy == IDENTITY_ID) { } else if (strategy == IDENTITY_ID) {
final IntTag sizeTag = tag.get("size"); final IntTag sizeTag = tag.getUnchecked("size");
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt()); return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
} else { } else {
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy); throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
@ -240,8 +240,8 @@ public final class MappingDataLoader {
} }
return new FullMappingsBase( return new FullMappingsBase(
unmappedElements.getValue().stream().map(StringTag::getValue).collect(Collectors.toList()), unmappedElements.stream().map(StringTag::getValue).collect(Collectors.toList()),
mappedElements.getValue().stream().map(StringTag::getValue).collect(Collectors.toList()), mappedElements.stream().map(StringTag::getValue).collect(Collectors.toList()),
mappings mappings
); );
} }

Datei anzeigen

@ -114,7 +114,7 @@ public class WorldPackets {
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue()); UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
compoundTag.put("Target", new IntArrayTag(UUIDUtil.toIntArray(targetUuid))); compoundTag.put("Target", new IntArrayTag(UUIDUtil.toIntArray(targetUuid)));
} else if (id.equals("minecraft:skull") && compoundTag.getCompoundTag("Owner") != null) { } else if (id.equals("minecraft:skull") && compoundTag.getCompoundTag("Owner") != null) {
CompoundTag ownerTag = compoundTag.remove("Owner"); CompoundTag ownerTag = compoundTag.removeUnchecked("Owner");
Tag ownerUuidTag = ownerTag.remove("Id"); Tag ownerUuidTag = ownerTag.remove("Id");
if (ownerUuidTag instanceof StringTag) { if (ownerUuidTag instanceof StringTag) {
UUID ownerUuid = UUID.fromString(((StringTag) ownerUuidTag).getValue()); UUID ownerUuid = UUID.fromString(((StringTag) ownerUuidTag).getValue());

Datei anzeigen

@ -77,10 +77,10 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
map(Type.NAMED_COMPOUND_TAG); // Current dimension map(Type.NAMED_COMPOUND_TAG); // Current dimension
handler(wrapper -> { handler(wrapper -> {
// Add new dimension fields // Add new dimension fields
CompoundTag dimensionRegistry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0).get("minecraft:dimension_type"); CompoundTag dimensionRegistry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0).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");
addNewDimensionData(dimensionCompound); addNewDimensionData(dimensionCompound);
} }

Datei anzeigen

@ -69,10 +69,10 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
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) {
addTagPrefix(dimension.get("element")); addTagPrefix(dimension.getCompoundTag("element"));
} }
addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1)); addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));

Datei anzeigen

@ -88,7 +88,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
private static final CompoundTag CHAT_REGISTRY; private static final CompoundTag CHAT_REGISTRY;
static { static {
CHAT_REGISTRY = SNBT.deserializeCompoundTag(CHAT_REGISTRY_SNBT).get("minecraft:chat_type"); CHAT_REGISTRY = SNBT.deserializeCompoundTag(CHAT_REGISTRY_SNBT).getCompoundTag("minecraft:chat_type");
} }
public Protocol1_19_1To1_19() { public Protocol1_19_1To1_19() {
@ -224,7 +224,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
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);
} }

Datei anzeigen

@ -63,11 +63,11 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
final CompoundTag damageTypeRegistry = protocol.getMappingData().damageTypesRegistry(); final CompoundTag damageTypeRegistry = protocol.getMappingData().damageTypesRegistry();
registry.put("minecraft:damage_type", damageTypeRegistry); registry.put("minecraft:damage_type", damageTypeRegistry);
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 StringTag precipitation = biomeData.get("precipitation"); final StringTag precipitation = biomeData.getStringTag("precipitation");
final byte precipitationByte = precipitation.getValue().equals("none") ? (byte) 0 : 1; final byte precipitationByte = precipitation.getValue().equals("none") ? (byte) 0 : 1;
biomeData.put("has_precipitation", new ByteTag(precipitationByte)); biomeData.put("has_precipitation", new ByteTag(precipitationByte));
} }

Datei anzeigen

@ -39,7 +39,7 @@ public final class MappingData extends MappingDataBase {
protected void loadExtras(final CompoundTag daata) { protected void loadExtras(final CompoundTag daata) {
final ListTag<CompoundTag> chatTypes = MappingDataLoader.loadNBTFromFile("chat-types-1.19.nbt").getListTag("values", CompoundTag.class); final ListTag<CompoundTag> chatTypes = MappingDataLoader.loadNBTFromFile("chat-types-1.19.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);
} }
} }

Datei anzeigen

@ -80,7 +80,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
public static final CompoundTag CHAT_REGISTRY; public static final CompoundTag CHAT_REGISTRY;
static { static {
CHAT_REGISTRY = SNBT.deserializeCompoundTag(CHAT_REGISTRY_SNBT).get("minecraft:chat_type"); CHAT_REGISTRY = SNBT.deserializeCompoundTag(CHAT_REGISTRY_SNBT).getCompoundTag("minecraft:chat_type");
} }
public EntityPackets(final Protocol1_19To1_18_2 protocol) { public EntityPackets(final Protocol1_19To1_18_2 protocol) {
@ -213,7 +213,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size()); final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size()); final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size());
for (final CompoundTag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final CompoundTag element = dimension.get("element"); final CompoundTag element = dimension.getCompoundTag("element");
final String name = dimension.getStringTag("name").getValue(); final String name = dimension.getStringTag("name").getValue();
addMonsterSpawnData(element); addMonsterSpawnData(element);
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(name, new DimensionDataImpl(element));

Datei anzeigen

@ -76,11 +76,11 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
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 damageTypeRegistry = registry.get("minecraft:damage_type"); final CompoundTag damageTypeRegistry = registry.getCompoundTag("minecraft:damage_type");
final ListTag<CompoundTag> damageTypes = damageTypeRegistry.get("value"); final ListTag<CompoundTag> damageTypes = damageTypeRegistry.getListTag("value", CompoundTag.class);
int highestId = -1; int highestId = -1;
for (final CompoundTag damageType : damageTypes) { for (final CompoundTag damageType : damageTypes) {
final IntTag id = damageType.get("id"); final IntTag id = damageType.getUnchecked("id");
highestId = Math.max(highestId, id.asInt()); highestId = Math.max(highestId, id.asInt());
} }

Datei anzeigen

@ -172,15 +172,15 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_
final ListTag<StringTag> messages = new ListTag<>(StringTag.class); final ListTag<StringTag> messages = new ListTag<>(StringTag.class);
for (int i = 1; i < 5; i++) { for (int i = 1; i < 5; i++) {
final StringTag text = tag.remove("Text" + i); final Tag text = tag.remove("Text" + i);
messages.add(text != null ? text : new StringTag(ComponentUtil.emptyJsonComponentString())); messages.add(text instanceof StringTag ? (StringTag) text : new StringTag(ComponentUtil.emptyJsonComponentString()));
} }
frontText.put("messages", messages); frontText.put("messages", messages);
final ListTag<StringTag> filteredMessages = new ListTag<>(StringTag.class); final ListTag<StringTag> filteredMessages = new ListTag<>(StringTag.class);
for (int i = 1; i < 5; i++) { for (int i = 1; i < 5; i++) {
final StringTag text = tag.remove("FilteredText" + i); final Tag text = tag.remove("FilteredText" + i);
filteredMessages.add(text != null ? text : messages.get(i - 1)); filteredMessages.add(text instanceof StringTag ? (StringTag) text : messages.get(i - 1));
} }
if (!filteredMessages.equals(messages)) { if (!filteredMessages.equals(messages)) {
frontText.put("filtered_messages", filteredMessages); frontText.put("filtered_messages", filteredMessages);

Datei anzeigen

@ -448,8 +448,8 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
} }
public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) { public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) {
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome"); final CompoundTag biomeRegistry = registry.getCompoundTag("minecraft:worldgen/biome");
final ListTag<?> biomes = biomeRegistry.get("value"); final ListTag<?> biomes = biomeRegistry.getListTag("value");
tracker(connection).setBiomesSent(biomes.size()); tracker(connection).setBiomesSent(biomes.size());
} }
@ -468,7 +468,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
final ListTag<CompoundTag> dimensions = registry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class); final ListTag<CompoundTag> dimensions = registry.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class);
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size()); final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
for (final CompoundTag dimension : dimensions) { for (final CompoundTag dimension : dimensions) {
final CompoundTag element = dimension.get("element"); final CompoundTag element = dimension.getCompoundTag("element");
final String name = dimension.getStringTag("name").getValue(); final String name = dimension.getStringTag("name").getValue();
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(name, new DimensionDataImpl(element));
} }

Datei anzeigen

@ -5,7 +5,7 @@ metadata.format.version = "1.1"
gson = "2.10.1" gson = "2.10.1"
fastutil = "8.5.12" fastutil = "8.5.12"
flare = "2.0.1" flare = "2.0.1"
vianbt = "4.4.0" vianbt = "4.4.2"
mcstructs = "2.4.2" mcstructs = "2.4.2"
# Common provided # Common provided