Skip to content

Expose deferred holders as public fields - #11

Merged
CaitlynMainer merged 3 commits into
CaitlynMainer:main-MC1.21.1from
SquidDev:squid/registration-tweaks
Aug 5, 2026
Merged

Expose deferred holders as public fields #11
CaitlynMainer merged 3 commits into
CaitlynMainer:main-MC1.21.1from
SquidDev:squid/registration-tweaks

Conversation

@SquidDev

@SquidDev SquidDev commented Aug 5, 2026

Copy link
Copy Markdown

Currently all item references in OpenComputers ends up going through the public ItemInfo API, for instance Items.get(Constants.ItemName.ServerTier1).item(). This is pretty verbose, inefficient (requires two map lookups on string keys) and not really in keeping with how most mods do things.

Instead, we move every item to be a field, meaning the items can just be accessed via Items.ServerTier1.get().

The entire diff here is just the following repeated for every block/item in the mod, hence it being a bit verbose.

- registerItem(new item.CuttingWire(defaultProps), Constants.ItemName.CuttingWire)
+ val CuttingWire: DeferredItem[item.CuttingWire] = registerItem(new item.CuttingWire(defaultProps), Constants.ItemName.CuttingWire)

This change was mostly motivated by a second PR I have for data-generation, where there's a lot of references to blocks/items.

IMO it's worth getting rid of the whole ItemInfo system (just look up the entries from the registry directly if you need them!), but that's a much bigger change and worth discussing first.

@SquidDev
SquidDev force-pushed the squid/registration-tweaks branch from 635159a to 474644e Compare August 5, 2026 15:56
@CaitlynMainer
CaitlynMainer merged commit aa08538 into CaitlynMainer:main-MC1.21.1 Aug 5, 2026
@SquidDev
SquidDev deleted the squid/registration-tweaks branch August 5, 2026 16:01
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