44import com .robotgryphon .compactcrafting .CompactCrafting ;
55import com .robotgryphon .compactcrafting .recipes .MiniaturizationRecipe ;
66import com .robotgryphon .compactcrafting .recipes .MiniaturizationRecipeManager ;
7+ import com .robotgryphon .compactcrafting .recipes .layers .IDynamicRecipeLayer ;
78import com .robotgryphon .compactcrafting .recipes .layers .IRecipeLayer ;
89import net .minecraft .block .BlockState ;
910import net .minecraft .client .resources .JsonReloadListener ;
1011import net .minecraft .item .ItemStack ;
1112import net .minecraft .profiler .IProfiler ;
1213import net .minecraft .resources .IResourceManager ;
1314import net .minecraft .util .ResourceLocation ;
15+ import net .minecraft .util .math .AxisAlignedBB ;
1416
1517import java .util .Arrays ;
1618import java .util .Collections ;
@@ -110,8 +112,10 @@ private boolean loadCatalyst(MiniaturizationRecipe recipe, JsonObject root) {
110112 }
111113
112114 private boolean loadLayers (MiniaturizationRecipe recipe , JsonObject root ) {
115+ String recipeRegName = recipe .getRegistryName ().toString ();
113116 if (!root .has ("layers" )) {
114- CompactCrafting .LOGGER .debug ("Skipping pattern loading for recipe " + recipe .getRegistryName ().toString () + "; no layers defined." );
117+ String msg = String .format ("Skipping pattern loading for recipe %s; no layers defined." , recipeRegName );
118+ CompactCrafting .LOGGER .debug (msg );
115119 return false ;
116120 }
117121
@@ -124,8 +128,26 @@ private boolean loadLayers(MiniaturizationRecipe recipe, JsonObject root) {
124128 IRecipeLayer [] iRecipeLayers = g .fromJson (layers , IRecipeLayer [].class );
125129 Collections .reverse (Arrays .asList (iRecipeLayers ));
126130
127-
128131 recipe .setLayers (iRecipeLayers );
132+
133+ boolean allDynamic = Arrays .stream (iRecipeLayers ).allMatch (layer -> layer instanceof IDynamicRecipeLayer );
134+ if (allDynamic ) {
135+ if (!root .has ("recipeSize" ))
136+ {
137+ String msg = String .format ("Cannot finish recipe definition for %s: all recipe layers are dynamic and no defined size set (recipeSize)." , recipeRegName );
138+ CompactCrafting .LOGGER .warn (msg );
139+ return false ;
140+ }
141+
142+ try {
143+ int size = root .get ("recipeSize" ).getAsInt ();
144+ recipe .setFluidDimensions (AxisAlignedBB .withSizeAtOrigin (size , size , size ));
145+ } catch (Exception e ) {
146+ CompactCrafting .LOGGER .error ("Error while trying to set fluid recipe dimensions." , e );
147+ return false ;
148+ }
149+ }
150+
129151 return true ;
130152 }
131153
0 commit comments