LlamaLad7 / MixinExtras

Companion library to SpongePowered Mixin with many custom injectors for a more expressive experience.
MIT License
304 stars 17 forks source link

Unable to get MixinExtras working on Forge 1.19.4 with Architectury #27

Closed Octol1ttle closed 1 year ago

Octol1ttle commented 1 year ago

Problematic Mixin method:

@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;useFancyGraphics()Z"))
    private boolean forceRenderDamageVignette(boolean vignetteAllowed) {
        LivingEntity entity = (LivingEntity) minecraft.cameraEntity;
        @SuppressWarnings("DataFlowIssue")
        float hpScaled = entity.getHealth() / entity.getMaxHealth() * 100.0f;
        float confLow = Mth.clamp(DamageVignette.configProvider.getLowThreshold(), 0.0f, DamageVignette.configProvider.getHighThreshold());
        float confHigh = Mth.clamp(DamageVignette.configProvider.getHighThreshold(), confLow, 100.0f);
        DamageVignette.curOpacity = (confHigh - hpScaled) / (confHigh - confLow);
        return vignetteAllowed || DamageVignette.configProvider.isModEnabled() && DamageVignette.curOpacity > 0.0f;
    }

Methods from vanilla Mixin work correctly Adding @Debug(export = true) and looking at the output class file shows the @ModifyExpressionValue being applied, however adding a System.out.println to that method will show that no modification actually happened (nothing will be printed when the method is invoked)

Common build.gradle dependencies block:

dependencies {
    implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:0.2.0-beta.6"))

    // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
    // Do NOT use other classes from fabric loader
    modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
}

Forge build.gradle:

dependencies {
    implementation(include("com.github.llamalad7.mixinextras:mixinextras-forge:0.2.0-beta.6"))

    forge "net.minecraftforge:forge:${rootProject.forge_version}"

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
}
LlamaLad7 commented 1 year ago

Can you provide a log with -Dmixin.debug.verbose=true on? And ideally send the exported class too.

Octol1ttle commented 1 year ago

Log: https://paste.gg/p/anonymous/d8b3d188f6854e95bbfc69eb643233ab

Gui.class.zip

LlamaLad7 commented 1 year ago

You can see from the class dump that it is working correctly: image Your problem is likely just a logic issue and not to do with MixinExtras.