mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-21 17:45:36 +01:00
Fix tag related issues to prepare for 1.21.2
- Inline tag values in 1.21 enchantments - Fix TagRewriter addTags if the server doesn't send values for a registry - Send the tags packet in 1.12->1.13 before the play login packet to fix tracking in 1.20->1.20.2
This commit is contained in:
parent
81682f4921
commit
50084c112d
@ -34,6 +34,7 @@ import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
@ -145,7 +146,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}).scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
||||
// Send tags packet
|
||||
w.create(ClientboundPackets1_13.UPDATE_TAGS, wrapper -> {
|
||||
final PacketWrapper tagsPacket = w.create(ClientboundPackets1_13.UPDATE_TAGS, wrapper -> {
|
||||
wrapper.write(Types.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags
|
||||
for (Map.Entry<String, int[]> tag : MAPPINGS.getBlockTags().entrySet()) {
|
||||
wrapper.write(Types.STRING, tag.getKey());
|
||||
@ -164,7 +165,13 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.getValue().clone());
|
||||
}
|
||||
}).scheduleSend(Protocol1_12_2To1_13.class);
|
||||
});
|
||||
if (w.user().getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_2)) {
|
||||
// Make sure it's included in the configuration packets
|
||||
tagsPacket.send(Protocol1_12_2To1_13.class);
|
||||
} else {
|
||||
tagsPacket.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -286,6 +286,7 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol<ClientboundPa
|
||||
tagRewriter.renameTag(RegistryType.ITEM, "minecraft:axolotl_tempt_items", "minecraft:axolotl_food");
|
||||
tagRewriter.removeTag(RegistryType.ITEM, "minecraft:tools");
|
||||
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:badlands_terracotta");
|
||||
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:enchantable/mace");
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
@ -217,6 +217,11 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
||||
tagRewriter.addEmptyTags(RegistryType.ENTITY, "minecraft:can_turn_in_boats", "minecraft:deflects_projectiles", "minecraft:immune_to_infested",
|
||||
"minecraft:immune_to_oozing", "minecraft:no_anger_from_wind_charge");
|
||||
tagRewriter.addTag(RegistryType.ENCHANTMENT, "minecraft:curse", 10, 41); // Binding and vanishing curse
|
||||
// Add other enchantment tags empty
|
||||
tagRewriter.addEmptyTags(RegistryType.ENCHANTMENT, "double_trade_price", "in_enchanting_table", "non_treasure", "on_mob_spawn_equipment", "on_random_loot",
|
||||
"on_traded_equipment", "prevents_bee_spawns_when_mining", "prevents_decorated_pot_shattering", "prevents_ice_melting", "prevents_infested_spawns", "smelts_loot",
|
||||
"tooltip_order", "tradeable", "treasure", "exclusive_set/armor", "exclusive_set/boots", "exclusive_set/bow", "exclusive_set/crossbow", "exclusive_set/damage",
|
||||
"exclusive_set/mining", "exclusive_set/riptide");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -143,11 +144,14 @@ public class TagRewriter<C extends ClientboundPacketType> implements com.viavers
|
||||
|
||||
public void handleGeneric(final PacketWrapper wrapper) {
|
||||
final int length = wrapper.passthrough(Types.VAR_INT);
|
||||
int editedLength = length;
|
||||
int finalLength = length;
|
||||
final Set<RegistryType> readTypes = EnumSet.noneOf(RegistryType.class);
|
||||
for (int i = 0; i < length; i++) {
|
||||
final String registryKey = wrapper.read(Types.STRING);
|
||||
if (toRemoveRegistries.contains(Key.stripMinecraftNamespace(registryKey))) {
|
||||
wrapper.set(Types.VAR_INT, 0, --editedLength);
|
||||
final String strippedKey = Key.stripMinecraftNamespace(registryKey);
|
||||
if (toRemoveRegistries.contains(strippedKey)) {
|
||||
finalLength--;
|
||||
|
||||
final int tagsSize = wrapper.read(Types.VAR_INT);
|
||||
for (int j = 0; j < tagsSize; j++) {
|
||||
wrapper.read(Types.STRING);
|
||||
@ -157,7 +161,29 @@ public class TagRewriter<C extends ClientboundPacketType> implements com.viavers
|
||||
}
|
||||
|
||||
wrapper.write(Types.STRING, registryKey);
|
||||
handle(wrapper, Key.stripMinecraftNamespace(registryKey));
|
||||
|
||||
final RegistryType type = RegistryType.getByKey(registryKey);
|
||||
if (type != null) {
|
||||
handle(wrapper, type);
|
||||
readTypes.add(type);
|
||||
} else {
|
||||
handle(wrapper, null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (final Map.Entry<RegistryType, List<TagData>> entry : toAdd.entrySet()) {
|
||||
if (readTypes.contains(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Registry wasn't present in the packet, add them here
|
||||
wrapper.write(Types.STRING, entry.getKey().resourceLocation());
|
||||
appendNewTags(wrapper, entry.getKey());
|
||||
finalLength++;
|
||||
}
|
||||
|
||||
if (length != finalLength) {
|
||||
wrapper.set(Types.VAR_INT, 0, finalLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user