1717import net .minecraftforge .fml .common .Loader ;
1818import net .minecraftforge .fml .common .Optional ;
1919
20- import java .util .NoSuchElementException ;
21-
2220public class CraftingUnitHandler {
2321
2422 private static final Object2ReferenceMap <SimpleItem , BlockCraftingUnit > CraftingUnitItemMap = new Object2ReferenceOpenHashMap <>();
@@ -77,22 +75,31 @@ private static void registerAE() {
7775 var def = AEApi .instance ().definitions ();
7876 var materials = def .materials ();
7977 var blocks = def .blocks ();
80- addMatch (materials .cell1kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .craftingStorage1k ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
81- addMatch (materials .cell4kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .craftingStorage4k ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
82- addMatch (materials .cell16kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .craftingStorage16k ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
83- addMatch (materials .cell64kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .craftingStorage64k ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
84- addMatch (materials .engProcessor ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .craftingAccelerator ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
78+ blocks .craftingStorage1k ().maybeBlock ()
79+ .ifPresent (b -> addMatch (materials .cell1kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
80+ blocks .craftingStorage4k ().maybeBlock ()
81+ .ifPresent (b -> addMatch (materials .cell4kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
82+ blocks .craftingStorage16k ().maybeBlock ()
83+ .ifPresent (b -> addMatch (materials .cell16kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
84+ blocks .craftingStorage64k ().maybeBlock ()
85+ .ifPresent (b -> addMatch (materials .cell64kPart ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
86+ blocks .craftingAccelerator ().maybeBlock ()
87+ .ifPresent (b -> addMatch (materials .engProcessor ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
8588 }
8689
8790 @ Optional .Method (modid = "nae2" )
8891 private static void registerNAE2 () {
8992 var def = NAE2 .definitions ();
9093 var materials = def .materials ();
9194 var blocks = def .blocks ();
92- addMatch (materials .cellPart256K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .storageCrafting256K ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
93- addMatch (materials .cellPart1024K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .storageCrafting1024K ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
94- addMatch (materials .cellPart4096K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .storageCrafting4096K ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
95- addMatch (materials .cellPart16384K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), blocks .storageCrafting16384K ().maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
95+ blocks .storageCrafting256K ().maybeBlock ()
96+ .ifPresent (b -> addMatch (materials .cellPart256K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
97+ blocks .storageCrafting1024K ().maybeBlock ()
98+ .ifPresent (b -> addMatch (materials .cellPart1024K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
99+ blocks .storageCrafting4096K ().maybeBlock ()
100+ .ifPresent (b -> addMatch (materials .cellPart4096K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
101+ blocks .storageCrafting16384K ().maybeBlock ()
102+ .ifPresent (b -> addMatch (materials .cellPart16384K ().maybeStack (1 ).orElse (ItemStack .EMPTY ), b ));
96103 }
97104
98105 /*
@@ -101,20 +108,23 @@ private static void registerNAE2() {
101108 */
102109 @ Optional .Method (modid = "extracpus" )
103110 private static void registerEXCPU () {
111+ final var block16384k = Block .getBlockFromName ("extracpus:crafting_storage_16384k" );
112+ final Item item ;
104113 if (Loader .isModLoaded ("extracells" )) {
105- Item item = Item .getByNameOrId ("extracells:storage.component" );
106- int i = 0 ;
107- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_256K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
108- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_1024K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
109- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_4096K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
110- addMatch (new ItemStack (item , 1 , i ++), Block .getBlockFromName ("extracpus:crafting_storage_16384k" ));
114+ item = Item .getByNameOrId ("extracells:storage.component" );
111115 } else if (Loader .isModLoaded ("aeadditions" )) {
112- Item item = Item .getByNameOrId ("aeadditions:storage.component" );
113- int i = 0 ;
114- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_256K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
115- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_1024K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
116- addMatch (new ItemStack (item , 1 , i ++), ModBlocks .CRAFTING_STORAGE_4096K .maybeBlock ().orElseThrow (() -> new NoSuchElementException ("Block not registered" )));
117- addMatch (new ItemStack (item , 1 , i ++), Block .getBlockFromName ("extracpus:crafting_storage_16384k" ));
116+ item = Item .getByNameOrId ("aeadditions:storage.component" );
117+ } else {
118+ item = null ;
119+ }
120+ if (item != null ) {
121+ ModBlocks .CRAFTING_STORAGE_256K .maybeBlock ()
122+ .ifPresent (b -> addMatch (new ItemStack (item , 1 , 0 ), b ));
123+ ModBlocks .CRAFTING_STORAGE_1024K .maybeBlock ()
124+ .ifPresent (b -> addMatch (new ItemStack (item , 1 , 1 ), b ));
125+ ModBlocks .CRAFTING_STORAGE_4096K .maybeBlock ()
126+ .ifPresent (b -> addMatch (new ItemStack (item , 1 , 2 ), b ));
127+ addMatch (new ItemStack (item , 1 , 3 ), block16384k );
118128 }
119129 }
120130}
0 commit comments