123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- package com.zjinja.mcmod.zry_client_utils_mod.events;
- import com.mojang.blaze3d.vertex.PoseStack;
- import com.mojang.logging.LogUtils;
- import com.zjinja.mcmod.zry_client_utils_mod.ZRYClientUtilsMod;
- import com.zjinja.mcmod.zry_client_utils_mod.commands.CommandGetWESelPos;
- import com.zjinja.mcmod.zry_client_utils_mod.commands.CommandMarker;
- import com.zjinja.mcmod.zry_client_utils_mod.commands.CommandReloadConfig;
- import com.zjinja.mcmod.zry_client_utils_mod.cui.CUIRegionManager;
- import com.zjinja.mcmod.zry_client_utils_mod.gui.GuiWEHelpPanel;
- import com.zjinja.mcmod.zry_client_utils_mod.keybinds.KeyBindings;
- import com.zjinja.mcmod.zry_client_utils_mod.marker.MarkerMgr;
- import com.zjinja.mcmod.zry_client_utils_mod.networking.NetworkHandlerWECUI;
- import com.zjinja.mcmod.zry_client_utils_mod.renderer.RenderContext;
- import com.zjinja.mcmod.zry_client_utils_mod.utils.ConfigMgr;
- import com.zjinja.mcmod.zry_client_utils_mod.utils.ZLogUtil;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.LevelRenderer;
- import net.minecraft.client.renderer.culling.Frustum;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraftforge.client.event.*;
- import net.minecraftforge.eventbus.api.SubscribeEvent;
- import net.minecraftforge.fml.common.Mod;
- import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
- public class ClientEvents {
- @Mod.EventBusSubscriber(modid = ZRYClientUtilsMod.MODID, value = Dist.CLIENT)
- public static class ClientForgeEvents{
- @SubscribeEvent
- public static void onKeyInput(InputEvent.Key event){
- var mc = Minecraft.getInstance();
- var player = mc.player;
- if (player == null) {
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.WARN,
- "key-event", "error in onKeyInput event: player is null."
- );
- return;
- }
- if(KeyBindings.KEY_MAPPING_WE_PANEL.consumeClick()){
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.INFO,
- "key-event", "we_panel key pressed."
- );
- mc.setScreen(new GuiWEHelpPanel());
- }
- }
- @SubscribeEvent
- public static void registerClientCommand(RegisterClientCommandsEvent event) {
- new CommandGetWESelPos().register(event.getDispatcher());
- new CommandReloadConfig().register(event.getDispatcher());
- new CommandMarker().register(event.getDispatcher());
- }
- @SubscribeEvent
- public static void loggedIn(ClientPlayerNetworkEvent.LoggingIn event) {
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.INFO,
- "client-logged-in", "Logged into server."
- );
- NetworkHandlerWECUI.onEnterServer();
- }
- @SubscribeEvent
- public static void loggedOut(ClientPlayerNetworkEvent.LoggingOut event) {
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.INFO,
- "client-logged-out", "Logged out of server."
- );
- NetworkHandlerWECUI.onQuitServer();
- }
- @SubscribeEvent
- public static void onRenderLevel(RenderLevelStageEvent event) {
- //if(event.getStage().equals(RenderLevelStageEvent.Stage.AFTER_CUTOUT_MIPPED_BLOCKS_BLOCKS)) {
- if(true) {
- PoseStack ps = event.getPoseStack();
- Frustum fr = event.getFrustum();
- RenderContext rctx = new RenderContext(ps, fr);
- CUIRegionManager.render(rctx);
- MarkerMgr.render(rctx);
- }
- }
- }
- @Mod.EventBusSubscriber(modid = ZRYClientUtilsMod.MODID, value = Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.MOD)
- public static class ClientModBusEvents {
- @SubscribeEvent
- public static void onClientSetup(FMLClientSetupEvent event)
- {
- // Some client setup code
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.INFO,
- "client-setup", "ZRY Client Utils Mod Loaded."
- );
- ConfigMgr cm = ConfigMgr.getInstance();
- if(cm == null) {
- ZLogUtil.log(
- LogUtils.getLogger(), ZLogUtil.Level.INFO,
- "client-setup", "Failed get ConfigMgr: is null."
- );
- }else{
- cm.init();
- }
- NetworkHandlerWECUI.hook();
- }
- @SubscribeEvent
- public static void onKeyRegister(RegisterKeyMappingsEvent event){
- event.register(KeyBindings.KEY_MAPPING_WE_PANEL);
- }
- }
- }
|