#kotlin #minecraft-fabric
Вопрос:
Я участвую в моде Minecraft magic, в котором хранятся данные игроков
Я использовал миксин, чтобы сделать эту часть
после этого он не работает на клиенте
, но все еще работает в среде разработки
как я могу это исправить?
Этот код не выдает ошибку, когда я его создаю
код:
package dev.bukgeuk.polarmagic.mixin
import ...
@Mixin(PlayerEntity::class)
abstract class PlayerEntityMixin(type: EntityType<LivingEntity>, world: World) : LivingEntity(type, world), PlayerEntityExt {
private var maxManaAmount: Float? = null
private var currentManaAmount: Float? = null
private var magicLevel: Int? = null
private var magicCurrentExp: Float? = null
private var magicMaxExp: Float? = null
...
@Inject(method = ["readCustomDataFromNbt"], at = [At("RETURN")])
fun readCustomDataFromNbt(nbt: NbtCompound, ci: CallbackInfo) {
magicLevel = nbt.getInt("magicLevel")
magicCurrentExp = nbt.getFloat("magicCurrentExp")
magicMaxExp = nbt.getFloat("magicMaxExp")
currentManaAmount = nbt.getFloat("currentManaAmount")
maxManaAmount = nbt.getFloat("maxManaAmount")
println("read")
}
@Inject(method = ["writeCustomDataToNbt"], at = [At("RETURN")])
fun writeCustomDataToNbt(nbt: NbtCompound, ci: CallbackInfo) {
if (this.magicLevel != null)
nbt.putInt("magicLevel", this.magicLevel!!)
if (this.magicCurrentExp != null)
nbt.putFloat("magicCurrentExp", this.magicCurrentExp!!)
if (this.magicMaxExp != null)
nbt.putFloat("magicMaxExp", this.magicMaxExp!!)
if (this.currentManaAmount != null)
nbt.putFloat("currentManaAmount", this.currentManaAmount!!)
if (this.maxManaAmount != null)
nbt.putFloat("maxManaAmount", this.maxManaAmount!!)
println("write")
}
...
}
журнал ошибок:
[23:45:59] [main/INFO]: Loading for game Minecraft 1.17.1
[23:45:59] [main/INFO]: [FabricLoader] Loading 61 mods:
- fabric@0.37.0 1.17
- fabric-api-base@0.3.0 a02b446318
- fabric-api-lookup-api-v1@1.2.0 2b5c62d018
- fabric-biome-api-v1@3.1.11 c345aea818
- fabric-blockrenderlayer-v1@1.1.5 a02b446318
- fabric-command-api-v1@1.1.2 6cefd57718
- fabric-commands-v0@0.2.2 92519afa18
- fabric-containers-v0@0.1.12 a02b446318
- fabric-content-registries-v0@0.2.2 a02b446318
- fabric-crash-report-info-v1@0.1.5 be9da31018
- fabric-dimensions-v1@2.0.11 6cefd57718
- fabric-entity-events-v1@1.1.0 a02b446318
- fabric-events-interaction-v0@0.4.9 a722d8c018
- fabric-events-lifecycle-v0@0.2.1 92519afa18
- fabric-game-rule-api-v1@1.0.7 6cefd57718
- fabric-item-api-v1@1.2.4 a02b446318
- fabric-item-groups-v0@0.2.10 b7ab612118
- fabric-key-binding-api-v1@1.0.4 a02b446318
- fabric-keybindings-v0@0.2.2 36b77c3e18
- fabric-language-kotlin@1.6.2 kotlin.1.5.20
- fabric-lifecycle-events-v1@1.4.4 a02b446318
- fabric-loot-tables-v1@1.0.4 a02b446318
- fabric-mining-levels-v0@0.1.3 92519afa18
- fabric-models-v0@0.3.0 a02b446318
- fabric-networking-api-v1@1.0.12 6cefd57718
- fabric-networking-blockentity-v0@0.2.11 a02b446318
- fabric-networking-v0@0.3.2 92519afa18
- fabric-object-builder-api-v1@1.10.9 b7ab612118
- fabric-object-builders-v0@0.7.3 a02b446318
- fabric-particles-v1@0.2.4 a02b446318
- fabric-registry-sync-v0@0.7.10 e2961fee18
- fabric-renderer-api-v1@0.4.4 5f02c96918
- fabric-renderer-indigo@0.4.8 a02b446318
- fabric-renderer-registries-v1@3.2.0 a02b446318
- fabric-rendering-data-attachment-v1@0.1.5 a02b446318
- fabric-rendering-fluids-v1@0.1.13 a02b446318
- fabric-rendering-v0@1.1.2 92519afa18
- fabric-rendering-v1@1.6.0 a02b446318
- fabric-resource-loader-v0@0.4.7 b7ab612118
- fabric-screen-api-v1@1.0.4 155f865c18
- fabric-screen-handler-api-v1@1.1.8 a02b446318
- fabric-structure-api-v1@1.1.12 6cefd57718
- fabric-tag-extensions-v0@1.1.4 a02b446318
- fabric-textures-v0@1.0.6 a02b446318
- fabric-tool-attribute-api-v1@1.2.12 b7ab612118
- fabric-transfer-api-v1@1.0.0 3fe3c3f518
- fabricloader@0.11.6
- jankson@3.0.1 j1.2.0
- java@16
- libgui@4.1.4 1.17.1
- libninepatch@1.1.0
- minecraft@1.17.1
- org_jetbrains_kotlin_kotlin-reflect@1.5.20
- org_jetbrains_kotlin_kotlin-stdlib@1.5.20
- org_jetbrains_kotlin_kotlin-stdlib-jdk7@1.5.20
- org_jetbrains_kotlin_kotlin-stdlib-jdk8@1.5.20
- org_jetbrains_kotlinx_kotlinx-coroutines-core-jvm@1.5.0
- org_jetbrains_kotlinx_kotlinx-coroutines-jdk8@1.5.0
- org_jetbrains_kotlinx_kotlinx-serialization-core-jvm@1.2.1
- org_jetbrains_kotlinx_kotlinx-serialization-json-jvm@1.2.1
- polarmagic@1.0.0
[23:45:59] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/C:/Users/bukgeuk/AppData/Roaming/.minecraft/libraries/net/fabricmc/sponge-mixin/0.9.4 mixin.0.8.2/sponge-mixin-0.9.4 mixin.0.8.2.jar Service=Knot/Fabric Env=CLIENT
[23:46:00] [main/INFO]: Compatibility level set to JAVA_16
[23:46:00] [main/WARN]: Reference map 'polarmagic-refmap.json' for polarmagic.mixins.json could not be read. If this is a development environment you can ignore this message
[23:46:00] [main/WARN]: @Mixin target net/minecraft/class_2474$class_5124 is public in fabric-tag-extensions-v0.mixins.json:MixinObjectBuilder and should be specified in value
[23:46:01] [main/FATAL]: Mixin apply failed polarmagic.mixins.json:PlayerEntityMixin -> net.minecraft.class_1657: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException Critical injection failure: @Inject annotation on readCustomDataFromNbt could not find any targets matching 'readCustomDataFromNbt' in net.minecraft.class_1657. No refMap loaded. [PREINJECT Applicator Phase -> polarmagic.mixins.json:PlayerEntityMixin -> Prepare Injections -> -> handler$zff000$readCustomDataFromNbt(Lnet/minecraft/class_2487;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V -> Parse]
org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: Critical injection failure: @Inject annotation on readCustomDataFromNbt could not find any targets matching 'readCustomDataFromNbt' in net.minecraft.class_1657. No refMap loaded. [PREINJECT Applicator Phase -> polarmagic.mixins.json:PlayerEntityMixin -> Prepare Injections -> -> handler$zff000$readCustomDataFromNbt(Lnet/minecraft/class_2487;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V -> Parse]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.findMethods(InjectionInfo.java:572) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.readAnnotation(InjectionInfo.java:288) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.<init>(InjectionInfo.java:275) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.<init>(InjectionInfo.java:267) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.injection.struct.CallbackInjectionInfo.<init>(CallbackInjectionInfo.java:46) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at jdk.internal.reflect.GeneratedConstructorAccessor58.newInstance(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo$InjectorEntry.create(InjectionInfo.java:140) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.parse(InjectionInfo.java:624) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinTargetContext.prepareInjections(MixinTargetContext.java:1247) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.prepareInjections(MixinApplicatorStandard.java:1033) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:388) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:320) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:208) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:178) ~[sponge-mixin-0.9.4 mixin.0.8.2.jar:0.9.4 mixin.0.8.2]
at org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy.transformClassBytes(FabricMixinTransformerProxy.java:23) ~[fabric-loader-0.11.6.jar:0.9.4 mixin.0.8.2]
at net.fabricmc.loader.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:162) ~[fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:154) ~[fabric-loader-0.11.6.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
at net.minecraft.class_2246.<clinit>(class_2246.java:103) ~[intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_3523.<clinit>(class_3523.java:13) ~[intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_5471.<clinit>(class_5471.java:11) ~[intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_5458.method_30573(class_5458.java:44) ~[intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_5458.method_30566(class_5458.java:75) ~[intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:723) [?:?]
at net.minecraft.class_5458.<clinit>(class_5458.java:74) [intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_2378.<clinit>(class_2378.java:266) [intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.class_2966.method_12851(class_2966.java:44) [intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at net.minecraft.client.main.Main.main(Main.java:139) [intermediary-fabric-loader-0.11.6-1.17.1.jar:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:234) [fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:153) [fabric-loader-0.11.6.jar:?]
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.6.jar:?]
full code: https://github.com/Bukgeuk/PolarMagic