Skip to content

Commit

Permalink
Fix #117: CPU multi-block structure doesn't render properly when inst…
Browse files Browse the repository at this point in the history
…alled with Xaero's World Map
  • Loading branch information
62832 committed Dec 4, 2024
1 parent b0d6ce5 commit 004c3fd
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/main/java/gripe/_90/megacells/client/MEGACellsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

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;
import net.neoforged.api.distmarker.Dist;
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;
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 004c3fd

Please sign in to comment.