Skip to content

Adding the posibility to add custom conditions for custom variants #105

Description

@AngelDGr

Describe the Addition

Currently, it seems that the only available conditions for assigning (or not assigning) new variants to the book are "mod_loaded", "not", "and", and "or".

While this is useful, some of my variants depend on a Forge config, which makes the default system insufficient for my use case.

I managed to add a custom condition using a simple mixin like this:

@Mixin(VariantConditionEvaluator.class)
public class VariantConditionEvaluatorMixin {

    @Inject(method = "evaluate", at = @At("HEAD"), cancellable = true)
    private static void primal$addConfigCondition(JsonObject condition, CallbackInfoReturnable<Boolean> cir) {

        if(condition.get("type").getAsString().equals("is_primal_rabbit_enabled")){
            cir.setReturnValue(Primal_Main.ConfigCache.rabbitModelChange);
        }
    }
}

And my JSON looks like this:

{
  "replace": false,
  "entries": [
    {
      "id": "minecraft:rabbit",
      "conditions": [
        {
          "type": "is_primal_rabbit_enabled"
        }
      ],
      "variants": [
        {
          "id": "gray",
          "nbt": "{RabbitType:7}"
        },
        {
          "id": "sand",
          "nbt": "{RabbitType:8}"
        }
      ]
    }
  ]
}

}

This works well, but it would be great to have a built-in way to define custom conditions.

In any case, I really like how this mod is evolving, and I’m excited about its future!

Screenshots and Videos

No response

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions