From e3142b48698e7711696af4b88bb56ac88c06e081 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Tue, 22 Oct 2024 22:24:59 +0200 Subject: [PATCH] Add 1.21.2 support --- .../changeme/nbtapi/utils/DataFixerUtil.java | 1 + .../changeme/nbtapi/utils/MinecraftVersion.java | 3 ++- .../utils/nmsmappings/MojangToMapping.java | 16 ++++++++++++++++ .../dev/tr7zw/mappingsparser/MappingsParser.java | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/DataFixerUtil.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/DataFixerUtil.java index 74655a85b..db6a605a3 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/DataFixerUtil.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/DataFixerUtil.java @@ -30,6 +30,7 @@ public class DataFixerUtil { public static final int VERSION1_20_4 = 3700; public static final int VERSION1_20_5 = 3837; public static final int VERSION1_21 = 3953; + public static final int VERSION1_21_2 = 4080; @SuppressWarnings("unchecked") public static Object fixUpRawItemData(Object nbt, int fromVersion, int toVersion) diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java index c3f9b0df7..62fa0dc55 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java @@ -24,7 +24,7 @@ public enum MinecraftVersion { MC1_13_R1(1131), MC1_13_R2(1132), MC1_14_R1(1141), MC1_15_R1(1151), MC1_16_R1(1161), MC1_16_R2(1162), MC1_16_R3(1163), MC1_17_R1(1171), MC1_18_R1(1181, true), MC1_18_R2(1182, true), MC1_19_R1(1191, true), MC1_19_R2(1192, true), MC1_19_R3(1193, true), MC1_20_R1(1201, true), MC1_20_R2(1202, true), MC1_20_R3(1203, true), - MC1_20_R4(1204, true), MC1_21_R1(1211, true); + MC1_20_R4(1204, true), MC1_21_R1(1211, true), MC1_21_R2(1212, true); private static MinecraftVersion version; private static Boolean hasGsonSupport; @@ -57,6 +57,7 @@ public enum MinecraftVersion { this.put("1.20.6", MC1_20_R4); this.put("1.21", MC1_21_R1); this.put("1.21.1", MC1_21_R1); + this.put("1.21.2", MC1_21_R2); } }; diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/MojangToMapping.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/MojangToMapping.java index 820d280e0..74929a28c 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/MojangToMapping.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/MojangToMapping.java @@ -183,10 +183,26 @@ public class MojangToMapping { } }; + + @SuppressWarnings("serial") + private static Map MC1_21R2 = new HashMap() { + + { + putAll(MC1_21R1); + + put("net.minecraft.server.MinecraftServer#registryAccess()", "ba"); + put("net.minecraft.world.entity.Entity#getEncodeId()", "bK"); + put("net.minecraft.world.level.block.entity.BlockEntity#getBlockState()", "m"); + } + + }; + public static Map getMapping() { switch (MinecraftVersion.getVersion()) { + case MC1_21_R2: + return MC1_21R2; case MC1_21_R1: return MC1_21R1; case MC1_20_R4: diff --git a/mappings-parser/src/main/java/dev/tr7zw/mappingsparser/MappingsParser.java b/mappings-parser/src/main/java/dev/tr7zw/mappingsparser/MappingsParser.java index 5e767cece..31f59d8e6 100644 --- a/mappings-parser/src/main/java/dev/tr7zw/mappingsparser/MappingsParser.java +++ b/mappings-parser/src/main/java/dev/tr7zw/mappingsparser/MappingsParser.java @@ -24,7 +24,7 @@ public class MappingsParser { public static StringBuilder builder = new StringBuilder(); public static void main(String[] args) throws IOException { - File input = new File("minecraft_server.1.21.txt"); + File input = new File("minecraft_server.1.21.2.txt"); List lines = Files.readAllLines(input.toPath()); Map classes = new HashMap<>();