From 9dff193c09289368674a5d0a8a3a2a359ea486b8 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 9 Sep 2020 11:25:45 +0200 Subject: [PATCH] Minor cleanup in 1.13->1.13.1 protocol --- .../api/data/MappingDataLoader.java | 8 ++-- .../Protocol1_13_1To1_13.java | 46 ++----------------- .../packets/InventoryPackets.java | 11 +---- .../data/StatisticMappings.java | 2 +- 4 files changed, 10 insertions(+), 57 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java b/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java index 01cd57eda..cf731a942 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java +++ b/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java @@ -161,12 +161,12 @@ public class MappingDataLoader { public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) { Object2IntMap newIdentifierMap = MappingDataLoader.arrayToMap(newIdentifiers); for (int i = 0; i < oldIdentifiers.size(); i++) { - JsonElement oldIfentifier = oldIdentifiers.get(i); - int mappedId = newIdentifierMap.getInt(oldIfentifier.getAsString()); + JsonElement oldIdentifier = oldIdentifiers.get(i); + int mappedId = newIdentifierMap.getInt(oldIdentifier.getAsString()); if (mappedId == -1) { // Search in diff mappings if (diffIdentifiers != null) { - JsonElement diffElement = diffIdentifiers.get(oldIfentifier.getAsString()); + JsonElement diffElement = diffIdentifiers.get(oldIdentifier.getAsString()); if (diffElement != null) { String mappedName = diffElement.getAsString(); if (mappedName.isEmpty()) continue; // "empty" remaps @@ -176,7 +176,7 @@ public class MappingDataLoader { } if (mappedId == -1) { if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("No key for " + oldIfentifier + " :( "); + Via.getPlatform().getLogger().warning("No key for " + oldIdentifier + " :( "); } continue; } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java index 8e95b9eef..f680b6f61 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java @@ -8,8 +8,8 @@ import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.ValueTransformer; -import us.myles.ViaVersion.api.rewriters.MetadataRewriter; import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; +import us.myles.ViaVersion.api.rewriters.TagRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.EntityPackets; @@ -30,7 +30,7 @@ public class Protocol1_13_1To1_13 extends Protocol { - int newId = id; - if (newId > 22) { - newId += 2; - } - if (newId > 25) { - newId += 3; - } - if (newId > 40) { - newId++; - } - return newId; - }).register(ClientboundPackets1_13.STATISTICS); + new TagRewriter(this, null).register(ClientboundPackets1_13.TAGS); + new StatisticsRewriter(this, null).register(ClientboundPackets1_13.STATISTICS); } @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java index a55f06c40..2cb083811 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java @@ -19,16 +19,7 @@ public class InventoryPackets { itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM); itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY); itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM); - - protocol.registerOutgoing(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() { - @Override - public void registerMap() { - handler(wrapper -> { - int itemId = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId)); - }); - } - }); + itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN); protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/StatisticMappings.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/StatisticMappings.java index 6c9342543..94cbd445b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/StatisticMappings.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/StatisticMappings.java @@ -35,7 +35,7 @@ public class StatisticMappings { CUSTOM_STATS.put("stat.playerKills", 26); CUSTOM_STATS.put("stat.fishCaught", 27); CUSTOM_STATS.put("stat.talkedToVillager", 28); - CUSTOM_STATS.put("stat.tradedWithVillage", 29); + CUSTOM_STATS.put("stat.tradedWithVillager", 29); CUSTOM_STATS.put("stat.cakeSlicesEaten", 30); CUSTOM_STATS.put("stat.cauldronFilled", 31); CUSTOM_STATS.put("stat.cauldronUsed", 32);