Skip to content

ModifyExpressionValue over a ternary expression #132

@HotelCalifornia

Description

@HotelCalifornia

For instance in the following expression:

if (random.nextFloat() < (this.level().getDifficulty == Difficulty.HARD ? 0.05F : 0.01F)) {

is it possible to modify the return values of each branch of the ternary, or else the ultimate result of the whole expression?

It seems impossible to match a ternary expression directly given that ? is a wildcard in the Expression DSL, unless I use an Injector and point at the right offset, which seems overly brittle and exactly the kind of thing ModifyExpressionValue was created to solve.

This functionality also seems broadly useful, given that the ternary expression is quite a common pattern (in the Minecraft source, at the very least).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions