Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
tags
Dieser Commit ist enthalten in:
Ursprung
c650b5c0bb
Commit
f022a57b23
@ -25,6 +25,8 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTrac
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type.Particle1_13Type;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// Development of 1.13 support!
|
||||
public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
|
||||
@ -166,6 +168,37 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
wrapper.write(Type.VAR_INT, 0); // Root node index
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
|
||||
// Send tags packet
|
||||
wrapper.create(0x54, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags
|
||||
for (Map.Entry<String, int[]> tag : MappingData.blockTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT, tag.getValue().length);
|
||||
for (int id : tag.getValue()) {
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags
|
||||
for (Map.Entry<String, int[]> tag : MappingData.itemTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT, tag.getValue().length);
|
||||
for (int id : tag.getValue()) {
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags
|
||||
for (Map.Entry<String, int[]> tag : MappingData.fluidTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT, tag.getValue().length);
|
||||
for (int id : tag.getValue()) {
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
@ -13,6 +14,9 @@ import java.util.Map;
|
||||
public class MappingData {
|
||||
public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>();
|
||||
public static Map<Integer, Integer> oldToNewItems = new HashMap<>();
|
||||
public static Map<String, int[]> blockTags = new HashMap<>();
|
||||
public static Map<String, int[]> itemTags = new HashMap<>();
|
||||
public static Map<String, int[]> fluidTags = new HashMap<>();
|
||||
|
||||
public static void init() {
|
||||
JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
||||
@ -23,7 +27,9 @@ public class MappingData {
|
||||
mapIdentifiers(oldToNewBlocks, mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
|
||||
System.out.println("Loading item mapping...");
|
||||
mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items"));
|
||||
|
||||
loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags"));
|
||||
loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags"));
|
||||
loadTags(fluidTags, mapping1_13.getAsJsonObject("fluid_tags"));
|
||||
}
|
||||
|
||||
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
@ -47,6 +53,17 @@ public class MappingData {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void loadTags(Map<String, int[]> output, JsonObject newTags) {
|
||||
for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) {
|
||||
JsonArray ids = entry.getValue().getAsJsonArray();
|
||||
int[] idsArray = new int[ids.size()];
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
idsArray[i] = Integer.parseInt(ids.get(i).getAsString());
|
||||
}
|
||||
output.put(entry.getKey(), idsArray);
|
||||
}
|
||||
}
|
||||
|
||||
public static JsonObject loadData(String name) {
|
||||
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren