3030import aztech .modern_industrialization .thirdparty .fabrictransfer .api .fluid .FluidVariant ;
3131import aztech .modern_industrialization .thirdparty .fabrictransfer .api .item .ItemVariant ;
3232import aztech .modern_industrialization .thirdparty .fabrictransfer .api .storage .TransferVariant ;
33- import java .util .List ;
34- import java .util .function .Consumer ;
35- import java .util .stream .Stream ;
3633import mezz .jei .api .gui .builder .IRecipeLayoutBuilder ;
3734import mezz .jei .api .gui .builder .IRecipeSlotBuilder ;
3835import mezz .jei .api .gui .builder .ITooltipBuilder ;
3936import mezz .jei .api .gui .drawable .IDrawable ;
4037import mezz .jei .api .gui .drawable .IDrawableStatic ;
41- import mezz .jei .api .gui .ingredient .IRecipeSlotTooltipCallback ;
42- import mezz .jei .api .gui .ingredient .IRecipeSlotView ;
4338import mezz .jei .api .gui .ingredient .IRecipeSlotsView ;
4439import mezz .jei .api .helpers .IJeiHelpers ;
4540import mezz .jei .api .recipe .IFocusGroup ;
4641import mezz .jei .api .recipe .RecipeIngredientRole ;
4742import mezz .jei .api .recipe .RecipeType ;
48- import mezz .jei .api .recipe .category .IRecipeCategory ;
43+ import mezz .jei .api .recipe .category .AbstractRecipeCategory ;
4944import net .minecraft .client .Minecraft ;
5045import net .minecraft .client .gui .GuiGraphics ;
5146import net .minecraft .network .chat .Component ;
5651import net .neoforged .neoforge .fluids .FluidType ;
5752import org .jetbrains .annotations .Nullable ;
5853
59- class ViewerCategoryJei <D > implements IRecipeCategory <D > {
54+ import java .util .List ;
55+ import java .util .function .Consumer ;
56+ import java .util .stream .Stream ;
57+
58+ class ViewerCategoryJei <D > extends AbstractRecipeCategory <D > {
6059 private final IJeiHelpers helpers ;
6160 public final ViewerCategory <D > wrapped ;
6261 public final RecipeType <D > recipeType ;
63- private final IDrawable background , icon , itemSlot , fluidSlot ;
62+ private final IDrawable fluidSlot ;
6463
6564 public ViewerCategoryJei (IJeiHelpers helpers , ViewerCategory <D > wrapped ) {
65+ super (
66+ RecipeType .create (wrapped .id .getNamespace (), wrapped .id .getPath (), wrapped .dataClass ),
67+ wrapped .title ,
68+ DrawableIcon .create (helpers .getGuiHelper (), wrapped .icon ),
69+ wrapped .width - 8 ,
70+ wrapped .height - 8
71+ );
72+
6673 this .helpers = helpers ;
6774 this .wrapped = wrapped ;
6875 this .recipeType = RecipeType .create (wrapped .id .getNamespace (), wrapped .id .getPath (), wrapped .dataClass );
6976
70- this .background = helpers .getGuiHelper ().createBlankDrawable (wrapped .width - 8 , wrapped .height - 8 );
71- this .icon = wrapped .icon instanceof ViewerCategory .Icon .Stack stack ? helpers .getGuiHelper ().createDrawableItemStack (stack .stack ())
72- : new IDrawable () {
73- @ Override
74- public int getWidth () {
75- return 18 ;
76- }
77-
78- @ Override
79- public int getHeight () {
80- return 18 ;
81- }
82-
83- @ Override
84- public void draw (GuiGraphics guiGraphics , int xOffset , int yOffset ) {
85- var texture = (ViewerCategory .Icon .Texture ) wrapped .icon ;
86- guiGraphics .blit (texture .loc (), xOffset - 1 , yOffset - 1 , 0 , texture .u (), texture .v (), 18 , 18 , 256 , 256 );
87- }
88- };
89- this .itemSlot = helpers .getGuiHelper ().getSlotDrawable ();
90- this .fluidSlot = helpers .getGuiHelper ().createDrawable (MachineScreen .SLOT_ATLAS , 18 , 0 , 18 , 18 );
91- }
92-
93- @ Override
94- public RecipeType <D > getRecipeType () {
95- return recipeType ;
96- }
97-
98- @ Override
99- public Component getTitle () {
100- return wrapped .title ;
101- }
102-
103- @ Override
104- public IDrawable getBackground () {
105- return background ;
106- }
107-
108- @ Override
109- public IDrawable getIcon () {
110- return icon ;
77+ var guiHelper = helpers .getGuiHelper ();
78+ this .fluidSlot = guiHelper .createDrawable (MachineScreen .SLOT_ATLAS , 18 , 0 , 18 , 18 );
11179 }
11280
11381 @ Override
@@ -130,8 +98,9 @@ public void invisibleOutput(ItemStack stack) {
13098 }
13199
132100 private ViewerCategory .SlotBuilder slot (RecipeIngredientRole role , int x , int y ) {
133- var slotBuilder = builder .addSlot (role , x - 4 , y - 4 );
134- slotBuilder .setBackground (itemSlot , -1 , -1 );
101+ var slotBuilder = builder .addSlot (role , x - 4 , y - 4 )
102+ .setStandardSlotBackground ();
103+
135104 return new ViewerCategory .SlotBuilder () {
136105 @ Override
137106 public ViewerCategory .SlotBuilder variant (TransferVariant <?> variant ) {
@@ -150,25 +119,13 @@ public ViewerCategory.SlotBuilder variant(TransferVariant<?> variant) {
150119 }
151120
152121 private static void addProbability (IRecipeSlotBuilder slot , float probability ) {
153- slot .addTooltipCallback (new IRecipeSlotTooltipCallback () {
154- @ Override
155- public void onTooltip (IRecipeSlotView recipeSlotView , List <Component > tooltip ) {
156- var input = recipeSlotView .getRole () == RecipeIngredientRole .INPUT ;
157- var probabilityLine = ViewerUtil .getProbabilityTooltip (probability , input );
158- if (probabilityLine != null ) {
159- tooltip .add (probabilityLine );
160- }
161- }
162-
163- @ Override
164- public void onRichTooltip (IRecipeSlotView recipeSlotView , ITooltipBuilder tooltip ) {
165- var input = recipeSlotView .getRole () == RecipeIngredientRole .INPUT ;
166- var probabilityLine = ViewerUtil .getProbabilityTooltip (probability , input );
167- if (probabilityLine != null ) {
168- tooltip .add (probabilityLine );
169- }
170- }
171- });
122+ slot .addRichTooltipCallback ((recipeSlotView , tooltip ) -> {
123+ var input = recipeSlotView .getRole () == RecipeIngredientRole .INPUT ;
124+ var probabilityLine = ViewerUtil .getProbabilityTooltip (probability , input );
125+ if (probabilityLine != null ) {
126+ tooltip .add (probabilityLine );
127+ }
128+ });
172129 }
173130
174131 @ Override
@@ -218,6 +175,7 @@ public ViewerCategory.SlotBuilder markCatalyst() {
218175
219176 @ Override
220177 public void draw (D recipe , IRecipeSlotsView recipeSlotsView , GuiGraphics guiGraphics , double mouseX , double mouseY ) {
178+ guiGraphics .pose ().pushPose ();
221179 guiGraphics .pose ().translate (-4 , -4 , 0 );
222180
223181 wrapped .buildWidgets (recipe , new ViewerCategory .WidgetList () {
@@ -254,7 +212,7 @@ public void drawable(Consumer<GuiGraphics> widget) {
254212 @ Override
255213 public void item (double x , double y , double w , double h , ItemLike item ) {
256214 guiGraphics .pose ().pushPose ();
257- var drawable = helpers .getGuiHelper ().createDrawableItemStack (item . asItem (). getDefaultInstance () );
215+ var drawable = helpers .getGuiHelper ().createDrawableItemLike (item );
258216 guiGraphics .pose ().translate (x , y , 0 );
259217 guiGraphics .pose ().scale ((float ) w / 16 , (float ) h / 16 , 0 );
260218 drawable .draw (guiGraphics );
@@ -265,6 +223,8 @@ public void item(double x, double y, double w, double h, ItemLike item) {
265223 public void tooltip (int x , int y , int w , int h , List <Component > tooltip ) {
266224 }
267225 });
226+
227+ guiGraphics .pose ().popPose ();
268228 }
269229
270230 @ Override
0 commit comments