Skip to content

Commit

Permalink
Separate
Browse files Browse the repository at this point in the history
  • Loading branch information
yuesha-yc committed Dec 12, 2024
1 parent b0f4641 commit e9f2944
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 100 deletions.
102 changes: 5 additions & 97 deletions src/main/java/com/teammoeg/frostedheart/FHClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,27 @@
import blusunrize.lib.manual.ManualInstance;
import blusunrize.lib.manual.Tree;
import com.teammoeg.frostedheart.compat.ftbq.FHGuiProviders;
import com.teammoeg.frostedheart.compat.ie.FHManual;
import com.teammoeg.frostedheart.compat.tetra.TetraClient;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.GeneratorScreen;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t1.T1GeneratorLogic;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t1.T1GeneratorState;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t2.T2GeneratorLogic;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t2.T2GeneratorState;
import com.teammoeg.frostedheart.content.decoration.RelicChestScreen;
import com.teammoeg.frostedheart.content.incubator.IncubatorT1Screen;
import com.teammoeg.frostedheart.content.incubator.IncubatorT2Screen;
import com.teammoeg.frostedheart.content.research.gui.drawdesk.DrawDeskScreen;
import com.teammoeg.frostedheart.content.scenario.client.gui.layered.font.KGlyphProvider;
import com.teammoeg.frostedheart.content.steamenergy.HeatStatScreen;
import com.teammoeg.frostedheart.content.steamenergy.sauna.SaunaScreen;
import com.teammoeg.frostedheart.content.trade.gui.TradeScreen;
import dev.ftb.mods.ftblibrary.ui.BaseScreen;
import dev.ftb.mods.ftblibrary.ui.MenuScreenWrapper;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import java.util.function.Function;

import static com.teammoeg.frostedheart.FHMain.*;

