From 004c3fd799712150059d952987f1711cd14d4582 Mon Sep 17 00:00:00 2001 From: 90 Date: Wed, 4 Dec 2024 13:45:26 +0000 Subject: [PATCH] Fix #117: CPU multi-block structure doesn't render properly when installed with Xaero's World Map --- .../_90/megacells/client/MEGACellsClient.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java b/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java index dbe37b4b..0ed3cbd4 100644 --- a/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java +++ b/src/main/java/gripe/_90/megacells/client/MEGACellsClient.java @@ -2,7 +2,6 @@ import java.util.ArrayList; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.util.FastColor; import net.minecraft.world.level.ItemLike; @@ -10,6 +9,7 @@ import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.neoforge.client.event.EntityRenderersEvent; import net.neoforged.neoforge.client.event.RegisterClientTooltipComponentFactoriesEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; @@ -43,14 +43,24 @@ @Mod(value = MEGACells.MODID, dist = Dist.CLIENT) public class MEGACellsClient { public MEGACellsClient(IEventBus eventBus) { + initCraftingUnitModels(); + eventBus.addListener(MEGACellsClient::initScreens); - eventBus.addListener(MEGACellsClient::initCraftingUnitModels); + eventBus.addListener(MEGACellsClient::initBlockEntityRenderers); eventBus.addListener(MEGACellsClient::initEnergyCellProps); eventBus.addListener(MEGACellsClient::initStorageCellModels); eventBus.addListener(MEGACellsClient::initItemColours); eventBus.addListener(MEGACellsClient::initTooltipComponents); } + private static void initCraftingUnitModels() { + for (var type : MEGACraftingUnitType.values()) { + BuiltInModelHooks.addBuiltInModel( + MEGACells.makeId("block/crafting/" + type.getAffix() + "_formed"), + new CraftingCubeModel(new MEGACraftingUnitModelProvider(type))); + } + } + private static void initScreens(RegisterMenuScreensEvent event) { InitScreens.register( event, @@ -71,16 +81,8 @@ private static void initScreens(RegisterMenuScreensEvent event) { "/screens/megacells/portable_cell_workbench.json"); } - private static void initCraftingUnitModels(FMLClientSetupEvent event) { - event.enqueueWork(() -> { - for (var type : MEGACraftingUnitType.values()) { - BuiltInModelHooks.addBuiltInModel( - MEGACells.makeId("block/crafting/" + type.getAffix() + "_formed"), - new CraftingCubeModel(new MEGACraftingUnitModelProvider(type))); - } - - BlockEntityRenderers.register(MEGABlockEntities.MEGA_CRAFTING_MONITOR.get(), CraftingMonitorRenderer::new); - }); + private static void initBlockEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { + event.registerBlockEntityRenderer(MEGABlockEntities.MEGA_CRAFTING_MONITOR.get(), CraftingMonitorRenderer::new); } private static void initEnergyCellProps(FMLClientSetupEvent event) {