Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Crafting station - mark missing items in red. #1707

Open
jk1895 opened this issue Aug 11, 2021 · 2 comments
Open

[Suggestion] Crafting station - mark missing items in red. #1707

jk1895 opened this issue Aug 11, 2021 · 2 comments
Labels
type: feature New feature or request

Comments

@jk1895
Copy link

jk1895 commented Aug 11, 2021

Hello,
It would be great if the crafting station would mark missing items in red.
I and I'm sure a lot of others would be very grateful for that.

Thanks a lot

@jk1895 jk1895 added the type: feature New feature or request label Aug 11, 2021
@bruberu
Copy link
Contributor

bruberu commented Aug 11, 2021

In fact, I was already working on implementing this feature in a fork of GTCE, and if enough people want it here, I can easily also bring it to GTCE itself.

@warjort
Copy link
Contributor

warjort commented Aug 12, 2021

This looks like it might be quite complicated to implement.
The issue is that there are three different representations of the crafting recipe items and they are not easily linked because of all the wrapping/delegation.

  • There is the "craftingGrid" which is a collection of SlotWidget wrappers to a forge ItemStackHandler that is used to display the items
  • There is an InventoryCrafting in CraftingRecipeResolver which is used for recipe searches
  • Another InventoryCrafting in CachedRecipeData which is used for caching and validation

Further:

  • The Slots actually used to display the information in ModularUIGui are delegates to the SlotWidgets, but in that code they could be any Slot implementation
  • The actual validation of the recipe is against the cached data (care needs to be taken as incorrect/unexpected handling of this data has led to a few bugs in the past)
  • The validation is currently just a yes/no with no information about which items/slots are invalid
  • The validation is done against a summary "required items" rather than identifying individual slots of the crafting grid (this is so recipes with the same item multiple times validate the total items of that type rather than multiple requests)
  • The items/status of the recipe get updated when inventory changes are detected in the Crafting Station's inventory or connected inventories

So the first issue is how to link the recipes subitems to the slot status on the screen
CachedRecipeData.requiredItems -> CraftingGrid.SlotWidget(s)
This will be required to set the slot status as it changes from missing to present and vice versa
The solution to this is not clear to me.

  • Having the crafting grid pull status from the cached recipe seems easiest, but also inefficient (doing this every render tick). A static link is not possible as the cached data is recreated on change of recipe.
  • The opposite would mean updates are only done when things change, but it introduces a reference to the screen in the recipe handling which would make what is already quite hard to read code even worse.

NOTE: The processing that highlights slots should be clever enough to give an indication of what is missing.
e.g. if you have 8 iron ingots and want to make an iron block (9 ingots), it should only hightlight the last slot, not all of them

The other issue is probably to introduce a "mixin" interface that lets a Slot choose an override background color.
The slot widgets used by the Crafting Station can then provide a red color override if the slot has been flagged as missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants