architectury / architectury-api

An intermediary api aimed at easing development of multiplatform mods.
https://discord.architectury.dev/
GNU Lesser General Public License v3.0
306 stars 55 forks source link

Injecting a method but forge needs the arguments in a different order than fabric #502

Open Nikev2 opened 2 months ago

Nikev2 commented 2 months ago

when run in forge createChild method in the VillagerEntity class wants the arguments in a different order than fabric has. I have tried switching the mixins around but nothing seems to work.

forge argument order: void createChild(ServerWorld serverWorld, PassiveEntity passiveEntity, CallbackInfoReturnable<VillagerEntity> cir,double d,VillagerType villagerType,VillagerEntity Child)

Fabric argument order void createChild(ServerWorld serverWorld, PassiveEntity passiveEntity, CallbackInfoReturnable<VillagerEntity> cir, VillagerType villagerType, double d, VillagerEntity Child)

Inject method it uses

@Inject(method = "createChild(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/passive/PassiveEntity;)Lnet/minecraft/entity/passive/VillagerEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/VillagerEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD,cancellable = true)

Bawnorton commented 2 months ago

Don't use local capture (for this reason and others; they rely on the LVT being consistent and in the same order which is intrinsically brittle). Use mixinextra's @Local if you need a specific local https://github.com/LlamaLad7/MixinExtras/wiki/Local

Nikev2 commented 2 months ago

Ok its fixed. Also when i try to launch this mod (the mod i made) on forge it loads normally but the Mixins won't work even though it works in the ide environment. it works in fabric tho