Skip to content

Make recipe viewer slots more generic and fix some emi stuff#11

Open
gustovafing wants to merge 9 commits intobrachy84:recipeviewersfrom
gustovafing:recipeviewers
Open

Make recipe viewer slots more generic and fix some emi stuff#11
gustovafing wants to merge 9 commits intobrachy84:recipeviewersfrom
gustovafing:recipeviewers

Conversation

@gustovafing
Copy link
Copy Markdown
Contributor

@gustovafing gustovafing commented May 4, 2026

Adds a RecipeViewerSlotWidget class which represents a recipe viewer slot. RecipeViewerSlotWidget.create() creates the appropriate subclass of RecipeViewerSlotWidget for the currently loaded recipe viewer.

Also allows the text widget to get its component from a supplier, to allow for dynamic components to be used as text widgets.

return this.slotWidget.keyPressed(keyCode, scanCode, modifiers) ? Result.SUCCESS : Result.ACCEPT;
}

public static class EmiIngredientHandler {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you don't need to put the util methods into an inner class, as this is (should be) only loaded with EMI loaded.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On second thought, this entire subclass should be calls to EmiStackConverter instead.

Comment on lines +89 to +93
@Override
public EmiRecipeViewerSlot chance(float chance) {
this.chance = chance;
return getThis();
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe use a fluent accessor for this

}

private void rebuildEmiSlot() {
if (value instanceof ItemEntryList itemEntryList) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this hardcoded to items and fluids?

Comment on lines +98 to +99
} else {
slotWidget = new TankWidget(EmiIngredientHandler.toEmiIngredient((FluidEntryList)value, chance), 0, 0, 18, 18, 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also check the cast here, you cannot know what type that object actually is.


if (list instanceof FluidTagList tagList) {
ingredients.addAll(tagList.getEntries().stream()
.map(FluidTagList.FluidTagEntry::stacks)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of this, get the list entries' tags and create EMI tag ingredients from those


public class ReiRecipeViewerSlot {

public static class ReiIngredientHandler {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ditto for the inner class comment


public class JeiRecipeViewerSlot {

public static class JeiIngredientHandler {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ditto for the inner class comment

}

public static Object getJEIFluid(FluidStack fluidStack) {
return jeiHelpers.getPlatformFluidHelper().create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the mod only supports forge/neoforge, you don't need to bother with this; the stack this returns is equal to the one you put in.

.orElse(null);
}

public static @Nullable Object getJEIStackClickable(ItemStack stack, int x, int y, int w, int h) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why does everything return Object?

}

public W value(Component text) {
key = text;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Referencing an object's fields with this.field exists, use it. At least don't remove its uses.

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