Skip to content

Data driven container compat#87

Open
ZZZank wants to merge 70 commits intoCleanroomMC:masterfrom
ZZZank:data-driven
Open

Data driven container compat#87
ZZZank wants to merge 70 commits intoCleanroomMC:masterfrom
ZZZank:data-driven

Conversation

@ZZZank
Copy link
Copy Markdown
Contributor

@ZZZank ZZZank commented Oct 31, 2024

This PR will allow developers and experienced users to add simple container support without touching any Java code of Bogo.

  • scan for data in ./config/bogosorter/bogo.compat.json in game instance folder and ./bogo.compat.json in eveny valid mod jar
  • conditional support, e.g. add support for IronBackpack only when mod with modid ironbackpack is present.
  • complex condition: currently providing logical operation like not, and, or for combining multiple conditions, and advanced mod condition like RegEx matching for mod version.
  • multiple support presets: generic support, custom slot begin/end and row size, mark only, remove only, mapped
  • more dynamic "mapped" container support: currently allows using advanced condition to filter slots to be added to slot group. We might need some more adaptable Slot->ISlot mapper, blocked by Arcane archive support #82 .
  • button position setter
  • documentation
  • in-game command for setting up template file and performing syntax check
  • data-driven reflection, forming a "access sequence", the sequence must start with the container instance, and ends as an integer, ready for use in container support. Each access in this sequemce should be either getting a field, or invoking an instance method with no arg requirement
  • data-driven ternary operator for more flexibility

@ZZZank ZZZank marked this pull request as ready for review September 11, 2025 16:15
@brachy84
Copy link
Copy Markdown
Member

Overengineered and will never be used by anyone. Perfect

@ZZZank
Copy link
Copy Markdown
Contributor Author

ZZZank commented Sep 11, 2025

The person who opened this PR one year ago didn't realize that developers can use Bogo API via Groovy and/or CrT, so feel free to close this ¯\_(ツ)_/¯

@brachy84
Copy link
Copy Markdown
Member

nah, ill merge it at some point

* @author ZZZank
*/
@Desugar
record AndCond(List<BogoCondition> conditions) implements BogoCondition {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of using records with jabel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using record saves the trouble of manually implementing all-arg constructor, getter, equals and hashcode. So if we are not switching to JVMDowngrader or Lombok, records with Jabel is by far the best solution

* @author ZZZank
*/
class MappedSlotActions {
public static final Map<String, JsonSchema<Function<Slot, ISlot>>> REDUCER_REGISTRY = new LinkedHashMap<>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why linked? This is a hash map zoo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep their order when generating schemas. Not quite useful here, but for filters I want basic filters to come before compound filters (and, or, not).

definitions.put(refKey, inner);

var result = new JsonObject();
result.addProperty("$ref", "#/definitions/" + refKey);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: https://json-schema.org/understanding-json-schema/structuring#dollarref . Example below:

{
    "type": "object",
    "properties": {
        "name": { "type": "string" },
        "address": { "$ref": "#/definitions/address" } // this will be linked to the 'address' below
    },
    "definitions": {
        "address": { // here
            "type": "object",
            "properties": {
                "street": { "type": "string" },
                "city": { "type": "string" }
            }
        }
    }
}

This is equivalent to:

{
    "type": "object",
    "properties": {
        "name": { "type": "string" },
        "address": { // inlined
            "type": "object",
            "properties": {
                "street": { "type": "string" },
                "city": { "type": "string" }
            }
        }
    }
}

I use this for recursive referencing object and breaking large schema into smaller bits

private final boolean includeOrdinal;

private transient final Map<String, T> named;
private transient final List<T> indexed;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a list when we have the array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we dont want to include enum ordinal, we want the len below to be 0:

        for (int i = 0, len = indexed.size(); i < len; i++) {
            enum_.add(i);
        }

we can do this by making the indexed an empty list. This will be harder if we use T[] indexed because we need something like new T[0]

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

Successfully merging this pull request may close these issues.

2 participants