3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Handle 1.13->1.12.2 (general) statistics

Dieser Commit ist enthalten in:
KennyTV 2020-01-15 22:53:34 +01:00
Ursprung 9d3bec1aa1
Commit 8878a18108
3 geänderte Dateien mit 57 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -50,7 +50,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
out(State.PLAY, 0x07, 0x07, cancel()); // Statistics TODO MODIFIED
out(State.PLAY, 0x0E, 0x0F); // Chat Message (clientbound)
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound)

Datei anzeigen

@ -16,14 +16,17 @@ import nl.matsv.viabackwards.api.data.VBMappings;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.gson.JsonPrimitive;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class BackwardsMappings {
public static final Map<Integer, String> statisticMappings = new HashMap<>();
public static BlockMappingsShortArray blockMappings;
public static Mappings soundMappings;
@ -36,6 +39,10 @@ public class BackwardsMappings {
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 sound mapping...");
soundMappings = new VBMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds"));
for (Map.Entry<String, Integer> entry : StatisticMappings.statistics.entrySet()) {
statisticMappings.put(entry.getValue(), entry.getKey());
}
}
// Has lots of compat layers, so we can't use the default Via method

Datei anzeigen

@ -4,6 +4,7 @@ import com.google.common.base.Joiner;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.rewriters.Rewriter;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
import nl.matsv.viabackwards.utils.ChatUtil;
@ -478,6 +479,55 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
});
}
});
// Statistics
protocol.out(State.PLAY, 0x07, 0x07, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int size = wrapper.get(Type.VAR_INT, 0);
int newSize = size;
for (int i = 0; i < size; i++) {
int categoryId = wrapper.read(Type.VAR_INT);
int statisticId = wrapper.read(Type.VAR_INT);
String name = "";
//TODO categories 0-7 (items, blocks, entities) - probably not feasible
switch (categoryId) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
wrapper.read(Type.VAR_INT); // remove value
newSize--;
continue;
case 8:
name = BackwardsMappings.statisticMappings.get(statisticId);
if (name == null) {
wrapper.read(Type.VAR_INT);
newSize--;
continue;
}
break;
}
wrapper.write(Type.STRING, name); // string id
wrapper.passthrough(Type.VAR_INT); // value
}
if (newSize != size)
wrapper.set(Type.VAR_INT, 0, newSize);
}
});
}
});
}
@Override