@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class FHClient {
public FHClient() {

}

private static Tree.InnerNode<ResourceLocation, ManualEntry> CATEGORY;

public static void init() {
IEventBus mod = FMLJavaModLoadingContext.get().getModEventBus();
IEventBus forge = MinecraftForge.EVENT_BUS;
Expand All @@ -73,84 +55,10 @@ public static void init() {
KGlyphProvider.addListener();

LOGGER.info(CLIENT_INIT, "Registering client forge event listeners");
// example: forge.addListener(ModuleClientEventHandler::render);

LOGGER.info(CLIENT_INIT, "Registering client mod event listeners");
mod.addListener(FHClient::setup);
}

public static void setup(FMLClientSetupEvent event) {
LOGGER.info(CLIENT_SETUP, "Setting up client");
FHGuiProviders.setRewardGuiProviders();
FHKeyMappings.init();

// Register screens
MenuScreens.register(FHMenuTypes.GENERATOR_T1.getType(), GeneratorScreen<T1GeneratorState, T1GeneratorLogic>::new);
MenuScreens.register(FHMenuTypes.GENERATOR_T2.getType(), GeneratorScreen<T2GeneratorState, T2GeneratorLogic>::new);
MenuScreens.register(FHMenuTypes.RELIC_CHEST.get(), RelicChestScreen::new);
registerFTBScreen(FHMenuTypes.DRAW_DESK.get(), DrawDeskScreen::new);
registerFTBScreen(FHMenuTypes.TRADE_GUI.get(), TradeScreen::new);
registerFTBScreen(FHMenuTypes.HEAT_STAT.get(), HeatStatScreen::new);
MenuScreens.register(FHMenuTypes.SAUNA.get(), SaunaScreen::new);
MenuScreens.register(FHMenuTypes.INCUBATOR_T1.get(), IncubatorT1Screen::new);
MenuScreens.register(FHMenuTypes.INCUBATOR_T2.get(), IncubatorT2Screen::new);

// Register translucent render type
//TODO: specify in model files
ItemBlockRenderTypes.setRenderLayer(FHBlocks.RYE_BLOCK.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.WHITE_TURNIP_BLOCK.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.WOLFBERRY_BUSH_BLOCK.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.DRAWING_DESK.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.CHARGER.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.MECHANICAL_CALCULATOR.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.STEAM_CORE.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.DEBUG_HEATER.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(FHBlocks.RELIC_CHEST.get(), RenderType.cutout());
// ItemBlockRenderTypes.setRenderLayer(FHBlocks.fluorite_ore.get(), RenderType.cutout());
// ItemBlockRenderTypes.setRenderLayer(FHBlocks.halite_ore.get(), RenderType.cutout());
/*
RenderTypeLookup.setRenderLayer(FHBlocks.blood_block, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.bone_block, RenderType.getCutout());
//RenderTypeLookup.setRenderLayer(FHBlocks.desk, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.small_garage, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.package_block, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.pebble_block, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.odd_mark, RenderType.getCutout());
RenderTypeLookup.setRenderLayer(FHBlocks.wooden_box, RenderType.getCutout());*/


// Register layers

addManual();
if (ModList.get().isLoaded("tetra"))
TetraClient.init();
}

public static void addManual() {
ManualInstance man = ManualHelper.getManual();
CATEGORY = man.getRoot().getOrCreateSubnode(new ResourceLocation(FHMain.MODID, "main"), 110);
{
ManualEntry.ManualEntryBuilder builder = new ManualEntry.ManualEntryBuilder(man);

builder.addSpecialElement(new ManualEntry.SpecialElementData("generator", 0, () -> new ManualElementMultiblock(man, FHMultiblocks.Multiblock.GENERATOR_T1)));
builder.readFromFile(new ResourceLocation(FHMain.MODID, "generator"));
man.addEntry(CATEGORY, builder.create(), 0);
}
{
ManualEntry.ManualEntryBuilder builder = new ManualEntry.ManualEntryBuilder(man);
builder.addSpecialElement(new ManualEntry.SpecialElementData("generator_2", 0, () -> new ManualElementMultiblock(man, FHMultiblocks.Multiblock.GENERATOR_T2)));
builder.readFromFile(new ResourceLocation(FHMain.MODID, "generator_t2"));
man.addEntry(CATEGORY, builder.create(), 1);
}
}

public static <C extends AbstractContainerMenu, S extends BaseScreen> void
registerFTBScreen(MenuType<C> type, Function<C, S> factory) {
MenuScreens.register(type, FTBScreenFactory(factory));
}

public static <C extends AbstractContainerMenu, S extends BaseScreen> MenuScreens.ScreenConstructor<C, MenuScreenWrapper<C>>
FTBScreenFactory(Function<C, S> factory) {
return (c, i, t) -> new MenuScreenWrapper<>(factory.apply(c), c, i, t).disableSlotDrawing();
}
}
5 changes: 4 additions & 1 deletion src/main/java/com/teammoeg/frostedheart/FHMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
Expand Down Expand Up @@ -191,7 +192,9 @@ public FHMain() {

// Client setup
LOGGER.info(COMMON_INIT, "Proceeding to Client Initialization");
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> FHClient::init);
if (FMLEnvironment.dist == Dist.CLIENT) {
FHClient.init();
}
}

/**
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/teammoeg/frostedheart/FHScreens.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.teammoeg.frostedheart;

import com.teammoeg.frostedheart.content.climate.heatdevice.generator.GeneratorScreen;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t1.T1GeneratorLogic;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t1.T1GeneratorState;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t2.T2GeneratorLogic;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t2.T2GeneratorState;
import com.teammoeg.frostedheart.content.decoration.RelicChestScreen;
import com.teammoeg.frostedheart.content.incubator.IncubatorT1Screen;
import com.teammoeg.frostedheart.content.incubator.IncubatorT2Screen;
import com.teammoeg.frostedheart.content.research.gui.drawdesk.DrawDeskScreen;
import com.teammoeg.frostedheart.content.steamenergy.HeatStatScreen;
import com.teammoeg.frostedheart.content.steamenergy.sauna.SaunaScreen;
import com.teammoeg.frostedheart.content.trade.gui.TradeScreen;
import dev.ftb.mods.ftblibrary.ui.BaseScreen;
import dev.ftb.mods.ftblibrary.ui.MenuScreenWrapper;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;

import java.util.function.Function;

public class FHScreens {
public static void init() {
// Register screens
MenuScreens.register(FHMenuTypes.GENERATOR_T1.getType(), GeneratorScreen<T1GeneratorState, T1GeneratorLogic>::new);
MenuScreens.register(FHMenuTypes.GENERATOR_T2.getType(), GeneratorScreen<T2GeneratorState, T2GeneratorLogic>::new);
MenuScreens.register(FHMenuTypes.RELIC_CHEST.get(), RelicChestScreen::new);
registerFTBScreen(FHMenuTypes.DRAW_DESK.get(), DrawDeskScreen::new);
registerFTBScreen(FHMenuTypes.TRADE_GUI.get(), TradeScreen::new);
registerFTBScreen(FHMenuTypes.HEAT_STAT.get(), HeatStatScreen::new);
MenuScreens.register(FHMenuTypes.SAUNA.get(), SaunaScreen::new);
MenuScreens.register(FHMenuTypes.INCUBATOR_T1.get(), IncubatorT1Screen::new);
MenuScreens.register(FHMenuTypes.INCUBATOR_T2.get(), IncubatorT2Screen::new);
}

public static <C extends AbstractContainerMenu, S extends BaseScreen> void
registerFTBScreen(MenuType<C> type, Function<C, S> factory) {
MenuScreens.register(type, FTBScreenFactory(factory));
}

public static <C extends AbstractContainerMenu, S extends BaseScreen> MenuScreens.ScreenConstructor<C, MenuScreenWrapper<C>>
FTBScreenFactory(Function<C, S> factory) {
return (c, i, t) -> new MenuScreenWrapper<>(factory.apply(c), c, i, t).disableSlotDrawing();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import dev.ftb.mods.ftblibrary.config.IntConfig;
import dev.ftb.mods.ftblibrary.config.ui.EditStringConfigOverlay;
import dev.ftb.mods.ftbquests.quest.reward.RewardTypes;
import dev.ftb.mods.ftbquests.quest.reward.XPReward;

public class FHGuiProviders {
public static void setRewardGuiProviders() {
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/teammoeg/frostedheart/compat/ie/FHManual.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.teammoeg.frostedheart.compat.ie;

import blusunrize.immersiveengineering.api.ManualHelper;
import blusunrize.immersiveengineering.client.manual.ManualElementMultiblock;
import blusunrize.lib.manual.ManualEntry;
import blusunrize.lib.manual.ManualInstance;
import blusunrize.lib.manual.Tree;
import com.teammoeg.frostedheart.FHMain;
import com.teammoeg.frostedheart.FHMultiblocks;
import net.minecraft.resources.ResourceLocation;

public class FHManual {
private static Tree.InnerNode<ResourceLocation, ManualEntry> CATEGORY;

public static void init() {
ManualInstance man = ManualHelper.getManual();
CATEGORY = man.getRoot().getOrCreateSubnode(new ResourceLocation(FHMain.MODID, "main"), 110);
{
ManualEntry.ManualEntryBuilder builder = new ManualEntry.ManualEntryBuilder(man);

builder.addSpecialElement(new ManualEntry.SpecialElementData("generator", 0, () -> new ManualElementMultiblock(man, FHMultiblocks.Multiblock.GENERATOR_T1)));
builder.readFromFile(new ResourceLocation(FHMain.MODID, "generator"));
man.addEntry(CATEGORY, builder.create(), 0);
}
{
ManualEntry.ManualEntryBuilder builder = new ManualEntry.ManualEntryBuilder(man);
builder.addSpecialElement(new ManualEntry.SpecialElementData("generator_2", 0, () -> new ManualElementMultiblock(man, FHMultiblocks.Multiblock.GENERATOR_T2)));
builder.readFromFile(new ResourceLocation(FHMain.MODID, "generator_t2"));
man.addEntry(CATEGORY, builder.create(), 1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.teammoeg.frostedheart.*;
import com.teammoeg.frostedheart.base.creativeTab.CreativeTabItemHelper;
import com.teammoeg.frostedheart.base.creativeTab.ICreativeModeTabItem;
import com.teammoeg.frostedheart.compat.ftbq.FHGuiProviders;
import com.teammoeg.frostedheart.compat.ie.FHManual;
import com.teammoeg.frostedheart.compat.tetra.TetraClient;
import com.teammoeg.frostedheart.content.climate.particle.SnowParticle;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t1.T1GeneratorRenderer;
import com.teammoeg.frostedheart.content.climate.heatdevice.generator.t2.T2GeneratorRenderer;
Expand Down Expand Up @@ -50,14 +53,31 @@
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.registries.ForgeRegistries;

import static com.teammoeg.frostedheart.FHMain.CLIENT_SETUP;
import static com.teammoeg.frostedheart.FHMain.LOGGER;

/**
* Client side events fired on mod bus.
*/
@Mod.EventBusSubscriber(modid = FHMain.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class FHClientEventsMod {
@SubscribeEvent
public static void setup(FMLClientSetupEvent event) {
LOGGER.info(CLIENT_SETUP, "Setting up client");
FHKeyMappings.init();
if (ModList.get().isLoaded("immersiveengineering"))
FHManual.init();
if (ModList.get().isLoaded("tetra"))
TetraClient.init();
if (ModList.get().isLoaded("ftbquests"))
FHGuiProviders.setRewardGuiProviders();
}

@SubscribeEvent
public static void onCreativeTabContents(BuildCreativeModeTabContentsEvent event) {
CreativeTabItemHelper helper = new CreativeTabItemHelper(event.getTabKey(), event.getTab());
Expand Down

0 comments on commit e9f2944

Please sign in to comment.