mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Minor cleanup in 1.13->1.13.1 protocol
This commit is contained in:
parent
df9508ff3c
commit
9dff193c09
@ -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;
|
||||
}
|
||||
|
@ -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<ClientboundPackets1_13, Clien
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
MetadataRewriter metadataRewriter = new MetadataRewriter1_13_1To1_13(this);
|
||||
new MetadataRewriter1_13_1To1_13(this);
|
||||
|
||||
EntityPackets.register(this);
|
||||
InventoryPackets.register(this);
|
||||
@ -123,46 +123,8 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < blocks.length; j++) {
|
||||
blocks[j] = getMappingData().getNewBlockId(blocks[j]);
|
||||
}
|
||||
}
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
items[j] = getMappingData().getNewItemId(items[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter(this, id -> {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user