Posted February 18, 201411 yr Should i use TickEvent as tickhandler (if yes how) and is it possible to use FMLCommonHandler with onpreclienttick and onpostclienttick? how to register the tickhandler? What about the PickupHandler? Actually i don't know what to write in this signature soooo.... anyway
February 18, 201411 yr http://www.minecraftforge.net/forum/index.php/topic,16506.msg83670.html#msg83670 should get you started
February 18, 201411 yr Author but now i have two codes that i know are used to register event, have i to use both or have i to use one of them? what one? MinecraftForge.EVENT_BUS.register(new mod_Glacia.TickHandlerClient()); or FMLCommonHandler.instance().bus().register(new mod_Glacia.TickHandlerClient()); Actually i don't know what to write in this signature soooo.... anyway
February 18, 201411 yr There are four different buses, two of main interest: Forge events goes on the MinecraftForge.EVENT_BUS FML events go on the FMLCommonHandler bus If you register your event on the wrong bus it won't be called. Easiest way: look to see which package it is in. TickEvent is in package cpw.mods.fml, so use FMLCommonHandler and eg ClientChatReceivedEvent is in net.minecraftforge, so use MinecraftForge -TGG
February 18, 201411 yr Author Is this code good? public static class TickHandlerClient { private GuiScreen lastGuiOpen; @SubscribeEvent public void onTick(TickEvent event) { //CLIENT TICK if (event.type == TickEvent.Type.CLIENT && event.side == Side.CLIENT) { //CLIENT TICK START if (event.phase == TickEvent.Phase.START) { final Minecraft minecraft = FMLClientHandler.instance().getClient(); final WorldClient world = minecraft.theWorld; if (world != null) { if (world.provider instanceof WorldProviderGlacia) { if (world.provider.getSkyRenderer() == null) { world.provider.setSkyRenderer(new GlacialSkyProvider()); } } } } //CLIENT TICK END else { Minecraft minecraft = Minecraft.getMinecraft(); GuiScreen var15 = minecraft.currentScreen; int var14; if (var15 != null) { if (var15 instanceof GuiAchievements) { var14 = ((GuiAchievements)var15).currentPage; if (AchievementPage.getTitle(var14).equals("Glacia")) { minecraft.thePlayer.openGui(mod_Glacia.instance, GlaciaCommonProxy.GUI_ID_ACHIEVEMENTS, minecraft.theWorld, var14, 0, 0); } } if (var15 instanceof GuiAchievementsGlacia) { var14 = ((GuiAchievementsGlacia)var15).currentPage; if (!AchievementPage.getTitle(var14).equals("Glacia")) { GuiAchievements var16 = new GuiAchievements(var15, minecraft.thePlayer.getStatFileWriter()); var16.currentPage = var14; FMLClientHandler.instance().displayGuiScreen(minecraft.thePlayer, var16); } } } } } } } Actually i don't know what to write in this signature soooo.... anyway
February 18, 201411 yr You can subscribe directly to the various TickEvents, rather than the generic TickEvent ServerTickEvent ClientTickEvent WorldTickEvent PlayerTickEvent RenderTickEvent Those are all the tick events available at this time, that I can find, so you can use: @SubscribeEvent public void onTick(ClientTickEvent event) { // codes } http://i.imgur.com/NdrFdld.png[/img]
February 18, 201411 yr Author like this? public static class TickHandlerClient { private GuiScreen lastGuiOpen; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { //CLIENT TICK START if (event.phase == TickEvent.Phase.START) { final Minecraft minecraft = FMLClientHandler.instance().getClient(); final WorldClient world = minecraft.theWorld; if (world != null) { if (world.provider instanceof WorldProviderGlacia) { if (world.provider.getSkyRenderer() == null) { world.provider.setSkyRenderer(new GlacialSkyProvider()); } } } } //CLIENT TICK END else { Minecraft minecraft = Minecraft.getMinecraft(); GuiScreen var15 = minecraft.currentScreen; int var14; if (var15 != null) { if (var15 instanceof GuiAchievements) { var14 = ((GuiAchievements)var15).currentPage; if (AchievementPage.getTitle(var14).equals("Glacia")) { minecraft.thePlayer.openGui(mod_Glacia.instance, GlaciaCommonProxy.GUI_ID_ACHIEVEMENTS, minecraft.theWorld, var14, 0, 0); } } if (var15 instanceof GuiAchievementsGlacia) { var14 = ((GuiAchievementsGlacia)var15).currentPage; if (!AchievementPage.getTitle(var14).equals("Glacia")) { GuiAchievements var16 = new GuiAchievements(var15, minecraft.thePlayer.getStatFileWriter()); var16.currentPage = var14; FMLClientHandler.instance().displayGuiScreen(minecraft.thePlayer, var16); } } } } } } Actually i don't know what to write in this signature soooo.... anyway
February 18, 201411 yr As far as the tick handler part of it is concerned, yeah, that's pretty much it. Why don't you try it and see if it works? Why you would name your variables var15 and such doesn't make much sense to me, but that's your call. http://i.imgur.com/NdrFdld.png[/img]
February 18, 201411 yr Author i can't still test it because it is part of my dimension mod and sill have a lot of codes to fix ps: what can replace Achievement.getName() //<<doesn't exist enymore Actually i don't know what to write in this signature soooo.... anyway
February 19, 201411 yr Hi Just a general suggestion, I find with new code that it's very helpful to try it in small pieces and get it working by itself before I try to integrate it into a bigger project. I keep a separate project called "TestFramework" full of simple classes to test out my new classes and make sure I understand how they work - Item Renderers, Tick Handlers, Tile Entities, etc. Otherwise it just gets too hard to figure out where the bugs are. -TGG
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.