mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 02:25:19 +01:00
Merge remote-tracking branch 'origin/dev' into master
This commit is contained in:
commit
e45c82ee87
@ -81,12 +81,9 @@ public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, Clie
|
|||||||
if (!Via.getConfig().is1_12NBTArrayFix()) return;
|
if (!Via.getConfig().is1_12NBTArrayFix()) return;
|
||||||
try {
|
try {
|
||||||
JsonElement obj = Protocol1_9To1_8.FIX_JSON.transform(null, wrapper.passthrough(Type.COMPONENT).toString());
|
JsonElement obj = Protocol1_9To1_8.FIX_JSON.transform(null, wrapper.passthrough(Type.COMPONENT).toString());
|
||||||
if (!TranslateRewriter.toClient(obj, wrapper.user())) {
|
TranslateRewriter.toClient(obj, wrapper.user());
|
||||||
wrapper.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatItemRewriter.toClient(obj, wrapper.user());
|
ChatItemRewriter.toClient(obj, wrapper.user());
|
||||||
|
wrapper.set(Type.COMPONENT, 0, obj);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,93 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping;
|
||||||
|
|
||||||
public class TranslateRewriter {
|
public class TranslateRewriter {
|
||||||
|
|
||||||
public static boolean toClient(JsonElement element, UserConnection user) {
|
private final static ComponentRewriter achievementTextRewriter = new ComponentRewriter() {
|
||||||
|
@Override
|
||||||
|
protected void handleTranslate(JsonObject object, String translate) {
|
||||||
|
String text = AchievementTranslationMapping.get(translate);
|
||||||
|
if (text != null) {
|
||||||
|
object.addProperty("translate", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleHoverEvent(JsonObject hoverEvent) {
|
||||||
|
String action = hoverEvent.getAsJsonPrimitive("action").getAsString();
|
||||||
|
if (!action.equals("show_achievement")) {
|
||||||
|
super.handleHoverEvent(hoverEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = hoverEvent.getAsJsonPrimitive("value").getAsString();
|
||||||
|
if (AchievementTranslationMapping.get(value) == null) {
|
||||||
|
JsonObject invalidText = new JsonObject();
|
||||||
|
invalidText.addProperty("text", "Invalid statistic/achievement!");
|
||||||
|
invalidText.addProperty("color", "red");
|
||||||
|
hoverEvent.addProperty("action", "show_text");
|
||||||
|
hoverEvent.add("value", invalidText);
|
||||||
|
super.handleHoverEvent(hoverEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JsonObject newLine = new JsonObject();
|
||||||
|
newLine.addProperty("text", "\n");
|
||||||
|
JsonArray baseArray = new JsonArray();
|
||||||
|
baseArray.add("");
|
||||||
|
JsonObject namePart = new JsonObject();
|
||||||
|
JsonObject typePart = new JsonObject();
|
||||||
|
baseArray.add(namePart);
|
||||||
|
baseArray.add(newLine);
|
||||||
|
baseArray.add(typePart);
|
||||||
|
if (value.startsWith("achievement")) {
|
||||||
|
namePart.addProperty("translate", value);
|
||||||
|
namePart.addProperty("color", AchievementTranslationMapping.isSpecial(value) ? "dark_purple" : "green");
|
||||||
|
typePart.addProperty("translate", "stats.tooltip.type.achievement");
|
||||||
|
JsonObject description = new JsonObject();
|
||||||
|
typePart.addProperty("italic", true);
|
||||||
|
description.addProperty("translate", value + ".desc");
|
||||||
|
baseArray.add(newLine);
|
||||||
|
baseArray.add(description);
|
||||||
|
} else if (value.startsWith("stat")) {
|
||||||
|
namePart.addProperty("translate", value);
|
||||||
|
namePart.addProperty("color", "gray");
|
||||||
|
typePart.addProperty("translate", "stats.tooltip.type.statistic");
|
||||||
|
typePart.addProperty("italic", true);
|
||||||
|
}
|
||||||
|
hoverEvent.addProperty("action", "show_text");
|
||||||
|
hoverEvent.add("value", baseArray);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Via.getPlatform().getLogger().warning("Error rewriting show_achievement: " + hoverEvent);
|
||||||
|
e.printStackTrace();
|
||||||
|
JsonObject invalidText = new JsonObject();
|
||||||
|
invalidText.addProperty("text", "Invalid statistic/achievement!");
|
||||||
|
invalidText.addProperty("color", "red");
|
||||||
|
hoverEvent.addProperty("action", "show_text");
|
||||||
|
hoverEvent.add("value", invalidText);
|
||||||
|
}
|
||||||
|
super.handleHoverEvent(hoverEvent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void toClient(JsonElement element, UserConnection user) {
|
||||||
if (element instanceof JsonObject) {
|
if (element instanceof JsonObject) {
|
||||||
JsonObject obj = (JsonObject) element;
|
JsonObject obj = (JsonObject) element;
|
||||||
JsonElement translate = obj.get("translate");
|
JsonElement translate = obj.get("translate");
|
||||||
if (translate != null) {
|
if (translate != null) {
|
||||||
return !translate.getAsString().equals("chat.type.achievement");
|
if (translate.getAsString().startsWith("chat.type.achievement")) {
|
||||||
|
achievementTextRewriter.processText(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -0,0 +1,183 @@
|
|||||||
|
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1.data;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class AchievementTranslationMapping {
|
||||||
|
|
||||||
|
private static final Object2ObjectOpenHashMap<String, String> ACHIEVEMENTS = new Object2ObjectOpenHashMap<>(150, 1.0f);
|
||||||
|
private static final Set<String> SPECIAL_ACHIEVEMENTS = new HashSet<>(10);
|
||||||
|
|
||||||
|
static {
|
||||||
|
add("chat.type.achievement", "%s has just earned the achievement %s");
|
||||||
|
add("chat.type.achievement.taken", "%s has lost the achievement %s");
|
||||||
|
add("stats.tooltip.type.achievement", "Achievement");
|
||||||
|
add("stats.tooltip.type.statistic", "Statistic");
|
||||||
|
add("stat.generalButton", "General");
|
||||||
|
add("stat.blocksButton", "Blocks");
|
||||||
|
add("stat.itemsButton", "Items");
|
||||||
|
add("stat.mobsButton", "Mobs");
|
||||||
|
add("stat.used", "Times Used");
|
||||||
|
add("stat.mined", "Times Mined");
|
||||||
|
add("stat.depleted", "Times Depleted");
|
||||||
|
add("stat.crafted", "Times Crafted");
|
||||||
|
add("stat.entityKills", "You killed %s %s");
|
||||||
|
add("stat.entityKilledBy", "%s killed you %s time(s)");
|
||||||
|
add("stat.entityKills.none", "You have never killed %s");
|
||||||
|
add("stat.entityKilledBy.none", "You have never been killed by %s");
|
||||||
|
add("stat.startGame", "Times Played");
|
||||||
|
add("stat.createWorld", "Worlds Created");
|
||||||
|
add("stat.loadWorld", "Saves Loaded");
|
||||||
|
add("stat.joinMultiplayer", "Multiplayer Joins");
|
||||||
|
add("stat.leaveGame", "Games Quit");
|
||||||
|
add("stat.playOneMinute", "Minutes Played");
|
||||||
|
add("stat.timeSinceDeath", "Since Last Death");
|
||||||
|
add("stat.sneakTime", "Sneak Time");
|
||||||
|
add("stat.walkOneCm", "Distance Walked");
|
||||||
|
add("stat.crouchOneCm", "Distance Crouched");
|
||||||
|
add("stat.sprintOneCm", "Distance Sprinted");
|
||||||
|
add("stat.fallOneCm", "Distance Fallen");
|
||||||
|
add("stat.swimOneCm", "Distance Swum");
|
||||||
|
add("stat.flyOneCm", "Distance Flown");
|
||||||
|
add("stat.climbOneCm", "Distance Climbed");
|
||||||
|
add("stat.diveOneCm", "Distance Dove");
|
||||||
|
add("stat.minecartOneCm", "Distance by Minecart");
|
||||||
|
add("stat.boatOneCm", "Distance by Boat");
|
||||||
|
add("stat.pigOneCm", "Distance by Pig");
|
||||||
|
add("stat.horseOneCm", "Distance by Horse");
|
||||||
|
add("stat.aviateOneCm", "Distance by Elytra");
|
||||||
|
add("stat.jump", "Jumps");
|
||||||
|
add("stat.drop", "Items Dropped");
|
||||||
|
add("stat.dropped", "Dropped");
|
||||||
|
add("stat.pickup", "Picked Up");
|
||||||
|
add("stat.damageDealt", "Damage Dealt");
|
||||||
|
add("stat.damageTaken", "Damage Taken");
|
||||||
|
add("stat.deaths", "Number of Deaths");
|
||||||
|
add("stat.mobKills", "Mob Kills");
|
||||||
|
add("stat.animalsBred", "Animals Bred");
|
||||||
|
add("stat.playerKills", "Player Kills");
|
||||||
|
add("stat.fishCaught", "Fish Caught");
|
||||||
|
add("stat.treasureFished", "Treasure Fished");
|
||||||
|
add("stat.junkFished", "Junk Fished");
|
||||||
|
add("stat.talkedToVillager", "Talked to Villagers");
|
||||||
|
add("stat.tradedWithVillager", "Traded with Villagers");
|
||||||
|
add("stat.cakeSlicesEaten", "Cake Slices Eaten");
|
||||||
|
add("stat.cauldronFilled", "Cauldrons Filled");
|
||||||
|
add("stat.cauldronUsed", "Water Taken from Cauldron");
|
||||||
|
add("stat.armorCleaned", "Armor Pieces Cleaned");
|
||||||
|
add("stat.bannerCleaned", "Banners Cleaned");
|
||||||
|
add("stat.brewingstandInteraction", "Interactions with Brewing Stand");
|
||||||
|
add("stat.beaconInteraction", "Interactions with Beacon");
|
||||||
|
add("stat.dropperInspected", "Droppers Searched");
|
||||||
|
add("stat.hopperInspected", "Hoppers Searched");
|
||||||
|
add("stat.dispenserInspected", "Dispensers Searched");
|
||||||
|
add("stat.noteblockPlayed", "Note Blocks Played");
|
||||||
|
add("stat.noteblockTuned", "Note Blocks Tuned");
|
||||||
|
add("stat.flowerPotted", "Plants Potted");
|
||||||
|
add("stat.trappedChestTriggered", "Trapped Chests Triggered");
|
||||||
|
add("stat.enderchestOpened", "Ender Chests Opened");
|
||||||
|
add("stat.itemEnchanted", "Items Enchanted");
|
||||||
|
add("stat.recordPlayed", "Records Played");
|
||||||
|
add("stat.furnaceInteraction", "Interactions with Furnace");
|
||||||
|
add("stat.workbenchInteraction", "Interactions with Crafting Table");
|
||||||
|
add("stat.chestOpened", "Chests Opened");
|
||||||
|
add("stat.shulkerBoxOpened", "Shulker Boxes Opened");
|
||||||
|
add("stat.sleepInBed", "Times Slept in a Bed");
|
||||||
|
add("stat.mineBlock", "%1$s Mined");
|
||||||
|
add("stat.craftItem", "%1$s Crafted");
|
||||||
|
add("stat.useItem", "%1$s Used");
|
||||||
|
add("stat.breakItem", "%1$s Depleted");
|
||||||
|
add("achievement.get", "Achievement get!");
|
||||||
|
add("achievement.taken", "Taken!");
|
||||||
|
add("achievement.unknown", "???");
|
||||||
|
add("achievement.requires", "Requires '%1$s'");
|
||||||
|
add("achievement.openInventory", "Taking Inventory");
|
||||||
|
add("achievement.openInventory.desc", "Press 'E' to open your inventory");
|
||||||
|
add("achievement.mineWood", "Getting Wood");
|
||||||
|
add("achievement.mineWood.desc", "Attack a tree until a block of wood pops out");
|
||||||
|
add("achievement.buildWorkBench", "Benchmarking");
|
||||||
|
add("achievement.buildWorkBench.desc", "Craft a workbench with four blocks of planks");
|
||||||
|
add("achievement.buildPickaxe", "Time to Mine!");
|
||||||
|
add("achievement.buildPickaxe.desc", "Use planks and sticks to make a pickaxe");
|
||||||
|
add("achievement.buildFurnace", "Hot Topic");
|
||||||
|
add("achievement.buildFurnace.desc", "Construct a furnace out of eight cobblestone blocks");
|
||||||
|
add("achievement.acquireIron", "Acquire Hardware");
|
||||||
|
add("achievement.acquireIron.desc", "Smelt an iron ingot");
|
||||||
|
add("achievement.buildHoe", "Time to Farm!");
|
||||||
|
add("achievement.buildHoe.desc", "Use planks and sticks to make a hoe");
|
||||||
|
add("achievement.makeBread", "Bake Bread");
|
||||||
|
add("achievement.makeBread.desc", "Turn wheat into bread");
|
||||||
|
add("achievement.bakeCake", "The Lie");
|
||||||
|
add("achievement.bakeCake.desc", "Wheat, sugar, milk and eggs!");
|
||||||
|
add("achievement.buildBetterPickaxe", "Getting an Upgrade");
|
||||||
|
add("achievement.buildBetterPickaxe.desc", "Construct a better pickaxe");
|
||||||
|
addSpecial("achievement.overpowered", "Overpowered");
|
||||||
|
add("achievement.overpowered.desc", "Eat a Notch apple");
|
||||||
|
add("achievement.cookFish", "Delicious Fish");
|
||||||
|
add("achievement.cookFish.desc", "Catch and cook fish!");
|
||||||
|
addSpecial("achievement.onARail", "On A Rail");
|
||||||
|
add("achievement.onARail.desc", "Travel by minecart at least 1 km from where you started");
|
||||||
|
add("achievement.buildSword", "Time to Strike!");
|
||||||
|
add("achievement.buildSword.desc", "Use planks and sticks to make a sword");
|
||||||
|
add("achievement.killEnemy", "Monster Hunter");
|
||||||
|
add("achievement.killEnemy.desc", "Attack and destroy a monster");
|
||||||
|
add("achievement.killCow", "Cow Tipper");
|
||||||
|
add("achievement.killCow.desc", "Harvest some leather");
|
||||||
|
add("achievement.breedCow", "Repopulation");
|
||||||
|
add("achievement.breedCow.desc", "Breed two cows with wheat");
|
||||||
|
addSpecial("achievement.flyPig", "When Pigs Fly");
|
||||||
|
add("achievement.flyPig.desc", "Fly a pig off a cliff");
|
||||||
|
addSpecial("achievement.snipeSkeleton", "Sniper Duel");
|
||||||
|
add("achievement.snipeSkeleton.desc", "Kill a skeleton with an arrow from more than 50 meters");
|
||||||
|
add("achievement.diamonds", "DIAMONDS!");
|
||||||
|
add("achievement.diamonds.desc", "Acquire diamonds with your iron tools");
|
||||||
|
add("achievement.diamondsToYou", "Diamonds to you!");
|
||||||
|
add("achievement.diamondsToYou.desc", "Throw diamonds at another player");
|
||||||
|
add("achievement.portal", "We Need to Go Deeper");
|
||||||
|
add("achievement.portal.desc", "Build a portal to the Nether");
|
||||||
|
addSpecial("achievement.ghast", "Return to Sender");
|
||||||
|
add("achievement.ghast.desc", "Destroy a Ghast with a fireball");
|
||||||
|
add("achievement.blazeRod", "Into Fire");
|
||||||
|
add("achievement.blazeRod.desc", "Relieve a Blaze of its rod");
|
||||||
|
add("achievement.potion", "Local Brewery");
|
||||||
|
add("achievement.potion.desc", "Brew a potion");
|
||||||
|
addSpecial("achievement.theEnd", "The End?");
|
||||||
|
add("achievement.theEnd.desc", "Locate the End");
|
||||||
|
addSpecial("achievement.theEnd2", "The End.");
|
||||||
|
add("achievement.theEnd2.desc", "Defeat the Ender Dragon");
|
||||||
|
add("achievement.spawnWither", "The Beginning?");
|
||||||
|
add("achievement.spawnWither.desc", "Spawn the Wither");
|
||||||
|
add("achievement.killWither", "The Beginning.");
|
||||||
|
add("achievement.killWither.desc", "Kill the Wither");
|
||||||
|
addSpecial("achievement.fullBeacon", "Beaconator");
|
||||||
|
add("achievement.fullBeacon.desc", "Create a full beacon");
|
||||||
|
addSpecial("achievement.exploreAllBiomes", "Adventuring Time");
|
||||||
|
add("achievement.exploreAllBiomes.desc", "Discover all biomes");
|
||||||
|
add("achievement.enchantments", "Enchanter");
|
||||||
|
add("achievement.enchantments.desc", "Use a book, obsidian and diamonds to construct an enchantment table");
|
||||||
|
addSpecial("achievement.overkill", "Overkill");
|
||||||
|
add("achievement.overkill.desc", "Deal nine hearts of damage in a single hit");
|
||||||
|
add("achievement.bookcase", "Librarian");
|
||||||
|
add("achievement.bookcase.desc", "Build some bookshelves to improve your enchantment table");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void add(String key, String value) {
|
||||||
|
ACHIEVEMENTS.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addSpecial(String key, String value) {
|
||||||
|
add(key, value);
|
||||||
|
SPECIAL_ACHIEVEMENTS.add(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(String key) {
|
||||||
|
return ACHIEVEMENTS.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpecial(String key) {
|
||||||
|
return SPECIAL_ACHIEVEMENTS.contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,10 +24,7 @@ import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.*;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeData;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||||
@ -41,9 +38,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.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
|
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
|
||||||
|
|
||||||
@ -189,18 +184,22 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.read(Type.VAR_INT);
|
||||||
|
List<StatisticData> remappedStats = new ArrayList<>();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String name = wrapper.read(Type.STRING);
|
String name = wrapper.read(Type.STRING);
|
||||||
String[] split = name.split("\\.");
|
String[] split = name.split("\\.");
|
||||||
int categoryId = 0;
|
int categoryId = 0;
|
||||||
int newId = 0;
|
int newId = -1;
|
||||||
|
int value = wrapper.read(Type.VAR_INT);
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
// Custom types
|
// Custom types
|
||||||
categoryId = 8;
|
categoryId = 8;
|
||||||
Integer newIdRaw = StatisticMappings.statistics.get(name);
|
Integer newIdRaw = StatisticMappings.CUSTOM_STATS.get(name);
|
||||||
if (newIdRaw != null) {
|
if (newIdRaw != null) {
|
||||||
newId = newIdRaw;
|
newId = newIdRaw;
|
||||||
|
} else {
|
||||||
|
Via.getPlatform().getLogger().warning("Could not find 1.13 -> 1.12.2 statistic mapping for " + name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String category = split[1];
|
String category = split[1];
|
||||||
@ -232,10 +231,15 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (newId != -1)
|
||||||
|
remappedStats.add(new StatisticData(categoryId, newId, value));
|
||||||
|
}
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, categoryId); // category id
|
wrapper.write(Type.VAR_INT, remappedStats.size()); // size
|
||||||
wrapper.write(Type.VAR_INT, newId); // statistics id
|
for (StatisticData stat : remappedStats) {
|
||||||
wrapper.passthrough(Type.VAR_INT); // value
|
wrapper.write(Type.VAR_INT, stat.getCategoryId()); // category id
|
||||||
|
wrapper.write(Type.VAR_INT, stat.getNewId()); // statistics id
|
||||||
|
wrapper.write(Type.VAR_INT, stat.getValue()); // value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
|
public class StatisticData {
|
||||||
|
|
||||||
|
private final int categoryId;
|
||||||
|
private final int newId;
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
public StatisticData(int categoryId, int newId, int value) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
this.newId = newId;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCategoryId() {
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNewId() {
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,58 +5,93 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class StatisticMappings {
|
public class StatisticMappings {
|
||||||
|
|
||||||
public static final Map<String, Integer> statistics = new HashMap<>();
|
public static final Map<String, Integer> CUSTOM_STATS = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
statistics.put("stat.jump", 17);
|
CUSTOM_STATS.put("stat.leaveGame", 0);
|
||||||
statistics.put("stat.drop", 18);
|
CUSTOM_STATS.put("stat.playOneMinute", 1);
|
||||||
statistics.put("stat.deaths", 21);
|
CUSTOM_STATS.put("stat.timeSinceDeath", 2);
|
||||||
statistics.put("stat.mobKills", 22);
|
CUSTOM_STATS.put("stat.sneakTime", 4);
|
||||||
statistics.put("stat.pigOneCm", 14);
|
CUSTOM_STATS.put("stat.walkOneCm", 5);
|
||||||
statistics.put("stat.flyOneCm", 10);
|
CUSTOM_STATS.put("stat.crouchOneCm", 6);
|
||||||
statistics.put("stat.leaveGame", 0);
|
CUSTOM_STATS.put("stat.sprintOneCm", 7);
|
||||||
statistics.put("stat.diveOneCm", 11);
|
CUSTOM_STATS.put("stat.swimOneCm", 18);
|
||||||
statistics.put("stat.swimOneCm", 7);
|
CUSTOM_STATS.put("stat.fallOneCm", 9);
|
||||||
statistics.put("stat.fallOneCm", 8);
|
CUSTOM_STATS.put("stat.climbOneCm", 10);
|
||||||
statistics.put("stat.walkOneCm", 4);
|
CUSTOM_STATS.put("stat.flyOneCm", 11);
|
||||||
statistics.put("stat.boatOneCm", 13);
|
CUSTOM_STATS.put("stat.diveOneCm", 12);
|
||||||
statistics.put("stat.sneakTime", 3);
|
CUSTOM_STATS.put("stat.minecartOneCm", 13);
|
||||||
statistics.put("stat.horseOneCm", 15);
|
CUSTOM_STATS.put("stat.boatOneCm", 14);
|
||||||
statistics.put("stat.sleepInBed", 48);
|
CUSTOM_STATS.put("stat.pigOneCm", 15);
|
||||||
statistics.put("stat.fishCaught", 25);
|
CUSTOM_STATS.put("stat.horseOneCm", 16);
|
||||||
statistics.put("stat.climbOneCm", 9);
|
CUSTOM_STATS.put("stat.aviateOneCm", 17);
|
||||||
statistics.put("stat.aviateOneCm", 16);
|
CUSTOM_STATS.put("stat.jump", 19);
|
||||||
statistics.put("stat.crouchOneCm", 5);
|
CUSTOM_STATS.put("stat.drop", 20);
|
||||||
statistics.put("stat.sprintOneCm", 6);
|
CUSTOM_STATS.put("stat.damageDealt", 21);
|
||||||
statistics.put("stat.animalsBred", 23);
|
CUSTOM_STATS.put("stat.damageTaken", 22);
|
||||||
statistics.put("stat.chestOpened", 47);
|
CUSTOM_STATS.put("stat.deaths", 23);
|
||||||
statistics.put("stat.damageTaken", 20);
|
CUSTOM_STATS.put("stat.mobKills", 24);
|
||||||
statistics.put("stat.damageDealt", 19);
|
CUSTOM_STATS.put("stat.animalsBred", 25);
|
||||||
statistics.put("stat.playerKills", 24);
|
CUSTOM_STATS.put("stat.playerKills", 26);
|
||||||
statistics.put("stat.armorCleaned", 31);
|
CUSTOM_STATS.put("stat.fishCaught", 27);
|
||||||
statistics.put("stat.flowerPotted", 40);
|
CUSTOM_STATS.put("stat.talkedToVillager", 28);
|
||||||
statistics.put("stat.recordPlayed", 44);
|
CUSTOM_STATS.put("stat.tradedWithVillage", 29);
|
||||||
statistics.put("stat.cauldronUsed", 30);
|
CUSTOM_STATS.put("stat.cakeSlicesEaten", 30);
|
||||||
statistics.put("stat.bannerCleaned", 32);
|
CUSTOM_STATS.put("stat.cauldronFilled", 31);
|
||||||
statistics.put("stat.itemEnchanted", 43);
|
CUSTOM_STATS.put("stat.cauldronUsed", 32);
|
||||||
statistics.put("stat.playOneMinute", 1);
|
CUSTOM_STATS.put("stat.armorCleaned", 33);
|
||||||
statistics.put("stat.minecartOneCm", 12);
|
CUSTOM_STATS.put("stat.bannerCleaned", 34);
|
||||||
statistics.put("stat.timeSinceDeath", 2);
|
CUSTOM_STATS.put("stat.brewingstandInter", 35);
|
||||||
statistics.put("stat.cauldronFilled", 29);
|
CUSTOM_STATS.put("stat.beaconInteraction", 36);
|
||||||
statistics.put("stat.noteblockTuned", 39);
|
CUSTOM_STATS.put("stat.dropperInspected", 37);
|
||||||
statistics.put("stat.noteblockPlayed", 38);
|
CUSTOM_STATS.put("stat.hopperInspected", 38);
|
||||||
statistics.put("stat.cakeSlicesEaten", 28);
|
CUSTOM_STATS.put("stat.dispenserInspecte", 39);
|
||||||
statistics.put("stat.hopperInspected", 36);
|
CUSTOM_STATS.put("stat.noteblockPlayed", 40);
|
||||||
statistics.put("stat.shulkerBoxOpened", 49);
|
CUSTOM_STATS.put("stat.noteblockTuned", 41);
|
||||||
statistics.put("stat.talkedToVillager", 26);
|
CUSTOM_STATS.put("stat.flowerPotted", 42);
|
||||||
statistics.put("stat.enderchestOpened", 42);
|
CUSTOM_STATS.put("stat.trappedChestTriggered", 43);
|
||||||
statistics.put("stat.dropperInspected", 35);
|
CUSTOM_STATS.put("stat.enderchestOpened", 44);
|
||||||
statistics.put("stat.beaconInteraction", 34);
|
CUSTOM_STATS.put("stat.itemEnchanted", 45);
|
||||||
statistics.put("stat.furnaceInteraction", 45);
|
CUSTOM_STATS.put("stat.recordPlayed", 46);
|
||||||
statistics.put("stat.dispenserInspected", 37);
|
CUSTOM_STATS.put("stat.furnaceInteraction", 47);
|
||||||
statistics.put("stat.tradedWithVillager", 27);
|
CUSTOM_STATS.put("stat.craftingTableInteraction", 48);
|
||||||
statistics.put("stat.trappedChestTriggered", 41);
|
CUSTOM_STATS.put("stat.chestOpened", 49);
|
||||||
statistics.put("stat.brewingstandInteraction", 33);
|
CUSTOM_STATS.put("stat.sleepInBed", 50);
|
||||||
statistics.put("stat.craftingTableInteraction", 46);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user