fixed 1.13 -> 1.12.2 statistics remapping

This commit is contained in:
RK_01 2020-08-12 16:39:01 +02:00
parent dfc4652da7
commit 70d08dfc6f
2 changed files with 104 additions and 61 deletions

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.md_5.bungee.api.ChatColor;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Triple;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_13Types;
@ -41,9 +42,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTra
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.util.GsonUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.*;
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
@ -189,18 +188,22 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int size = wrapper.passthrough(Type.VAR_INT);
int size = wrapper.read(Type.VAR_INT);
List<Triple<Integer, Integer, Integer>> remappedStats = new ArrayList<>();
for (int i = 0; i < size; i++) {
String name = wrapper.read(Type.STRING);
String[] split = name.split("\\.");
int categoryId = 0;
int newId = 0;
int newId = -1;
int value = wrapper.read(Type.VAR_INT);
if (split.length == 2) {
// Custom types
categoryId = 8;
Integer newIdRaw = StatisticMappings.statistics.get(name);
Integer newIdRaw = StatisticMappings.CUSTOM_STATS.get(name);
if (newIdRaw != null) {
newId = newIdRaw;
} else {
Via.getPlatform().getLogger().warning("Could not find 1.13 -> 1.12.2 statistic mapping for " + name);
}
} else {
String category = split[1];
@ -232,10 +235,15 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
break;
}
}
if (newId != -1)
remappedStats.add(new Triple<>(categoryId, newId, value));
}
wrapper.write(Type.VAR_INT, categoryId); // category id
wrapper.write(Type.VAR_INT, newId); // statistics id
wrapper.passthrough(Type.VAR_INT); // value
wrapper.write(Type.VAR_INT, remappedStats.size()); // size
for (Triple<Integer, Integer, Integer> stat : remappedStats) {
wrapper.write(Type.VAR_INT, stat.getFirst()); // category id
wrapper.write(Type.VAR_INT, stat.getSecond()); // statistics id
wrapper.write(Type.VAR_INT, stat.getThird()); // value
}
}
});

View File

