Skip to content

Commit b24ff3e

Browse files
authored
[Fix] Only register mte or pipe block/items when necessary (GregTechCEu#2780)
1 parent b6e7d4c commit b24ff3e

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

src/main/java/gregtech/common/CommonProxy.java

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
8888
IForgeRegistry<Block> registry = event.getRegistry();
8989

9090
for (MTERegistry r : GregTechAPI.mteManager.getRegistries()) {
91-
registry.register(r.getBlock());
91+
if (!registry.getKeys().isEmpty()) {
92+
registry.register(r.getBlock());
93+
}
9294
}
9395

9496
StoneType.init();
@@ -122,9 +124,21 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
122124
}
123125
}
124126

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);
127+
for (BlockCable cable : CABLES.get(materialRegistry.getModid())) {
128+
if (!cable.getEnabledMaterials().isEmpty()) {
129+
registry.register(cable);
130+
}
131+
}
132+
for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) {
133+
if (!pipe.getEnabledMaterials().isEmpty()) {
134+
registry.register(pipe);
135+
}
136+
}
137+
for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) {
138+
if (!pipe.getEnabledMaterials().isEmpty()) {
139+
registry.register(pipe);
140+
}
141+
}
128142
}
129143
for (BlockOpticalPipe pipe : OPTICAL_PIPES) registry.register(pipe);
130144
for (BlockLaserPipe pipe : LASER_PIPES) registry.register(pipe);
@@ -235,16 +249,27 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
235249
GTRecipeManager.preLoad();
236250

237251
for (MTERegistry r : GregTechAPI.mteManager.getRegistries()) {
238-
registry.register(createItemBlock(r.getBlock(), MachineItemBlock::new));
252+
if (!r.getKeys().isEmpty()) {
253+
registry.register(createItemBlock(r.getBlock(), MachineItemBlock::new));
254+
}
239255
}
240256

241257
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));
258+
for (BlockCable cable : CABLES.get(materialRegistry.getModid())) {
259+
if (!cable.getEnabledMaterials().isEmpty()) {
260+
registry.register(createItemBlock(cable, ItemBlockCable::new));
261+
}
262+
}
263+
for (BlockFluidPipe pipe : FLUID_PIPES.get(materialRegistry.getModid())) {
264+
if (!pipe.getEnabledMaterials().isEmpty()) {
265+
registry.register(createItemBlock(pipe, ItemBlockFluidPipe::new));
266+
}
267+
}
268+
for (BlockItemPipe pipe : ITEM_PIPES.get(materialRegistry.getModid())) {
269+
if (!pipe.getEnabledMaterials().isEmpty()) {
270+
registry.register(createItemBlock(pipe, ItemBlockItemPipe::new));
271+
}
272+
}
248273
}
249274
for (BlockOpticalPipe pipe : OPTICAL_PIPES) registry.register(createItemBlock(pipe, ItemBlockOpticalPipe::new));
250275
for (BlockLaserPipe pipe : LASER_PIPES) registry.register(createItemBlock(pipe, ItemBlockLaserPipe::new));

0 commit comments

Comments
 (0)