From 2edd540ce051ef91a05d02342abdad56b2e5f21f Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Sat, 3 May 2025 11:16:13 +0800 Subject: [PATCH] fix: only register mte or pipe block/items when necessary --- .../java/gregtech/common/CommonProxy.java | 47 ++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main/java/gregtech/common/CommonProxy.java b/src/main/java/gregtech/common/CommonProxy.java index 59055bb74e1..4675bdf0a15 100644 --- a/src/main/java/gregtech/common/CommonProxy.java +++ b/src/main/java/gregtech/common/CommonProxy.java @@ -88,7 +88,9 @@ public static void registerBlocks(RegistryEvent.Register event) { IForgeRegistry registry = event.getRegistry(); for (MTERegistry r : GregTechAPI.mteManager.getRegistries()) { - registry.register(r.getBlock()); + if (!registry.getKeys().isEmpty()) { + registry.register(r.getBlock()); + } } StoneType.init(); @@ -122,9 +124,21 @@ public static void registerBlocks(RegistryEvent.Register event) { } } - for (BlockCable cable : CABLES.get(materialRegistry.getModid())) registry.register(cable); - for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) registry.register(pipe); - for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) registry.register(pipe); + for (BlockCable cable : CABLES.get(materialRegistry.getModid())) { + if (!cable.getEnabledMaterials().isEmpty()) { + registry.register(cable); + } + } + for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) { + if (!pipe.getEnabledMaterials().isEmpty()) { + registry.register(pipe); + } + } + for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) { + if (!pipe.getEnabledMaterials().isEmpty()) { + registry.register(pipe); + } + } } for (BlockOpticalPipe pipe : OPTICAL_PIPES) registry.register(pipe); for (BlockLaserPipe pipe : LASER_PIPES) registry.register(pipe); @@ -235,16 +249,27 @@ public static void registerItems(RegistryEvent.Register event) { GTRecipeManager.preLoad(); for (MTERegistry r : GregTechAPI.mteManager.getRegistries()) { - registry.register(createItemBlock(r.getBlock(), MachineItemBlock::new)); + if (!r.getKeys().isEmpty()) { + registry.register(createItemBlock(r.getBlock(), MachineItemBlock::new)); + } } for (MaterialRegistry materialRegistry : GregTechAPI.materialManager.getRegistries()) { - for (BlockCable cable : CABLES.get(materialRegistry.getModid())) - registry.register(createItemBlock(cable, ItemBlockCable::new)); - for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) - registry.register(createItemBlock(pipe, ItemBlockFluidPipe::new)); - for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) - registry.register(createItemBlock(pipe, ItemBlockItemPipe::new)); + for (BlockCable cable : CABLES.get(materialRegistry.getModid())) { + if (!cable.getEnabledMaterials().isEmpty()) { + registry.register(createItemBlock(cable, ItemBlockCable::new)); + } + } + for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) { + if (!pipe.getEnabledMaterials().isEmpty()) { + registry.register(createItemBlock(pipe, ItemBlockFluidPipe::new)); + } + } + for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) { + if (!pipe.getEnabledMaterials().isEmpty()) { + registry.register(createItemBlock(pipe, ItemBlockItemPipe::new)); + } + } } for (BlockOpticalPipe pipe : OPTICAL_PIPES) registry.register(createItemBlock(pipe, ItemBlockOpticalPipe::new)); for (BlockLaserPipe pipe : LASER_PIPES) registry.register(createItemBlock(pipe, ItemBlockLaserPipe::new));