1818import gregtech .api .unification .material .registry .MaterialRegistry ;
1919import gregtech .api .unification .ore .OrePrefix ;
2020import gregtech .api .unification .ore .StoneType ;
21- import gregtech .api .unification .stack .ItemMaterialInfo ;
21+ import gregtech .api .unification .stack .RecyclingData ;
2222import gregtech .api .util .AssemblyLineManager ;
2323import gregtech .api .util .GTLog ;
2424import gregtech .common .blocks .BlockCompressed ;
6464import net .minecraftforge .event .RegistryEvent ;
6565import net .minecraftforge .event .furnace .FurnaceFuelBurnTimeEvent ;
6666import net .minecraftforge .fml .client .event .ConfigChangedEvent ;
67+ import net .minecraftforge .fml .common .FMLCommonHandler ;
6768import net .minecraftforge .fml .common .Loader ;
6869import net .minecraftforge .fml .common .LoaderState ;
6970import net .minecraftforge .fml .common .Mod ;
@@ -88,7 +89,9 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
8889 IForgeRegistry <Block > registry = event .getRegistry ();
8990
9091 for (MTERegistry r : GregTechAPI .mteManager .getRegistries ()) {
91- registry .register (r .getBlock ());
92+ if (!registry .getKeys ().isEmpty ()) {
93+ registry .register (r .getBlock ());
94+ }
9295 }
9396
9497 StoneType .init ();
@@ -101,30 +104,42 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
101104
102105 if (material .hasProperty (PropertyKey .WIRE )) {
103106 for (BlockCable cable : CABLES .get (materialRegistry .getModid ())) {
104- if (! cable .getItemPipeType ( null ). isCable () ||
105- ! material .getProperty (PropertyKey .WIRE ). isSuperconductor ())
106- cable . addCableMaterial ( material , material . getProperty ( PropertyKey . WIRE ));
107+ if (cable .isValidPipeMaterial ( material )) {
108+ cable . addPipeMaterial ( material , material .getProperty (PropertyKey .WIRE ));
109+ }
107110 }
108111 }
109112 if (material .hasProperty (PropertyKey .FLUID_PIPE )) {
110113 for (BlockFluidPipe pipe : FLUID_PIPES .get (materialRegistry .getModid ())) {
111- if (! pipe .getItemPipeType ( pipe . getItem ( material )). getOrePrefix (). isIgnored (material )) {
114+ if (pipe .isValidPipeMaterial (material )) {
112115 pipe .addPipeMaterial (material , material .getProperty (PropertyKey .FLUID_PIPE ));
113116 }
114117 }
115118 }
116119 if (material .hasProperty (PropertyKey .ITEM_PIPE )) {
117120 for (BlockItemPipe pipe : ITEM_PIPES .get (materialRegistry .getModid ())) {
118- if (! pipe .getItemPipeType ( pipe . getItem ( material )). getOrePrefix (). isIgnored (material )) {
121+ if (pipe .isValidPipeMaterial (material )) {
119122 pipe .addPipeMaterial (material , material .getProperty (PropertyKey .ITEM_PIPE ));
120123 }
121124 }
122125 }
123126 }
124127
125- for (BlockCable cable : CABLES .get (materialRegistry .getModid ())) registry .register (cable );
126- for (BlockFluidPipe pipe : FLUID_PIPES .get (materialRegistry .getModid ())) registry .register (pipe );
127- for (BlockItemPipe pipe : ITEM_PIPES .get (materialRegistry .getModid ())) registry .register (pipe );
128+ for (BlockCable cable : CABLES .get (materialRegistry .getModid ())) {
129+ if (!cable .getEnabledMaterials ().isEmpty ()) {
130+ registry .register (cable );
131+ }
132+ }
133+ for (BlockFluidPipe pipe : FLUID_PIPES .get (materialRegistry .getModid ())) {
134+ if (!pipe .getEnabledMaterials ().isEmpty ()) {
135+ registry .register (pipe );
136+ }
137+ }
138+ for (BlockItemPipe pipe : ITEM_PIPES .get (materialRegistry .getModid ())) {
139+ if (!pipe .getEnabledMaterials ().isEmpty ()) {
140+ registry .register (pipe );
141+ }
142+ }
128143 }
129144 for (BlockOpticalPipe pipe : OPTICAL_PIPES ) registry .register (pipe );
130145 for (BlockLaserPipe pipe : LASER_PIPES ) registry .register (pipe );
@@ -235,16 +250,27 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
235250 GTRecipeManager .preLoad ();
236251
237252 for (MTERegistry r : GregTechAPI .mteManager .getRegistries ()) {
238- registry .register (createItemBlock (r .getBlock (), MachineItemBlock ::new ));
253+ if (!r .getKeys ().isEmpty ()) {
254+ registry .register (createItemBlock (r .getBlock (), MachineItemBlock ::new ));
255+ }
239256 }
240257
241258 for (MaterialRegistry materialRegistry : GregTechAPI .materialManager .getRegistries ()) {
242- for (BlockCable cable : CABLES .get (materialRegistry .getModid ()))
243- registry .register (createItemBlock (cable , ItemBlockCable ::new ));
244- for (BlockFluidPipe pipe : FLUID_PIPES .get (materialRegistry .getModid ()))
245- registry .register (createItemBlock (pipe , ItemBlockFluidPipe ::new ));
246- for (BlockItemPipe pipe : ITEM_PIPES .get (materialRegistry .getModid ()))
247- registry .register (createItemBlock (pipe , ItemBlockItemPipe ::new ));
259+ for (BlockCable cable : CABLES .get (materialRegistry .getModid ())) {
260+ if (!cable .getEnabledMaterials ().isEmpty ()) {
261+ registry .register (createItemBlock (cable , ItemBlockCable ::new ));
262+ }
263+ }
264+ for (BlockFluidPipe pipe : FLUID_PIPES .get (materialRegistry .getModid ())) {
265+ if (!pipe .getEnabledMaterials ().isEmpty ()) {
266+ registry .register (createItemBlock (pipe , ItemBlockFluidPipe ::new ));
267+ }
268+ }
269+ for (BlockItemPipe pipe : ITEM_PIPES .get (materialRegistry .getModid ())) {
270+ if (!pipe .getEnabledMaterials ().isEmpty ()) {
271+ registry .register (createItemBlock (pipe , ItemBlockItemPipe ::new ));
272+ }
273+ }
248274 }
249275 for (BlockOpticalPipe pipe : OPTICAL_PIPES ) registry .register (createItemBlock (pipe , ItemBlockOpticalPipe ::new ));
250276 for (BlockLaserPipe pipe : LASER_PIPES ) registry .register (createItemBlock (pipe , ItemBlockLaserPipe ::new ));
@@ -334,7 +360,7 @@ public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
334360 MaterialInfoLoader .init ();
335361
336362 // post an event for addons to modify unification data before base GT registers recycling recipes
337- MinecraftForge .EVENT_BUS .post (new GregTechAPI .RegisterEvent <>(null , ItemMaterialInfo .class ));
363+ MinecraftForge .EVENT_BUS .post (new GregTechAPI .RegisterEvent <>(null , RecyclingData .class ));
338364
339365 GTLog .logger .info ("Registering recipes..." );
340366
@@ -420,9 +446,13 @@ public void onLoadComplete() {
420446 // If JEI and GS is not loaded, refresh ore dict ingredients
421447 // Not needed if JEI is loaded, as done in the JEI plugin (and this runs after that)
422448 // Not needed if GS is loaded, as done after script loads (and this runs after that)
423- if (!GregTechAPI .moduleManager .isModuleEnabled (GregTechModules .MODULE_JEI ) &&
424- !GroovyScriptModule .isCurrentlyRunning ())
425- GTRecipeOreInput .refreshStackCache ();
449+ if (!GroovyScriptModule .isCurrentlyRunning ()) {
450+ // EXCEPTION: IF GrS is not loaded, and JEI is loaded, and we are in a dedicated server env, refresh
451+ // This is due to JEI Plugin Register not taking place on server, and GrS not acting as the backup.
452+ if (!GregTechAPI .moduleManager .isModuleEnabled (GregTechModules .MODULE_JEI ) ||
453+ FMLCommonHandler .instance ().getSide ().isServer ())
454+ GTRecipeOreInput .refreshStackCache ();
455+ }
426456 }
427457
428458 public boolean isFancyGraphics () {
0 commit comments