Posted October 24, 20195 yr Hey! I am trying to open a backpack GUI whenever a custom key binding is pressed. The only problem is it seems that ClientTickEvent is not being fired at all. At this point I suspect that I'm ignorant of how events are subscribed. Let me show you my code. PegasusVanguard.java @Mod(PegasusVanguard.ID) public class PegasusVanguard { public static final String ID = "pegasusvanguard"; public static final String VERSION = "1.0"; public static final Logger MOD_LOGGER = LogManager.getLogger(); public PegasusVanguard() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupCommon); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupClient); } @SubscribeEvent public void setupCommon(final FMLCommonSetupEvent event) { long t = System.currentTimeMillis(); MOD_LOGGER.info("Initializing dual-side behaviour..."); //MinecraftForge.EVENT_BUS.register(new EventSubscriber()); ModCapabilities.registerAll(); MOD_LOGGER.info(new StringBuilder("Done! (").append(Long.toString(System.currentTimeMillis() - t)).append("ms)")); } @SubscribeEvent public void setupClient(final FMLClientSetupEvent event) { long t = System.currentTimeMillis(); MOD_LOGGER.info("Initializing client-side behaviour..."); //MinecraftForge.EVENT_BUS.register(new ClientEventSubscriber()); ModKeyBindings.registerAll(); ModScreens.registerAll(); MOD_LOGGER.info(new StringBuilder("Done! (").append(Long.toString(System.currentTimeMillis() - t)).append("ms)")); } } EventSubscriber.java @EventBusSubscriber(modid = PegasusVanguard.ID, bus = EventBusSubscriber.Bus.MOD) public class EventSubscriber { @SubscribeEvent public static void onRegisterBlocks(final RegistryEvent.Register<Block> event) { ModBlocks.registerAll(event); PegasusVanguard.MOD_LOGGER.info("Blocks registered!"); } @SubscribeEvent public static void onRegisterItems(final RegistryEvent.Register<Item> event) { ModItems.registerAll(event); PegasusVanguard.MOD_LOGGER.info("Items registered!"); } @SubscribeEvent public static void onRegisterContainers(final RegistryEvent.Register<ContainerType<?>> event) { ModContainers.registerAll(event); PegasusVanguard.MOD_LOGGER.info("Containers registered!"); } @SubscribeEvent(priority = EventPriority.LOWEST) public static void onPlayerFall(LivingFallEvent event) { if (event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); if (PlayerUtil.isWearing(player, ModItems.getItemStack("armor.airforceboots"))) { event.setDamageMultiplier(0); if (player.isServerWorld()) { Vec3d v = player.getMotion(); player.setVelocity(v.x, -v.y * 10, v.z); player.velocityChanged = true; } } } } } ClientEventSubscriber.java @EventBusSubscriber(modid = PegasusVanguard.ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class ClientEventSubscriber { @SubscribeEvent public static void onKeyInput(TickEvent.ClientTickEvent event) { System.out.println("top notch debugging over here"); if (event.phase == Phase.END && ModKeyBindings.openBackpack.isKeyDown() && Minecraft.getInstance().isGameFocused()) { ModNetworkHandler.CHANNEL.send(PacketDistributor.SERVER.noArg(), new PacketOpenGui(ModReference.Gui.BACKPACK)); } } } The thing is, EventSubscriber code is called and executed normally (blocks and items are registered), but ClientEventSubscriber is not. The onKeyInput method is never reached, and I can't figure out why.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.