44import com .mojang .blaze3d .vertex .IVertexBuilder ;
55import com .robotgryphon .compactcrafting .CompactCrafting ;
66import com .robotgryphon .compactcrafting .client .render .RenderTickCounter ;
7- import com .robotgryphon .compactcrafting .client .render .RenderTypesExtensions ;
87import com .robotgryphon .compactcrafting .core .Registration ;
98import com .robotgryphon .compactcrafting .recipes .MiniaturizationRecipe ;
109import com .robotgryphon .compactcrafting .recipes .layers .IRecipeLayer ;
1817import mezz .jei .api .recipe .category .IRecipeCategory ;
1918import net .minecraft .block .BlockState ;
2019import net .minecraft .client .Minecraft ;
21- import net .minecraft .client .renderer .*;
20+ import net .minecraft .client .renderer .BlockRendererDispatcher ;
21+ import net .minecraft .client .renderer .IRenderTypeBuffer ;
22+ import net .minecraft .client .renderer .RenderType ;
23+ import net .minecraft .client .renderer .Tessellator ;
2224import net .minecraft .client .renderer .texture .OverlayTexture ;
2325import net .minecraft .client .resources .I18n ;
2426import net .minecraft .item .Item ;
@@ -133,13 +135,19 @@ public void setRecipe(IRecipeLayout recipeLayout, MiniaturizationRecipe recipe,
133135
134136 IGuiItemStackGroup guiItemStacks = recipeLayout .getItemStacks ();
135137 int numComponentSlots = 18 ;
138+ int catalystSlot = -1 ;
139+ try {
140+ addMaterialSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
136141
137- addMaterialSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
138-
139- int catalystSlot = addCatalystSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
142+ catalystSlot = addCatalystSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
140143
141- addOutputSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
144+ addOutputSlots (recipe , GUTTER_X , OFFSET_Y , guiItemStacks , numComponentSlots );
145+ } catch (Exception ex ) {
146+ CompactCrafting .LOGGER .error (recipe .getRegistryName ());
147+ CompactCrafting .LOGGER .error (ex );
148+ }
142149
150+ int finalCatalystSlot = catalystSlot ;
143151 guiItemStacks .addTooltipCallback ((slot , b , itemStack , tooltip ) -> {
144152 if (slot >= 0 && slot < recipe .getComponentKeys ().size ()) {
145153 IFormattableTextComponent text =
@@ -150,7 +158,7 @@ public void setRecipe(IRecipeLayout recipeLayout, MiniaturizationRecipe recipe,
150158 tooltip .add (text );
151159 }
152160
153- if (slot == catalystSlot ) {
161+ if (slot == finalCatalystSlot ) {
154162 IFormattableTextComponent text = new TranslationTextComponent (CompactCrafting .MOD_ID + ".jei.miniaturization.catalyst" )
155163 .mergeStyle (TextFormatting .YELLOW )
156164 .mergeStyle (TextFormatting .ITALIC );
@@ -181,6 +189,7 @@ private void addMaterialSlots(MiniaturizationRecipe recipe, int GUTTER_X, int OF
181189 recipe .getRecipeComponentTotals ()
182190 .entrySet ()
183191 .stream ()
192+ .filter (comp -> comp .getValue () > 0 )
184193 .sorted (Map .Entry .comparingByValue (Comparator .reverseOrder ()))
185194 .forEach ((comp ) -> {
186195 String component = comp .getKey ();
@@ -222,14 +231,14 @@ public boolean handleClick(MiniaturizationRecipe recipe, double mouseX, double m
222231 }
223232
224233 if (layerUp .contains (mouseX , mouseY ) && singleLayer ) {
225- if (singleLayerOffset < recipe .getDimensions ().getYSize () - 1 )
234+ if (singleLayerOffset < recipe .getDimensions ().getYSize () - 1 )
226235 singleLayerOffset ++;
227236
228237 return true ;
229238 }
230239
231240 if (layerDown .contains (mouseX , mouseY ) && singleLayer ) {
232- if (singleLayerOffset > 0 )
241+ if (singleLayerOffset > 0 )
233242 singleLayerOffset --;
234243
235244 return true ;
@@ -240,48 +249,32 @@ public boolean handleClick(MiniaturizationRecipe recipe, double mouseX, double m
240249
241250 @ Override
242251 public void draw (MiniaturizationRecipe recipe , MatrixStack mx , double mouseX , double mouseY ) {
243-
244- // try {
245- // IDrawableBuilder b = guiHelper.drawableBuilder(new ResourceLocation(CompactCrafting.MOD_ID, "block/field_projector"), 16, 16, 16, 16);
246- // IDrawableStatic build = b.build();
247- //
248- // build.draw(mx, 0, 30);
249- // } catch (Exception ex) {
250- // }
251-
252252 AxisAlignedBB dims = recipe .getDimensions ();
253253
254254 IDrawableStatic jei = guiHelper
255255 .drawableBuilder (
256- new ResourceLocation (CompactCrafting .MOD_ID , "textures/nope.png" ),
257- 0 , 0 ,
258- 10 , 10
259- ).setTextureSize (16 , 16 ).build ();
256+ new ResourceLocation (CompactCrafting .MOD_ID , "textures/nope.png" ),
257+ 0 , 0 ,
258+ 10 , 10
259+ ).setTextureSize (16 , 16 ).build ();
260260
261261 jei .draw (mx , explodeToggle .x , explodeToggle .y );
262262
263263 jei .draw (mx , layerSwap .x , layerSwap .y );
264- if (singleLayer ) {
265- if (singleLayerOffset < dims .getYSize () - 1 )
264+ if (singleLayer ) {
265+ if (singleLayerOffset < dims .getYSize () - 1 )
266266 jei .draw (mx , layerUp .x , layerUp .y );
267267
268- if (singleLayerOffset > 0 )
268+ if (singleLayerOffset > 0 )
269269 jei .draw (mx , layerDown .x , layerDown .y );
270270 }
271271
272272 try {
273273 IRenderTypeBuffer .Impl buffers = IRenderTypeBuffer .getImpl (Tessellator .getInstance ().getBuffer ());
274- IVertexBuilder field = buffers .getBuffer (RenderTypesExtensions .PROJECTION_FIELD_RENDERTYPE );
275274 IVertexBuilder lines = buffers .getBuffer (RenderType .getLines ());
276275
277- // drawRect(mx, lines, layerUp, Color.blue);
278- // drawRect(mx, lines, layerSwap, Color.red);
279- // drawRect(mx, lines, layerDown, Color.blue);
280-
281276 mx .push ();
282277
283- // mx.translate(-dims.getXSize()/2, -dims.getYSize() /2 , -dims.getZSize() / 2);
284-
285278 mx .translate (
286279 background .getWidth () / 2 ,
287280 70 ,
0 commit comments