This commit is contained in:
Nassim Jahnke 2024-12-03 21:11:09 +01:00
parent 2331dad0a0
commit dc74c6f19e
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 414 additions and 453 deletions

View File

@ -196,10 +196,10 @@ index 0000000000000000000000000000000000000000..a27d3d41109271834b6c37fa22d4b80d
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..056801570c6756a4b484633d79080aed740832a8
index 0000000000000000000000000000000000000000..9a5cdd68bf03c3e126601126f576ce57d4d1ac8c
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
@@ -0,0 +1,440 @@
@@ -0,0 +1,445 @@
+package ca.spottedleaf.dataconverter.minecraft;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
@ -451,7 +451,12 @@ index 0000000000000000000000000000000000000000..056801570c6756a4b484633d79080aed
+ 4067,
+ 4068,
+ 4081,
+ // All up to 1.21.3
+ 4173,
+ 4175,
+ 4176,
+ 4180,
+ 4181
+ // All up to 1.21.4-pre2
+ };
+ Arrays.sort(converterVersions);
+
@ -642,10 +647,10 @@ index 0000000000000000000000000000000000000000..056801570c6756a4b484633d79080aed
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
new file mode 100644
index 0000000000000000000000000000000000000000..aaa45b3f97b4e67ca04ad9739d3f0197bec46671
index 0000000000000000000000000000000000000000..5e345b961186325496d63057cbb4c9487f87bdf4
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
@@ -0,0 +1,558 @@
@@ -0,0 +1,563 @@
+package ca.spottedleaf.dataconverter.minecraft;
+
+@SuppressWarnings("unused")
@ -1201,6 +1206,11 @@ index 0000000000000000000000000000000000000000..aaa45b3f97b4e67ca04ad9739d3f0197
+ public static final int V1_21_2_RC2 = 4079;
+ public static final int V1_21_2 = 4080;
+ public static final int V1_21_3 = 4082;
+ public static final int V24W44A = 4174;
+ public static final int V24W45A = 4177;
+ public static final int V24W46A = 4178;
+ public static final int V1_21_4_PRE1 = 4179;
+ public static final int V1_21_4_PRE2 = 4182;
+
+ private MCVersions() {}
+}
@ -9339,10 +9349,10 @@ index 0000000000000000000000000000000000000000..075574f33476882ddc6787e3b8bac864
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4d41add3566a0e377fa41eb6d40004b05e2cbbc
index 0000000000000000000000000000000000000000..ddc19b5f5e469327ed8374fda1ee5a7a91280782
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
@@ -0,0 +1,325 @@
@@ -0,0 +1,331 @@
+package ca.spottedleaf.dataconverter.minecraft.datatypes;
+
+import ca.spottedleaf.dataconverter.minecraft.versions.*;
@ -9664,6 +9674,12 @@ index 0000000000000000000000000000000000000000..d4d41add3566a0e377fa41eb6d40004b
+ V4071.register();
+ // V1.21.3
+ V4081.register();
+ // V1.21.4
+ V4173.register();
+ V4175.register();
+ V4176.register();
+ V4180.register();
+ V4181.register();
+ }
+
+ private MCTypeRegistry() {}
@ -24374,6 +24390,202 @@ index 0000000000000000000000000000000000000000..22eae4d39c3887ef4991fd21856c32c4
+
+ private V4081() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java
new file mode 100644
index 0000000000000000000000000000000000000000..4e89460386bbc75b8380835b5df3ca821d6a9c82
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4173.java
@@ -0,0 +1,24 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import ca.spottedleaf.dataconverter.types.MapType;
+
+public final class V4173 {
+
+ private static final int VERSION = MCVersions.V1_21_3 + 91;
+
+ public static void register() {
+ MCTypeRegistry.ENTITY.addStructureConverter(new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ RenameHelper.renameSingle(data, "TNTFuse", "fuse");
+ return null;
+ }
+ });
+ }
+
+ private V4173() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java
new file mode 100644
index 0000000000000000000000000000000000000000..c4c6e75b8aae973fc4e4ac9f6e03ecbb5a38ef99
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4175.java
@@ -0,0 +1,40 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import ca.spottedleaf.dataconverter.types.ListType;
+import ca.spottedleaf.dataconverter.types.MapType;
+import ca.spottedleaf.dataconverter.types.TypeUtil;
+
+public final class V4175 {
+
+ private static final int VERSION = MCVersions.V24W44A + 1;
+
+ public static void register() {
+ MCTypeRegistry.DATA_COMPONENTS.addStructureConverter(new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ RenameHelper.renameSingle(data.getMap("minecraft:equippable"), "model", "asset_id");
+
+ final Number modelData = data.getNumber("minecraft:custom_model_data");
+ if (modelData != null) {
+ final TypeUtil typeUtil = data.getTypeUtil();
+
+ final MapType<String> newModelData = typeUtil.createEmptyMap();
+ data.setMap("minecraft:custom_model_data", newModelData);
+
+ final ListType floats = typeUtil.createEmptyList();
+ newModelData.setList("floats", floats);
+
+ floats.addFloat(modelData.floatValue());
+ }
+
+ return null;
+ }
+ });
+ }
+
+ private V4175() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1a74d545333224d9e8c79667bf42b2617fbe346
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4176.java
@@ -0,0 +1,44 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import ca.spottedleaf.dataconverter.types.MapType;
+
+public final class V4176 {
+
+ private static final int VERSION = MCVersions.V24W44A + 2;
+
+ private static void fixInvalidLock(final MapType<String> root, final String path) {
+ final MapType<String> lock = root.getMap(path);
+ if (lock == null || lock.size() != 1) {
+ return;
+ }
+
+ final MapType<String> components = lock.getMap("components");
+ if (components == null || components.size() != 1 || !"\"\"".equals(components.getString("minecraft:custom_name"))) {
+ return;
+ }
+
+ root.remove(path);
+ }
+
+ public static void register() {
+ MCTypeRegistry.TILE_ENTITY.addStructureConverter(new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ fixInvalidLock(data, "lock");
+ return null;
+ }
+ });
+ MCTypeRegistry.DATA_COMPONENTS.addStructureConverter(new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ fixInvalidLock(data, "minecraft:lock");
+ return null;
+ }
+ });
+ }
+
+ private V4176() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java
new file mode 100644
index 0000000000000000000000000000000000000000..c8eb7ba000310d1165c63fb9eef3787872f299bb
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4180.java
@@ -0,0 +1,22 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.converters.leveldat.ConverterRemoveFeatureFlag;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import java.util.Arrays;
+import java.util.HashSet;
+
+public final class V4180 {
+
+ private static final int VERSION = MCVersions.V1_21_4_PRE1 + 1;
+
+ public static void register() {
+ MCTypeRegistry.LEVEL.addStructureConverter(new ConverterRemoveFeatureFlag(VERSION, new HashSet<>(
+ Arrays.asList(
+ "minecraft:winter_drop"
+ )
+ )));
+ }
+
+ private V4180() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java
new file mode 100644
index 0000000000000000000000000000000000000000..f31c79adeddc4c1b8a82d1b0f122cc1d64c24440
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V4181.java
@@ -0,0 +1,36 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import ca.spottedleaf.dataconverter.types.MapType;
+
+public final class V4181 {
+
+ private static final int VERSION = MCVersions.V1_21_4_PRE1 + 2;
+
+ public static void register() {
+ final DataConverter<MapType<String>, MapType<String>> furnaceConverter = new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ RenameHelper.renameSingle(data, "CookTime", "cooking_time_spent");
+ RenameHelper.renameSingle(data, "CookTimeTotal", "cooking_total_time");
+ RenameHelper.renameSingle(data, "BurnTime", "lit_time_remaining");
+
+ final Object litTotalTime = data.getGeneric("lit_total_time");
+ if (litTotalTime != null) {
+ data.setGeneric("lit_time_remaining", litTotalTime);
+ }
+
+ return null;
+ }
+ };
+
+ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:furnace", furnaceConverter);
+ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:smoker", furnaceConverter);
+ MCTypeRegistry.TILE_ENTITY.addConverterForId("minecraft:blast_furnace", furnaceConverter);
+ }
+
+ private V4181() {}
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java
new file mode 100644
index 0000000000000000000000000000000000000000..a7a4d6446b7765ac485af82df660aafab05955bf
@ -30235,11 +30447,11 @@ index 1aa6be257ce594d7a69fdff008cd29014a04fd75..c8f2457ab3b28f2c3a6b500bcea40261
type, new Dynamic<>(NbtOps.INSTANCE, nbt), fromVersion, toVersion
).getValue();
diff --git a/src/main/java/net/minecraft/data/structures/StructureUpdater.java b/src/main/java/net/minecraft/data/structures/StructureUpdater.java
index 967cae22838fc23c3404777fd5f9d0b63885eb90..6e7c06008b392846acb84f2b061118a597680627 100644
index 96aea6d8cb68dd033c31cbde9d73ee490f320501..c51d71dd24cd28c22cda83cc3128c414ebd71a54 100644
--- a/src/main/java/net/minecraft/data/structures/StructureUpdater.java
+++ b/src/main/java/net/minecraft/data/structures/StructureUpdater.java
@@ -27,7 +27,7 @@ public class StructureUpdater implements SnbtToNbt.Filter {
LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 4053, name);
LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", i, 4173, name);
}
- CompoundTag compoundTag = DataFixTypes.STRUCTURE.updateToCurrentVersion(DataFixers.getDataFixer(), nbt, i);
@ -30384,7 +30596,7 @@ index b54a3741cd3ba615c83c98985cb4b3c4c586ed7a..b148cf247acdd36f856d0495cde4cc5a
return nbttagcompound;
});
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 4c82dae4c2d764c8310832b1a209846d4352bae9..507f908916cbeb592496f963b46e4c2121a7b5e3 100644
index 0d5d14a9a817c00704728f65cd87e446a0caa3c3..af19ab1f01946c41c27bf6bf76c9b194f85f2737 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -523,7 +523,7 @@ public final class CraftMagicNumbers implements UnsafeValues {