More compilation error fixes

This commit is contained in:
Nassim Jahnke
2022-06-08 16:24:55 +02:00
parent 0da6d1d498
commit 3cd8d0c681
7 changed files with 27 additions and 13 deletions

View File

@@ -1196,12 +1196,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package ca.spottedleaf.dataconverter.minecraft;
+
+import ca.spottedleaf.dataconverter.converters.datatypes.DataType;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCDataType;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import com.google.gson.JsonObject;
+import com.mojang.datafixers.DSL;
+import com.mojang.datafixers.DataFixer;
+import com.mojang.datafixers.schemas.Schema;
+import com.mojang.serialization.Dynamic;
+import net.minecraft.SharedConstants;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.util.datafix.fixes.References;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
@@ -1308,7 +1311,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (equivType != null) {
+ if (newVersion > version) {
+ try {
+ final Dynamic<T> ret = new Dynamic<>(input.getOps(), (T)MCDataConverter.copy(MCDataConverter.convertUnwrapped((DataType)equivType, input.getValue(), false, version, newVersion)));
+ final Dynamic<T> ret = new Dynamic<>(input.getOps(), (T)MCDataConverter.copy(convertUnwrapped((DataType)equivType, input.getValue(), false, version, newVersion)));
+ return ret;
+ } catch (final Exception ex) {
+ LOGGER.error("Failed to convert data using DataConverter, falling back to DFU", new Throwable());
@@ -1328,6 +1331,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+
+ public static <T, R> R convertUnwrapped(final DataType<T, R> type, final T data, final boolean compressedJson, final int fromVersion, final int toVersion) {
+ if (data instanceof CompoundTag) {
+ return (R)MCDataConverter.convertTag((MCDataType)type, (CompoundTag)data, fromVersion, toVersion);
+ }
+ if (data instanceof JsonObject) {
+ return (R)MCDataConverter.convertJson((MCDataType)type, (JsonObject)data, compressedJson, fromVersion, toVersion);
+ }
+
+ return MCDataConverter.convert(type, data, fromVersion, toVersion);
+ }
+
+ @Override
+ public Schema getSchema(final int key) {
+ return this.wrapped.getSchema(key);