@ -5,58 +5,93 @@ import java.util.Map;
public class StatisticMappings {
public static final Map<String, Integer> statistics = new HashMap<>();
public static final Map<String, Integer> CUSTOM_STATS = new HashMap<>();
static {
statistics.put("stat.jump", 17);
statistics.put("stat.drop", 18);
statistics.put("stat.deaths", 21);
statistics.put("stat.mobKills", 22);
statistics.put("stat.pigOneCm", 14);
statistics.put("stat.flyOneCm", 10);
statistics.put("stat.leaveGame", 0);
statistics.put("stat.diveOneCm", 11);
statistics.put("stat.swimOneCm", 7);
statistics.put("stat.fallOneCm", 8);
statistics.put("stat.walkOneCm", 4);
statistics.put("stat.boatOneCm", 13);
statistics.put("stat.sneakTime", 3);
statistics.put("stat.horseOneCm", 15);
statistics.put("stat.sleepInBed", 48);
statistics.put("stat.fishCaught", 25);
statistics.put("stat.climbOneCm", 9);
statistics.put("stat.aviateOneCm", 16);
statistics.put("stat.crouchOneCm", 5);
statistics.put("stat.sprintOneCm", 6);
statistics.put("stat.animalsBred", 23);
statistics.put("stat.chestOpened", 47);
statistics.put("stat.damageTaken", 20);
statistics.put("stat.damageDealt", 19);
statistics.put("stat.playerKills", 24);
statistics.put("stat.armorCleaned", 31);
statistics.put("stat.flowerPotted", 40);
statistics.put("stat.recordPlayed", 44);
statistics.put("stat.cauldronUsed", 30);
statistics.put("stat.bannerCleaned", 32);
statistics.put("stat.itemEnchanted", 43);
statistics.put("stat.playOneMinute", 1);
statistics.put("stat.minecartOneCm", 12);
statistics.put("stat.timeSinceDeath", 2);
statistics.put("stat.cauldronFilled", 29);
statistics.put("stat.noteblockTuned", 39);
statistics.put("stat.noteblockPlayed", 38);
statistics.put("stat.cakeSlicesEaten", 28);
statistics.put("stat.hopperInspected", 36);
statistics.put("stat.shulkerBoxOpened", 49);
statistics.put("stat.talkedToVillager", 26);
statistics.put("stat.enderchestOpened", 42);
statistics.put("stat.dropperInspected", 35);
statistics.put("stat.beaconInteraction", 34);
statistics.put("stat.furnaceInteraction", 45);
statistics.put("stat.dispenserInspected", 37);
statistics.put("stat.tradedWithVillager", 27);
statistics.put("stat.trappedChestTriggered", 41);
statistics.put("stat.brewingstandInteraction", 33);
statistics.put("stat.craftingTableInteraction", 46);
CUSTOM_STATS.put("stat.leaveGame", 0);
CUSTOM_STATS.put("stat.playOneMinute", 1);
CUSTOM_STATS.put("stat.timeSinceDeath", 2);
CUSTOM_STATS.put("stat.sneakTime", 4);
CUSTOM_STATS.put("stat.walkOneCm", 5);
CUSTOM_STATS.put("stat.crouchOneCm", 6);
CUSTOM_STATS.put("stat.sprintOneCm", 7);
CUSTOM_STATS.put("stat.swimOneCm", 18);
CUSTOM_STATS.put("stat.fallOneCm", 9);
CUSTOM_STATS.put("stat.climbOneCm", 10);
CUSTOM_STATS.put("stat.flyOneCm", 11);
CUSTOM_STATS.put("stat.diveOneCm", 12);
CUSTOM_STATS.put("stat.minecartOneCm", 13);
CUSTOM_STATS.put("stat.boatOneCm", 14);
CUSTOM_STATS.put("stat.pigOneCm", 15);
CUSTOM_STATS.put("stat.horseOneCm", 16);
CUSTOM_STATS.put("stat.aviateOneCm", 17);
CUSTOM_STATS.put("stat.jump", 19);
CUSTOM_STATS.put("stat.drop", 20);
CUSTOM_STATS.put("stat.damageDealt", 21);
CUSTOM_STATS.put("stat.damageTaken", 22);
CUSTOM_STATS.put("stat.deaths", 23);
CUSTOM_STATS.put("stat.mobKills", 24);
CUSTOM_STATS.put("stat.animalsBred", 25);
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.cakeSlicesEaten", 30);
CUSTOM_STATS.put("stat.cauldronFilled", 31);
CUSTOM_STATS.put("stat.cauldronUsed", 32);
CUSTOM_STATS.put("stat.armorCleaned", 33);
CUSTOM_STATS.put("stat.bannerCleaned", 34);
CUSTOM_STATS.put("stat.brewingstandInter", 35);
CUSTOM_STATS.put("stat.beaconInteraction", 36);
CUSTOM_STATS.put("stat.dropperInspected", 37);
CUSTOM_STATS.put("stat.hopperInspected", 38);
CUSTOM_STATS.put("stat.dispenserInspecte", 39);
CUSTOM_STATS.put("stat.noteblockPlayed", 40);
CUSTOM_STATS.put("stat.noteblockTuned", 41);
CUSTOM_STATS.put("stat.flowerPotted", 42);
CUSTOM_STATS.put("stat.trappedChestTriggered", 43);
CUSTOM_STATS.put("stat.enderchestOpened", 44);
CUSTOM_STATS.put("stat.itemEnchanted", 45);
CUSTOM_STATS.put("stat.recordPlayed", 46);
CUSTOM_STATS.put("stat.furnaceInteraction", 47);
CUSTOM_STATS.put("stat.craftingTableInteraction", 48);
CUSTOM_STATS.put("stat.chestOpened", 49);
CUSTOM_STATS.put("stat.sleepInBed", 50);
CUSTOM_STATS.put("stat.shulkerBoxOpened", 51);
CUSTOM_STATS.put("achievement.openInventory", -1);
CUSTOM_STATS.put("achievement.mineWood", -1);
CUSTOM_STATS.put("achievement.buildWorkBench", -1);
CUSTOM_STATS.put("achievement.buildPickaxe", -1);
CUSTOM_STATS.put("achievement.buildFurnace", -1);
CUSTOM_STATS.put("achievement.acquireIron", -1);
CUSTOM_STATS.put("achievement.buildHoe", -1);
CUSTOM_STATS.put("achievement.makeBread", -1);
CUSTOM_STATS.put("achievement.bakeCake", -1);
CUSTOM_STATS.put("achievement.buildBetterPickaxe", -1);
CUSTOM_STATS.put("achievement.cookFish", -1);
CUSTOM_STATS.put("achievement.onARail", -1);
CUSTOM_STATS.put("achievement.buildSword", -1);
CUSTOM_STATS.put("achievement.killEnemy", -1);
CUSTOM_STATS.put("achievement.killCow", -1);
CUSTOM_STATS.put("achievement.flyPig", -1);
CUSTOM_STATS.put("achievement.snipeSkeleton", -1);
CUSTOM_STATS.put("achievement.diamonds", -1);
CUSTOM_STATS.put("achievement.diamondsToYou", -1);
CUSTOM_STATS.put("achievement.portal", -1);
CUSTOM_STATS.put("achievement.ghast", -1);
CUSTOM_STATS.put("achievement.blazeRod", -1);
CUSTOM_STATS.put("achievement.potion", -1);
CUSTOM_STATS.put("achievement.theEnd", -1);
CUSTOM_STATS.put("achievement.theEnd2", -1);
CUSTOM_STATS.put("achievement.enchantments", -1);
CUSTOM_STATS.put("achievement.overkill", -1);
CUSTOM_STATS.put("achievement.bookcase", -1);
CUSTOM_STATS.put("achievement.breedCow", -1);
CUSTOM_STATS.put("achievement.spawnWither", -1);
CUSTOM_STATS.put("achievement.killWither", -1);
CUSTOM_STATS.put("achievement.fullBeacon", -1);
CUSTOM_STATS.put("achievement.exploreAllBiomes", -1);
CUSTOM_STATS.put("achievement.overpowered", -1);
}
}