Make recipe viewer slots more generic and fix some emi stuff#11
Make recipe viewer slots more generic and fix some emi stuff#11gustovafing wants to merge 9 commits intobrachy84:recipeviewersfrom
Conversation
| return this.slotWidget.keyPressed(keyCode, scanCode, modifiers) ? Result.SUCCESS : Result.ACCEPT; | ||
| } | ||
|
|
||
| public static class EmiIngredientHandler { |
There was a problem hiding this comment.
you don't need to put the util methods into an inner class, as this is (should be) only loaded with EMI loaded.
There was a problem hiding this comment.
On second thought, this entire subclass should be calls to EmiStackConverter instead.
| @Override | ||
| public EmiRecipeViewerSlot chance(float chance) { | ||
| this.chance = chance; | ||
| return getThis(); | ||
| } |
There was a problem hiding this comment.
maybe use a fluent accessor for this
| } | ||
|
|
||
| private void rebuildEmiSlot() { | ||
| if (value instanceof ItemEntryList itemEntryList) { |
There was a problem hiding this comment.
Why is this hardcoded to items and fluids?
| } else { | ||
| slotWidget = new TankWidget(EmiIngredientHandler.toEmiIngredient((FluidEntryList)value, chance), 0, 0, 18, 18, 1); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
instead of this, get the list entries' tags and create EMI tag ingredients from those
|
|
||
| public class ReiRecipeViewerSlot { | ||
|
|
||
| public static class ReiIngredientHandler { |
There was a problem hiding this comment.
ditto for the inner class comment
|
|
||
| public class JeiRecipeViewerSlot { | ||
|
|
||
| public static class JeiIngredientHandler { |
There was a problem hiding this comment.
ditto for the inner class comment
| } | ||
|
|
||
| public static Object getJEIFluid(FluidStack fluidStack) { | ||
| return jeiHelpers.getPlatformFluidHelper().create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
why does everything return Object?
| } | ||
|
|
||
| public W value(Component text) { | ||
| key = text; |
There was a problem hiding this comment.
Referencing an object's fields with this.field exists, use it. At least don't remove its uses.
Adds a
RecipeViewerSlotWidgetclass which represents a recipe viewer slot.RecipeViewerSlotWidget.create()creates the appropriate subclass ofRecipeViewerSlotWidgetfor 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.