Skip to content

Feat/consume container renderers#91

Open
0xar-ds wants to merge 21 commits intomkram17:v1.0.0from
0xar-ds:feat/consume-container-renderers
Open

Feat/consume container renderers#91
0xar-ds wants to merge 21 commits intomkram17:v1.0.0from
0xar-ds:feat/consume-container-renderers

Conversation

@0xar-ds
Copy link
Collaborator

@0xar-ds 0xar-ds commented Mar 24, 2026

depends on #73

changelog

  • Refactors the ItemButton interface semantics to more proper match how we consume those fields:
    • slotNumber -> slotIndex 110757a
    • wasButtonSlotClicked -> wasButtonClicked 51735e6
  • Refactors the ItemButton's itemstack-retrieving routine to be that of a sealed interface, whereas implementations may consume any of the following:
    • ById, a strategy which is to be consumed by features which resolve their item by identifier. e36cc94
      • The Id lookup & identifier parsing is cached by the item registry
    • Direct, a strategy which is to be consumed by features which resolve their item statically, albeit, it is not configurable. e36cc94
    • Stateful, a strategy which accepts a supplier of state and a StateItemGroup which is generic to the state. It is to be consumed by features which want to shift the button item depending on some state. e36cc94
      • This really is a abstraction which could be convexed/dropped in favor of just if/else'ing at the item ref accessor, but 1) the routines relevant to resolve to a item stack are ran once per frame; 2) hash-map lookups are virtually as fast as a switch/a if condition.
  • Consume Container Renderers on features
  • Slot Providers that this PR consumes were populated by 0xar-ds@5d7129b, and those providers were populated with their feature set by 0xar-ds@c217afa
    • Do note the trailer of that commit, we should really aim to have a sole definition of screens. Whether they'd be static or remote. Also, we should aim with 1:1 looks of the related screen, as filling those item stacks of lore is something that it's done on a sole frame and at a configuration standpoint of the mod: it's better user experience and there are no tradeoffs to it.
  • Input Helpers were refactored to consume List<? @ConfigObject> Update ResourcefulConfig to 3.11.3 (List<? @ConfigObject> support) #90 0xar-ds@3a12471 0xar-ds@ceaf1f4

examples

ItemButton

A feature which consumes the new interface

@Module
public class MyButton extends BUListener implements ItemButton {
    @Override
    public int getSlotIndex() {
        return 0;
    }

    @Override
    public ItemRef getItemRef() {
        return ItemRef.of(Items.BARRIER);
    }

    public MyButton() {}

    @EventHandler
    private void onReplaceItemEvent(ReplaceItemEvent event) {
        if (!shouldReplaceItem(event) || !inCorrectScreen()) return;

        event.setReplacement(getReplacementItem());
    }
}

and allows the user to configure both the index and the button item

@Getter
@ConfigObject
public class MyButton extends BUListener implements ItemButton {
    @ConfigEntry(...)
    @Comment(...)
    @ContainerSlot(...)
    @ConfigOption.Range(...)
    @ConfigOption.Renderer("bazaarutils:slot")
    public int slotIndex;

    @ConfigEntry(...)
    @Comment(...)
    @ConfigOption.Renderer("bazaarutils:item")
    public String itemId = "minecraft:green_stained_glass_pane";

    @Override
    public ItemRef getItemRef() {
        return ItemRef.of(this::getItemId);
    }

    public MyButton() {}

    @EventHandler
    private void onReplaceItemEvent(ReplaceItemEvent event) {
        if (!shouldReplaceItem(event) || !inCorrectScreen()) return;

        event.setReplacement(getReplacementItem());
    }
}

and shifts through state

@Getter
@ConfigObject
public class MyButton extends BUListener implements ItemButton {
    @ConfigEntry(...)
    @Comment(...)
    @ContainerSlot(...)
    @ConfigOption.Range(...)
    @ConfigOption.Renderer("bazaarutils:slot")
    public int slotIndex;

    @ConfigEntry(...)
    @Comment(...)
    @ConfigOption.Renderer("bazaarutils:item")
    public String itemId = "minecraft:green_stained_glass_pane";

