Jump to content

Registering/Using ITickHandler


Draco18s

Recommended Posts

Alright, I can't figure this out.

 

I'm trying to add a new HUD item and I have a class that implements ITickHandler and I've registered it with the TickRegistry, but its methods are never called!

 

I have this in my main mod class

TickRegistry.registerTickHandler(new MyGUI(), Side.CLIENT);

 

And this is my GUI class

 

package draco18s.decay.client;

import java.util.EnumSet;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.ScaledResolution;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class OverhealGUI implements ITickHandler {
public Minecraft mc;


public OverhealGUI() {
	mc = Minecraft.getMinecraft();
}

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {

}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	System.out.println("Rendering GUI object");  //this never fires
	ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
	FontRenderer fontrenderer = mc.fontRenderer;
	int width = scaledresolution.getScaledWidth();
	int height = scaledresolution.getScaledHeight();
	mc.entityRenderer.setupOverlayRendering();
	if (type.equals(EnumSet.of(TickType.RENDER)))
	{
		onRenderTick();
	}
}

@Override
public EnumSet<TickType> ticks() {
	return null;
}

@Override
public String getLabel() {
	return null;
}

public void onRenderTick(){}
}

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I don't quite get what you mean, but try looking through the Questology repo. Mainly the HUDOverlayHandler class (something like that) in the client package and some other ones that I can't remember at the time being... I know its some sort of tick handler.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Ok, I've got Questology's code, but I can't get anything to draw.

The only thing I can figure is that it's because net.minecraftforge.client.event.RenderGameOverlayEvent doesn't exist any more.

 

The function is being called, but nothing is getting drawn. :<

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

All I know is that you have to register it... like so:

 

MinecraftForge.EVENT_BUS.register(new HudOverlayHandler());

 

thats keeping to the questology code. Register this wherever you want it to I guess...

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

All I know is that you have to register it... like so:

 

MinecraftForge.EVENT_BUS.register(new HudOverlayHandler());

 

thats keeping to the questology code. Register this wherever you want it to I guess...

 

That part worked fine, the function is being called, but NOTHING IS DRAWN.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Haha.... Oops. I missed that xD

 

I'm not sure why, could you show what you do have? I know you have to have a picture that needs to be drawn onto the screen. I am just not quite sure, wait.

 

Did you get rid of the if statement in front of all the code in the drawing method? I know you most likely have, but its good to be sure... And if you can post the code, I can compare it to mine.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

package draco18s.decay.client;

import org.lwjgl.opengl.GL11;

import draco18s.decay.PositiveDamage;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.client.event.RenderWorldLastEvent;

public class OverhealGUIHandler extends Gui {
private final Minecraft mc = Minecraft.getMinecraft();

@ForgeSubscribe
public void drawOverlay(RenderWorldLastEvent event) {
	System.out.println("Rendering");  //this prints
	mc.renderEngine.bindTexture("/mods/DecayingWorld/textures/gui/overheal.png");
	drawTexturedModalRect(244, 382, 0, 0, 162, 16);
}
}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

hmm.... Maybe try keeping more of there code?

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

None of their code is relevant.  A large percentage of it has to do with Questology's...properties and variables.

Another good portion is drawing some text that I don't need

Of the remainder, it's what I have, plus some GUIscalar code, which shouldn't matter (except that it won't size my GUI object properly unless implemented).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Right. Ok, I don't then... All I know is that mine works :/

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Right. Ok, I don't then... All I know is that mine works :/

Why do you extend Gui?

 

Scratch that, You need this: RenderGameOverlayEvent.Pre or RenderGameOverlayEvent.Post

not the RenderWorldLastEvent

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Right. Ok, I don't then... All I know is that mine works :/

Why do you extend Gui?

 

Scratch that, You need this: RenderGameOverlayEvent.Pre or RenderGameOverlayEvent.Post

not the RenderWorldLastEvent

 

*Cough*

 

The only thing I can figure is that it's because net.minecraftforge.client.event.RenderGameOverlayEvent doesn't exist any more.

 

Untitled.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Your forge is way outdated. Update.

 

Can't update very far, the mod I'm writing needs to work with another mod, which is not compatible past 644 (and I'm on 639).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Then get that guy to update his mod? It shouldn't be your problem...

 

He is updating, and when he updates I'll update my addon.  There's no point in updating my addon before the base mod updates, it would be unusable.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

May I quickly ask, how you made a addon mod. I looked around and theres like nothing on it. I tried to do it myself but the mod I was doing an addon on the files were wierd, and things werent working just right. Is there any thing you saw that shows you how to do this?

Link to comment
Share on other sites

May I quickly ask, how you made a addon mod. I looked around and theres like nothing on it. I tried to do it myself but the mod I was doing an addon on the files were wierd, and things werent working just right. Is there any thing you saw that shows you how to do this?

 

The parent mod needs to have an API.  Very few do, but Mystcraft does (though it's not public; I was messing around doing neat stuff before I was given the API, and a lot of what I've done I've passed back to Mystcraft as starting points for things XCompWiz was going to implement eventually anyway).

 

You might be able to get away with decompiling the original and tying into its classes, then distributing your mod without those classes, but using the required-after dependency.  I haven't tried.  It'd be messy though and subject to easy breaking if the parent mod changes its structure, etc.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.