Skip to content

Commit

Permalink
Move render type init to FMLClientSetupEvent on Forge
Browse files Browse the repository at this point in the history
fixes occasional crash bug
  • Loading branch information
62832 committed Jan 25, 2023
1 parent b5c53b0 commit 45bc0ef
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class MEGACellsClient {
public MEGACellsClient() {
var bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(this::initScreens);
bus.addListener(this::initRenderTypes);
bus.addListener(this::initModels);
bus.addListener(this::initModelRotation);
bus.addListener(this::initItemColors);
Expand All @@ -53,12 +54,16 @@ private void initScreens(FMLClientSetupEvent ignoredEvent) {
"/screens/megacells/mega_pattern_provider.json");
}

private void initRenderTypes(FMLClientSetupEvent ignoredEvent) {
for (var type : MEGACraftingUnitType.values()) {
ItemBlockRenderTypes.setRenderLayer(type.getDefinition().block(), RenderType.cutout());
}
}

private void initModels(ModelEvent.RegisterGeometryLoaders event) {
for (var type : MEGACraftingUnitType.values()) {
event.register("block/crafting/" + type.getAffix() + "_formed",
new SimpleModelLoader<>(() -> new CraftingCubeModel(new MEGACraftingUnitModelProvider(type))));

ItemBlockRenderTypes.setRenderLayer(type.getDefinition().block(), RenderType.cutout());
}

BlockEntityRenderers.register(MEGABlockEntities.MEGA_CRAFTING_MONITOR, CraftingMonitorRenderer::new);
Expand Down

0 comments on commit 45bc0ef

Please sign in to comment.