From 432eca7513004175985218cc4ac99395822717be Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 19 Jun 2025 04:51:11 +0500 Subject: [PATCH] Fixed DataFixer apply --- bridge/pom.xml | 2 +- main/pom.xml | 2 +- .../su/nightexpress/nightcore/util/ItemNbt.java | 15 ++++++++++++++- main/src/main/resources/plugin.yml | 2 +- paper/pom.xml | 2 +- spigot/pom.xml | 2 +- utils/pom.xml | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/bridge/pom.xml b/bridge/pom.xml index dcbbbab..a7f239d 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -28,7 +28,7 @@ io.papermc.paper paper-api - 1.21.5-R0.1-SNAPSHOT + 1.21.6-R0.1-SNAPSHOT provided diff --git a/main/pom.xml b/main/pom.xml index 840ba2d..6533eb7 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -77,7 +77,7 @@ io.papermc.paper paper-api - 1.21.5-R0.1-SNAPSHOT + 1.21.6-R0.1-SNAPSHOT provided diff --git a/main/src/main/java/su/nightexpress/nightcore/util/ItemNbt.java b/main/src/main/java/su/nightexpress/nightcore/util/ItemNbt.java index a934b0a..76aa18b 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/ItemNbt.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/ItemNbt.java @@ -330,7 +330,7 @@ public class ItemNbt { if (useCodec) { Object context = createSerializationContext(); - DataResult decoded = (DataResult) Reflex.invokeMethod(mParse, itemStackCodec, context, tag); + DataResult decoded = (DataResult) Reflex.invokeMethod(mParse, itemStackCodec, context, compoundTag); if (decoded == null) return null; itemStack = decoded.resultOrPartial(itemId -> Engine.core().error("Could not decode ItemStack from tag: " + itemId)).orElse(null); @@ -352,6 +352,19 @@ public class ItemNbt { if (targetVersion <= 0) return compoundTag; if (sourceVersion > targetVersion || sourceVersion <= 0) return compoundTag; + // Probably not necessary, but they used it for a reason probably. +// if (Version.isPaper()) { +// Class mcDataTypeClass = Reflex.getClass("ca.spottedleaf.dataconverter.minecraft.datatypes", "MCDataType"); +// Class mcDataConvertedClass = Reflex.getClass("ca.spottedleaf.dataconverter.minecraft", "MCDataConverter"); +// Class mcTypeRegistryClass = Reflex.getClass("ca.spottedleaf.dataconverter.minecraft.datatypes", "MCTypeRegistry"); +// +// Object itemStackRegistry = Reflex.getFieldValue(mcTypeRegistryClass, "ITEM_STACK"); +// +// Method convert = Reflex.getMethod(mcDataConvertedClass, "convertTag", mcDataTypeClass, CLS_COMPOUND_TAG, Integer.TYPE, Integer.TYPE); +// +// return Reflex.invokeMethod(convert, null, itemStackRegistry, compoundTag, sourceVersion, targetVersion); +// } + Dynamic dynamic = new Dynamic<>((DynamicOps) nbtOps, compoundTag); return dataFixer.update((DSL.TypeReference) itemStackReference, dynamic, sourceVersion, targetVersion).getValue(); } diff --git a/main/src/main/resources/plugin.yml b/main/src/main/resources/plugin.yml index 76a3b84..dd46d8b 100644 --- a/main/src/main/resources/plugin.yml +++ b/main/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ main: su.nightexpress.nightcore.NightCore version: '${project.version}' description: Plugin core author: NightExpress -api-version: 1.19 +api-version: 1.20 load: STARTUP libraries: - com.zaxxer:HikariCP:6.0.0 diff --git a/paper/pom.xml b/paper/pom.xml index 5ef7a2f..3072a35 100644 --- a/paper/pom.xml +++ b/paper/pom.xml @@ -28,7 +28,7 @@ io.papermc.paper paper-api - 1.21.5-R0.1-SNAPSHOT + 1.21.6-R0.1-SNAPSHOT provided diff --git a/spigot/pom.xml b/spigot/pom.xml index 967b2bb..083e580 100644 --- a/spigot/pom.xml +++ b/spigot/pom.xml @@ -28,7 +28,7 @@ org.spigotmc spigot-api - 1.21.4-R0.1-SNAPSHOT + 1.21.6-R0.1-SNAPSHOT provided diff --git a/utils/pom.xml b/utils/pom.xml index 823175c..e80fac0 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -28,7 +28,7 @@ io.papermc.paper paper-api - 1.21.5-R0.1-SNAPSHOT + 1.21.6-R0.1-SNAPSHOT provided