    private transient PricingPosition pricingPosition = PricingPosition.MATCHED;

    private static final Set<Item> GLASS_PANES_FAMILY = Set.of(
            Items.GLASS_PANE,
            Items.WHITE_STAINED_GLASS_PANE, Items.ORANGE_STAINED_GLASS_PANE,
            Items.MAGENTA_STAINED_GLASS_PANE, Items.LIGHT_BLUE_STAINED_GLASS_PANE,
            Items.YELLOW_STAINED_GLASS_PANE, Items.LIME_STAINED_GLASS_PANE,
            Items.PINK_STAINED_GLASS_PANE, Items.GRAY_STAINED_GLASS_PANE,
            Items.LIGHT_GRAY_STAINED_GLASS_PANE, Items.CYAN_STAINED_GLASS_PANE,
            Items.PURPLE_STAINED_GLASS_PANE, Items.BLUE_STAINED_GLASS_PANE,
            Items.BROWN_STAINED_GLASS_PANE, Items.GREEN_STAINED_GLASS_PANE,
            Items.RED_STAINED_GLASS_PANE, Items.BLACK_STAINED_GLASS_PANE
    );

    public static final StateItemGroup<PricingPosition> PANE_PRICING_POSITION_GROUP = StateItemGroup.of(GLASS_PANES_FAMILY) // the item family under which this state group activates; if itemId configured is not existential to this group, whichever item was selected is rendered no matter the state. 
        .on(PricingPosition.COMPETITIVE, Items.LIME_STAINED_GLASS_PANE)
        .configured(PricingPosition.MATCHED)   // user's neutral pane shows through when at market
        .on(PricingPosition.OUTBID,   Items.RED_STAINED_GLASS_PANE)
        .build();

     @Override
     public ItemRef getItemRef() {
         return ItemRef.of(
             ItemRef.of(this::getItemId),
             this::getPricingPosition,
             PANE_PRICING_POSITION_GROUP
         );
     }

    public MyButton() {}

    @EventHandler
    private void onReplaceItemEvent(ReplaceItemEvent event) {
        if (!shouldReplaceItem(event) || !inCorrectScreen()) return;

        event.setReplacement(getReplacementItem());
    }
}

renders

hScHx232RejfvsuL zgrHy7YJjCyZPGVe HmZcsxux57NGwphZ HdB46mcD5KSGVQDS 6f6sfSeRf6EoSGJB rTFaUjXERVQTm6bm

0xar-ds added 21 commits March 21, 2026 17:27
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Consuming features/modules can use ResourcefulConfigItems#resolve to not
recompute the identifier parsing & registry lookup of values that are
very much likely to have already been computed

Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Register a custom component, CUSTOM_SLOT_SELECTOR_LOCKED_COMPONENT,
which the custom renderer uses to branch off whether a cell can be
picked/specified.

Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
…strategy

Allows stateful maping between declared groups (configured item is
intrinsic to a group? state can be mapped declaratively through possible
state), item id parsing & direct item access

Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Honestly, we should aim to match 1:1 with the screens users know- color
match, lore lines-alike, etc... These containers are built for a sole
frame and at a configuration point of the mod, so it won't be
performance heavy ever.

also, as commented on the element's PR, it'll be better if we come to
have a sole definition of screen per screen type, we need to do the
refactors needed to bazaarslots/bazaarscreens to source these elements
providers from those existent definitions.
and we could maybe have those bazaarslots/bazaarscreens definitions be
retrieved from a github repository, so that we can fix without updating
if game data ever changes

Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
…ovider

Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
Signed-off-by: 0xar-ds <sadden-rope-sleek@duck.com>
@0xar-ds
Copy link
Collaborator Author

0xar-ds commented Mar 24, 2026

do lmk if you want me to drop stateful item configurations/item groups

@0xar-ds
Copy link
Collaborator Author

0xar-ds commented Mar 24, 2026

@mkram17 if you can merge this and #73 today it'd be greatly appreciated, so we can rebase #87 to v1.0.0 and i can start working on skyblockapi consumptions/redacting the pr

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.

1 participant