3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00
Dieser Commit ist enthalten in:
Gerrygames 2018-11-08 13:43:38 +01:00
Ursprung b92f4070d4
Commit 9fac4f9de4
14 geänderte Dateien mit 21272 neuen und 57 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -67,7 +67,7 @@ public class ProtocolVersion {
register(v1_13 = new ProtocolVersion(393, "1.13")); register(v1_13 = new ProtocolVersion(393, "1.13"));
register(v1_13_1 = new ProtocolVersion(401, "1.13.1")); register(v1_13_1 = new ProtocolVersion(401, "1.13.1"));
register(v1_13_2 = new ProtocolVersion(404, "1.13.2")); register(v1_13_2 = new ProtocolVersion(404, "1.13.2"));
register(v1_14 = new ProtocolVersion(443, "1.14")); register(v1_14 = new ProtocolVersion(444, "1.14"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -29,18 +29,18 @@ public class MappingData {
JsonObject mapping1_12 = loadData("mapping-1.12.json"); JsonObject mapping1_12 = loadData("mapping-1.12.json");
JsonObject mapping1_13 = loadData("mapping-1.13.json"); JsonObject mapping1_13 = loadData("mapping-1.13.json");
Via.getPlatform().getLogger().info("Loading block mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks")); blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading item mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 item mapping...");
mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items")); mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items"));
Via.getPlatform().getLogger().info("Loading new tags..."); Via.getPlatform().getLogger().info("Loading new 1.13 tags...");
loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags")); loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags"));
loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags")); loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags"));
loadTags(fluidTags, mapping1_13.getAsJsonObject("fluid_tags")); loadTags(fluidTags, mapping1_13.getAsJsonObject("fluid_tags"));
Via.getPlatform().getLogger().info("Loading enchantments..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 enchantment mapping...");
loadEnchantments(oldEnchantmentsIds, mapping1_12.getAsJsonObject("enchantments")); loadEnchantments(oldEnchantmentsIds, mapping1_12.getAsJsonObject("enchantments"));
enchantmentMappings = new EnchantmentMappingByteArray(mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments")); enchantmentMappings = new EnchantmentMappingByteArray(mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments"));
Via.getPlatform().getLogger().info("Loading sound mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping...");
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds")); soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
} }

Datei anzeigen

@ -1,12 +1,14 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
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.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.PlayerPackets; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.PlayerPackets;
@ -15,6 +17,11 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker;
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;
public class Protocol1_14To1_13_2 extends Protocol { public class Protocol1_14To1_13_2 extends Protocol {
static {
MappingData.init();
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
InventoryPackets.register(this); InventoryPackets.register(this);
@ -247,17 +254,12 @@ public class Protocol1_14To1_13_2 extends Protocol {
} }
public static int getNewBlockStateId(int id) { public static int getNewBlockStateId(int id) {
if (id < 1121) return id; int newId = MappingData.blockMappings.getNewBlock(id);
else if (id < 3108) return id + 3; if (newId == -1) {
else if (id < 3278) return id + 163; Via.getPlatform().getLogger().warning("Missing 1.14 blockstate for 1.13.2 blockstate " + id);
else if (id < 3978) return id + 203; return 0;
else if (id < 3984) return id + 207; }
else if (id < 3988) return id + 197; return newId;
else if (id < 5284) return id + 203;
else if (id < 7300) return id + 206;
else if (id < 8591) return id + 212;
else if (id < 8595) return id + 226;
else return id + 2192;
} }
public static int getNewBlockId(int id) { public static int getNewBlockId(int id) {

Datei anzeigen

@ -0,0 +1,109 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
public class MappingData {
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
public static BlockMappings blockMappings;
public static void init() {
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");
JsonObject mapping1_14 = loadData("mapping-1.14.json");
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_13_2.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 item mapping...");
mapIdentifiers(oldToNewItems, mapping1_13_2.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"));
}
public static JsonObject loadData(String name) {
InputStream stream = MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
InputStreamReader reader = new InputStreamReader(stream);
try {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
}
}
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
}
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
private static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
public interface BlockMappings {
int getNewBlock(int old);
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew;
private BlockMappingsShortArray(JsonObject mapping1_13_2, JsonObject mapping1_14) {
oldToNew = new short[mapping1_13_2.entrySet().size()];
Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14);
}
@Override
public int getNewBlock(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
}
}
}

Datei anzeigen

@ -1,12 +1,14 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
public class InventoryPackets { public class InventoryPackets {
@ -201,17 +203,12 @@ public class InventoryPackets {
} }
public static int getNewItemId(int id) { public static int getNewItemId(int id) {
if (id < 108) return id; Integer newId = MappingData.oldToNewItems.get(id);
else if (id < 119) return id + 3; if (newId == null) {
else if (id < 460) return id + 4; Via.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
else if (id < 542) return id + 43; return 1;
else if (id < 561) return id + 48; }
else if (id < 593) return id + 49; return newId;
else if (id < 641) return id + 53;
else if (id < 657) return id + 54;
else if (id < 662) return id + 55;
else if (id < 665) return id + 56;
else return id + 57;
} }
public static void toServer(Item item) { public static void toServer(Item item) {
@ -220,27 +217,7 @@ public class InventoryPackets {
} }
public static int getOldItemId(int id) { public static int getOldItemId(int id) {
if (id < 108) return id; Integer oldId = MappingData.oldToNewItems.inverse().get(id);
else if (id < 111) return 1; return oldId != null ? oldId : 1;
else if (id < 122) return id - 3;
else if (id < 123) return 1;
else if (id < 464) return id - 4;
else if (id < 503) return 1;
else if (id < 585) return id - 43;
else if (id < 590) return 1;
else if (id < 609) return id - 48;
else if (id < 610) return 1;
else if (id < 642) return id - 49;
else if (id < 646) return 1;
else if (id < 694) return id - 53;
else if (id < 695) return 1;
else if (id < 711) return id - 54;
else if (id < 712) return 1;
else if (id < 717) return id - 55;
else if (id < 718) return 1;
else if (id < 721) return id - 56;
else if (id < 722) return 1;
else if (id < 847) return id - 57;
else return 1;
} }
} }

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name> <name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>viaversion-parent</name> <name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.6.1-18w44a</version> <version>1.6.1-18w45a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>