@@ -220,10 +220,10 @@ index 0000000000000000000000000000000000000000..515f6691c72ffa82ac8b92646768be7a
220220+}
221221diff --git a/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java b/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
222222new file mode 100644
223- index 0000000000000000000000000000000000000000..427222ee6d4300757864ebd1158f86443252604e
223+ index 0000000000000000000000000000000000000000..d8662b811b47787f12ebf53e410dc4fa7fad0e10
224224--- /dev/null
225225+++ b/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
226- @@ -0,0 +1,485 @@
226+ @@ -0,0 +1,487 @@
227227+package ca.spottedleaf.dataconverter.minecraft;
228228+
229229+import ca.spottedleaf.dataconverter.converters.DataConverter;
@@ -504,9 +504,9 @@ index 0000000000000000000000000000000000000000..427222ee6d4300757864ebd1158f8644
504504+ 4311,
505505+ 4312,
506506+ 4314,
507- +// 4420,
508- +// 4424,
509- + // All up to 1.21.6-pre2
507+ + // 4420,
508+ + // 4424,
509+ + // All up to 1.21.6
510510+ };
511511+ Arrays.sort(converterVersions);
512512+
@@ -533,6 +533,8 @@ index 0000000000000000000000000000000000000000..427222ee6d4300757864ebd1158f8644
533533+ registerSubVersion(MCVersions.V24W07A + 1, 5);
534534+ registerSubVersion(MCVersions.V24W07A + 1, 6);
535535+
536+ + registerSubVersion(V4290.VERSION, 1);
537+ +
536538+ // register breakpoints here
537539+ // for all major releases after 1.16, add them. this reduces the work required to determine if a breakpoint
538540+ // is needed for new converters
@@ -559,7 +561,7 @@ index 0000000000000000000000000000000000000000..427222ee6d4300757864ebd1158f8644
559561+
560562+ // There is a read of entity sub data in V4299 (salmon) which was written to after V1_20_6
561563+ // There is also a sub type read in V4290 as it reads and converts all data within a text component
562- + registerBreakpointBefore (V4290.VERSION);
564+ + registerBreakpointAfter (V4290.VERSION);
563565+ }
564566+
565567+ static {
@@ -711,10 +713,10 @@ index 0000000000000000000000000000000000000000..427222ee6d4300757864ebd1158f8644
711713+}
712714diff --git a/ca/spottedleaf/dataconverter/minecraft/MCVersions.java b/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
713715new file mode 100644
714- index 0000000000000000000000000000000000000000..d2d572733f848108c156a629c9e65d35e0c681c4
716+ index 0000000000000000000000000000000000000000..f54d93488ce8d6161bc69735fe4be9c54c374424
715717--- /dev/null
716718+++ b/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
717- @@ -0,0 +1,593 @@
719+ @@ -0,0 +1,599 @@
718720+package ca.spottedleaf.dataconverter.minecraft;
719721+
720722+@SuppressWarnings("unused")
@@ -1296,15 +1298,21 @@ index 0000000000000000000000000000000000000000..d2d572733f848108c156a629c9e65d35
12961298+ public static final int V1_21_5_RC1 = 4323;
12971299+ public static final int V1_21_5_RC2 = 4324;
12981300+ public static final int V1_21_5 = 4325;
1299- +// public static final int V25W15A = 4422;
1300- +// public static final int V25W16A = 4423;
1301- +// public static final int V25W17A = 4425;
1302- +// public static final int V25W18A = 4426;
1303- +// public static final int V25W19A = 4427;
1304- +// public static final int V25W20A = 4428;
1305- +// public static final int V25W21A = 4429;
1306- +// public static final int V1_21_6_PRE1 = 4430;
1307- +// public static final int V1_21_6_PRE2 = 4431;
1301+ + /*
1302+ + public static final int V25W15A = 4422;
1303+ + public static final int V25W16A = 4423;
1304+ + public static final int V25W17A = 4425;
1305+ + public static final int V25W18A = 4426;
1306+ + public static final int V25W19A = 4427;
1307+ + public static final int V25W20A = 4428;
1308+ + public static final int V25W21A = 4429;
1309+ + public static final int V1_21_6_PRE1 = 4430;
1310+ + public static final int V1_21_6_PRE2 = 4431;
1311+ + public static final int V1_21_6_PRE3 = 4432;
1312+ + public static final int V1_21_6_PRE4 = 4433;
1313+ + public static final int V1_21_6_RC1 = 4434;
1314+ + public static final int V1_21_6 = 4435;
1315+ + */
13081316+
13091317+ private MCVersions() {}
13101318+}
@@ -9282,10 +9290,10 @@ index 0000000000000000000000000000000000000000..e1f7c0d7fd80556941bbba8018aa85e7
92829290+}
92839291diff --git a/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java b/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
92849292new file mode 100644
9285- index 0000000000000000000000000000000000000000..1a09db070633d257174b6985d70f1801b06492d5
9293+ index 0000000000000000000000000000000000000000..edeb0db8e00157da02f9318a1625a62a06f7de0e
92869294--- /dev/null
92879295+++ b/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
9288- @@ -0,0 +1,367 @@
9296+ @@ -0,0 +1,369 @@
92899297+package ca.spottedleaf.dataconverter.minecraft.datatypes;
92909298+
92919299+import ca.spottedleaf.dataconverter.minecraft.versions.*;
@@ -9646,9 +9654,11 @@ index 0000000000000000000000000000000000000000..1a09db070633d257174b6985d70f1801
96469654+ V4311.register();
96479655+ V4312.register();
96489656+ V4314.register();
9649- +// V4420.register();
9650- +// V4421.register();
9651- +// V4424.register();
9657+ + /*
9658+ + V4420.register();
9659+ + V4421.register();
9660+ + V4424.register();
9661+ + */
96529662+ }
96539663+
96549664+ private MCTypeRegistry() {}
@@ -9898,6 +9908,90 @@ index 0000000000000000000000000000000000000000..17ded002b5546de8be4a5238c20ccfda
98989908+
98999909+ private ComponentUtils() {}
99009910+}
9911+ diff --git a/ca/spottedleaf/dataconverter/minecraft/util/StringWalker.java b/ca/spottedleaf/dataconverter/minecraft/util/StringWalker.java
9912+ new file mode 100644
9913+ index 0000000000000000000000000000000000000000..4e1add641c092b241b48e93732dab4ef646eafc3
9914+ --- /dev/null
9915+ +++ b/ca/spottedleaf/dataconverter/minecraft/util/StringWalker.java
9916+ @@ -0,0 +1,78 @@
9917+ +package ca.spottedleaf.dataconverter.minecraft.util;
9918+ +
9919+ +public final class StringWalker {
9920+ +
9921+ + public final String string;
9922+ + private int index; // index of next value to return
9923+ + private final int maxIndex; // exclusive
9924+ +
9925+ + public StringWalker(final String string) {
9926+ + this(string, 0);
9927+ + }
9928+ +
9929+ + public StringWalker(final String string, final int index) {
9930+ + this(string, index, string.length());
9931+ + }
9932+ +
9933+ + public StringWalker(final String string, final int index, final int maxIndex) {
9934+ + this.string = string;
9935+ + this.index = index;
9936+ + this.maxIndex = maxIndex;
9937+ +
9938+ + if (maxIndex < 0 || maxIndex > string.length()) {
9939+ + throw new IllegalArgumentException("Max index out of string range");
9940+ + }
9941+ +
9942+ + if (index < 0 || index > maxIndex) {
9943+ + throw new IllegalArgumentException("Index out of string range");
9944+ + }
9945+ + }
9946+ +
9947+ + public int getIndex() {
9948+ + return this.index;
9949+ + }
9950+ +
9951+ + public void setIndex(final int to) {
9952+ + this.index = to;
9953+ + }
9954+ +
9955+ + private void checkNext() {
9956+ + if (!this.hasNext()) {
9957+ + throw this.parseFail(this.getIndex(), "Expecting more input");
9958+ + }
9959+ + }
9960+ +
9961+ + public boolean hasNext() {
9962+ + return this.index < this.maxIndex;
9963+ + }
9964+ +
9965+ + public char next() {
9966+ + return this.string.charAt(this.index++);
9967+ + }
9968+ +
9969+ + public char peek() {
9970+ + return this.string.charAt(this.index);
9971+ + }
9972+ +
9973+ + public void advance() {
9974+ + ++this.index;
9975+ + }
9976+ +
9977+ + public void skipWhitespace() {
9978+ + while (this.hasNext() || Character.isWhitespace(this.peek())) {
9979+ + this.advance();
9980+ + }
9981+ + }
9982+ +
9983+ + public boolean skipIf(final char c) {
9984+ + if (this.hasNext() && this.peek() == c) {
9985+ + this.advance();
9986+ + return true;
9987+ + }
9988+ + return false;
9989+ + }
9990+ +
9991+ + public IllegalStateException parseFail(final int index, final String reason) {
9992+ + return new IllegalStateException("At column " + index + ": " + reason);
9993+ + }
9994+ +}
99019995diff --git a/ca/spottedleaf/dataconverter/minecraft/util/Version.java b/ca/spottedleaf/dataconverter/minecraft/util/Version.java
99029996new file mode 100644
99039997index 0000000000000000000000000000000000000000..57563e3f85653d1e946495e7609c6ee644095ceb
@@ -24764,15 +24858,13 @@ index 0000000000000000000000000000000000000000..7d09c4218d0db8119d1681bf95900be8
2476424858+}
2476524859diff --git a/ca/spottedleaf/dataconverter/minecraft/versions/V4290.java b/ca/spottedleaf/dataconverter/minecraft/versions/V4290.java
2476624860new file mode 100644
24767- index 0000000000000000000000000000000000000000..4197a5e89aec77f2893f0f118a927b96d5377ec1
24861+ index 0000000000000000000000000000000000000000..d5dfa9a64e2d3f9a37a5bdde60b92ed93bd89aed
2476824862--- /dev/null
2476924863+++ b/ca/spottedleaf/dataconverter/minecraft/versions/V4290.java
24770- @@ -0,0 +1,248 @@
24864+ @@ -0,0 +1,312 @@
2477124865+package ca.spottedleaf.dataconverter.minecraft.versions;
2477224866+
2477324867+import ca.spottedleaf.dataconverter.converters.DataConverter;
24774- +import ca.spottedleaf.dataconverter.converters.datatypes.DataType;
24775- +import ca.spottedleaf.dataconverter.minecraft.MCDataConverter;
2477624868+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
2477724869+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
2477824870+import ca.spottedleaf.dataconverter.minecraft.walkers.generic.WalkerUtils;
@@ -24912,6 +25004,70 @@ index 0000000000000000000000000000000000000000..4197a5e89aec77f2893f0f118a927b96
2491225004+ }
2491325005+ }
2491425006+
25007+ + private static void directWalkComponentList(final ListType list, final long fromVersion, final long toVersion) {
25008+ + for (int i = 0, len = list.size(); i < len; ++i) {
25009+ + directWalkComponent(list.getGeneric(i), fromVersion, toVersion);
25010+ + }
25011+ + }
25012+ +
25013+ + private static void directWalkComponent(final Object input, final long fromVersion, final long toVersion) {
25014+ + if (input instanceof ListType listType) {
25015+ + directWalkComponentList(listType, fromVersion, toVersion);
25016+ + } else if (input instanceof MapType root) {
25017+ + final ListType extra = root.getListUnchecked("extra");
25018+ + if (extra != null) {
25019+ + directWalkComponentList(extra, fromVersion, toVersion);
25020+ + }
25021+ +
25022+ + final Object separator = root.getGeneric("separator");
25023+ + if (separator != null) {
25024+ + directWalkComponent(separator, fromVersion, toVersion);
25025+ + }
25026+ +
25027+ + final MapType clickEvent = root.getMap("clickEvent");
25028+ + if (clickEvent != null) {
25029+ + switch (clickEvent.getString("action", "")) {
25030+ + case "run_command":
25031+ + case "suggest_command": {
25032+ + WalkerUtils.convert(MCTypeRegistry.DATACONVERTER_CUSTOM_TYPE_COMMAND, clickEvent, "value", fromVersion, toVersion);
25033+ + break;
25034+ + }
25035+ + }
25036+ + }
25037+ +
25038+ + final MapType hoverEvent = root.getMap("hoverEvent");
25039+ + if (hoverEvent != null) {
25040+ + switch (hoverEvent.getString("action", "")) {
25041+ + case "show_text": {
25042+ + final Object contents = hoverEvent.getGeneric("contents");
25043+ + if (contents != null) {
25044+ + directWalkComponent(contents, fromVersion, toVersion);
25045+ + }
25046+ + break;
25047+ + }
25048+ + case "show_item": {
25049+ + if (hoverEvent.hasKey("contents", ObjectType.STRING)) {
25050+ + WalkerUtils.convert(MCTypeRegistry.ITEM_NAME, hoverEvent, "contents", fromVersion, toVersion);
25051+ + } else {
25052+ + WalkerUtils.convert(MCTypeRegistry.ITEM_STACK, hoverEvent, "contents", fromVersion, toVersion);
25053+ + }
25054+ + break;
25055+ + }
25056+ + case "show_entity": {
25057+ + WalkerUtils.convert(MCTypeRegistry.ENTITY_NAME, hoverEvent, "type", fromVersion, toVersion);
25058+ +
25059+ + final Object name = hoverEvent.getGeneric("name");
25060+ + if (name != null) {
25061+ + directWalkComponent(name, fromVersion, toVersion);
25062+ + }
25063+ + break;
25064+ + }
25065+ + // default: do nothing
25066+ + }
25067+ + }
25068+ + } // else: should only be string
25069+ + }
25070+ +
2491525071+ public static void register() {
2491625072+ MCTypeRegistry.TEXT_COMPONENT.addStructureConverter(new DataConverter<>(VERSION) {
2491725073+ @Override
@@ -24958,6 +25114,7 @@ index 0000000000000000000000000000000000000000..4197a5e89aec77f2893f0f118a927b96
2495825114+ };
2495925115+
2496025116+ convertNested(ret);
25117+ + directWalkComponent(ret, sourceVersion, toVersion);
2496125118+ return ret;
2496225119+ }
2496325120+ } catch (final JsonParseException ex) {
@@ -24968,7 +25125,8 @@ index 0000000000000000000000000000000000000000..4197a5e89aec77f2893f0f118a927b96
2496825125+ }
2496925126+ });
2497025127+
24971- + MCTypeRegistry.TEXT_COMPONENT.addStructureWalker(VERSION, (final Object input, final long fromVersion, final long toVersion) -> {
25128+ + // step 1
25129+ + MCTypeRegistry.TEXT_COMPONENT.addStructureWalker(VERSION, 1, (final Object input, final long fromVersion, final long toVersion) -> {
2497225130+ if (input instanceof ListType listType) {
2497325131+ WalkerUtils.convert(MCTypeRegistry.TEXT_COMPONENT, listType, fromVersion, toVersion);
2497425132+ } else if (input instanceof MapType root) {
@@ -30277,10 +30435,10 @@ index 0000000000000000000000000000000000000000..6704da4a40522a4f40cd770a4cbaaa8e
3027730435+}
3027830436diff --git a/ca/spottedleaf/dataconverter/types/json/JsonTypeUtil.java b/ca/spottedleaf/dataconverter/types/json/JsonTypeUtil.java
3027930437new file mode 100644
30280- index 0000000000000000000000000000000000000000..d96808060623f73b08dec8eb6d6fdfca4d309d16
30438+ index 0000000000000000000000000000000000000000..3ace24bdd5e5da4333e25c9c681007e6a85d52ab
3028130439--- /dev/null
3028230440+++ b/ca/spottedleaf/dataconverter/types/json/JsonTypeUtil.java
30283- @@ -0,0 +1,189 @@
30441+ @@ -0,0 +1,181 @@
3028430442+package ca.spottedleaf.dataconverter.types.json;
3028530443+
3028630444+import ca.spottedleaf.dataconverter.minecraft.converters.helpers.CopyHelper;
@@ -30461,14 +30619,6 @@ index 0000000000000000000000000000000000000000..d96808060623f73b08dec8eb6d6fdfca
3046130619+
3046230620+ return ret;
3046330621+ }
30464- +
30465- + private static MapType convertJson(final TypeUtil<?> to, final JsonMapType json) {
30466- + return convertJson(to, json.map, json.compressed);
30467- + }
30468- +
30469- + private static ListType convertJson(final TypeUtil<?> to, final JsonListType json) {
30470- + return convertJson(to, json.array, json.compressed);
30471- + }
3047230622+}
3047330623diff --git a/ca/spottedleaf/dataconverter/types/nbt/NBTListType.java b/ca/spottedleaf/dataconverter/types/nbt/NBTListType.java
3047430624new file mode 100644
@@ -31508,10 +31658,10 @@ index 0000000000000000000000000000000000000000..2558d9014e1daff6dd4a44ad85bbc025
3150831658+}
3150931659diff --git a/ca/spottedleaf/dataconverter/types/nbt/NBTTypeUtil.java b/ca/spottedleaf/dataconverter/types/nbt/NBTTypeUtil.java
3151031660new file mode 100644
31511- index 0000000000000000000000000000000000000000..32d90fc5ab415b0261af8377b130404ad37e19ee
31661+ index 0000000000000000000000000000000000000000..61e98240a221a75780e311c0777a8c43c4297d65
3151231662--- /dev/null
3151331663+++ b/ca/spottedleaf/dataconverter/types/nbt/NBTTypeUtil.java
31514- @@ -0,0 +1,136 @@
31664+ @@ -0,0 +1,128 @@
3151531665+package ca.spottedleaf.dataconverter.types.nbt;
3151631666+
3151731667+import ca.spottedleaf.dataconverter.minecraft.converters.helpers.CopyHelper;
@@ -31639,14 +31789,6 @@ index 0000000000000000000000000000000000000000..32d90fc5ab415b0261af8377b130404a
3163931789+
3164031790+ return ret;
3164131791+ }
31642- +
31643- + public static MapType convertNBT(final TypeUtil<?> to, final NBTMapType nbt) {
31644- + return convertNBT(to, nbt.map);
31645- + }
31646- +
31647- + public static ListType convertNBT(final TypeUtil<?> to, final NBTListType nbt) {
31648- + return convertNBT(to, nbt.list);
31649- + }
3165031792+}
3165131793diff --git a/ca/spottedleaf/dataconverter/util/Int2IntArraySortedMap.java b/ca/spottedleaf/dataconverter/util/Int2IntArraySortedMap.java
3165231794new file mode 100644
0 commit comments