Skip to content

Commit

Permalink
Fix issues on older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Apr 23, 2024
1 parent c723eef commit fdc16aa
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ public class NBTReflectionUtil {
} catch (NoSuchFieldException e) {

}
try {
Field typeField = ClassWrapper.NMS_DATACOMPONENTS.getClazz().getDeclaredField(
MojangToMapping.getMapping().get("net.minecraft.core.component.DataComponents#CUSTOM_DATA"));
type_custom_data = typeField.get(null);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_20_R4)) {
try {
Field typeField = ClassWrapper.NMS_DATACOMPONENTS.getClazz().getDeclaredField(
MojangToMapping.getMapping().get("net.minecraft.core.component.DataComponents#CUSTOM_DATA"));
type_custom_data = typeField.get(null);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {

}
try {
Object nmsServer = ReflectionMethod.NMSSERVER_GETSERVER.run(Bukkit.getServer());
registry_access = ReflectionMethod.NMSSERVER_GETREGISTRYACCESS.run(nmsServer);
} catch (Exception e) {
e.printStackTrace();
}
try {
Object nmsServer = ReflectionMethod.NMSSERVER_GETSERVER.run(Bukkit.getServer());
registry_access = ReflectionMethod.NMSSERVER_GETREGISTRYACCESS.run(nmsServer);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Expand Down

0 comments on commit fdc16aa

Please sign in to comment.