#[1.21.1] ModifyExpressionValue conditions still evaluate to true

20 messages · Page 1 of 1 (latest)

fading jolt
#

Using the @ModifyExpressionValue annotation, I made 2 expressions automatically evaluate to true no matter what. This isn't a permanent solution just trying to get something working and go from there. Here are the two methods:

@ModifyExpressionValue(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z"))
    private boolean allowHorseArmorCombine(boolean original) {
        boolean custom = this.input.getStack(0).isIn(ModTags.Items.HORSE_ARMOR) && this.input.getStack(1).isIn(ModTags.Items.HORSE_ARMOR);
        return true;
    }

    @ModifyExpressionValue(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isDamageable()Z"))
    private boolean allowNonDamageableCombine(boolean original) {
        return true;
    }```

This is the condition from the `AnvilScreenHandler` class:
```java
!bl && (!itemStack2.isOf(itemStack3.getItem()) || !itemStack2.isDamageable())```

Despite forcing `isOf` and `isDamageable` to be true, the condition still overall evaluates to true. Why does this happen? Also, does the `ModifyExpressionValue` work on all invokes to the target method in the injected method?
-# Ping on reply please :) 🔔
grim estuary
#

did you debug your code?

fading jolt
#

yeah ofc

#

the debug stuff is still in the github lol

grim estuary
#

no, i mean putting a debug point in the mixin

#

you should also verify if the mixin is injected at the correct place

#

!!mixinexport

glacial steppeBOT
#
Exporting Mixin Classes

Annotate your Mixin class with @Debug(export = true), which will export the individual Mixin.

Example:

@Debug(export = true)
@Mixin(...)
public class MyMixin {
    // Mixin code here
}

You can export all Mixin classes by adding -Dmixin.debug.export=true to your VM options.

IntelliJ IDEA - Run/debug configurations - More options (See "VM options")
VSCode - Running and debugging Java - Configuration options (See "vmArgs")

Exported finalized classes will appear in run/.mixin.out.

fading jolt
#

I've tried doing this before but I don't have a run folder nor is one generated

#

Found the files

#

So it is injecting into the right spot

#

!bl && (!this.modifyExpressionValue$zkn000$betterhorses$allowHorseArmorCombine(itemStack2.isOf(itemStack3.getItem())) || !this.modifyExpressionValue$zkn000$betterhorses$allowNonDamageableCombine(itemStack2.isDamageable()))

#

The original condition is completely overwritten so the args don't matter

#

and bl doesn't matter either because the right condition is false and its an &&

#

I figured it out

#

Because the inject I was using to debug it canceled at the end of the method

#

The vanilla code wouldn't run

#

and the modify expression doesn't effect the mixin code

#

so it was working but getting canceled before it even ran