Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nikev2 opened this issue May 3, 2024 · 2 comments

Comments

@Nikev2
Copy link

Nikev2 commented May 3, 2024

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
Copy link

Bawnorton commented May 4, 2024

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
Copy link
Author

Nikev2 commented May 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants