Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Commit
752f039411
@ -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.storage.TabCompleteTracker;
|
||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type.Particle1_13Type;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type.Particle1_13Type;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
// Development of 1.13 support!
|
// Development of 1.13 support!
|
||||||
public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||||
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
|
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
|
wrapper.write(Type.VAR_INT, 0); // Root node index
|
||||||
}
|
}
|
||||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
}).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;
|
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
|
||||||
|
|
||||||
|
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.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
@ -13,6 +14,9 @@ import java.util.Map;
|
|||||||
public class MappingData {
|
public class MappingData {
|
||||||
public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>();
|
public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>();
|
||||||
public static Map<Integer, Integer> oldToNewItems = 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() {
|
public static void init() {
|
||||||
JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
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"));
|
mapIdentifiers(oldToNewBlocks, mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
|
||||||
System.out.println("Loading item mapping...");
|
System.out.println("Loading item mapping...");
|
||||||
mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items"));
|
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) {
|
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||||
@ -47,6 +53,17 @@ public class MappingData {
|
|||||||
return null;
|
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) {
|
public static JsonObject loadData(String name) {
|
||||||
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
||||||
InputStreamReader reader = new InputStreamReader(stream);
|
InputStreamReader reader = new InputStreamReader(stream);
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren