Reputation: 31
I had a problem programming my first Minecraft Mod.
Here is the source code:
Events.java:
public class Events {
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent event) {
if(!event.isCancelable() && event.type == ElementType.EXPERIENCE && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
int posX = event.resolution.getScaledWidth() / 2 + 10;
int posY = event.resolution.getScaledHeight() - 48;
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("tc:textures/gui/thermo-icon.png"));
Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect(posX + 9, posY + 3, 0, 9, 71, 3);
}
}
}
So, my problem is that in Minecraft it shows me this:
Note the red ellipse (I added it with GIMP), inside it there is a black rectangle (I haven't added it with GIMP)... it is too small and without texture...
I followed this tutorial (https://www.youtube.com/watch?v=oi41BAlRjtE), but still not working...
Any solution, please?
UPDATE - - - - - -
Thanks all guys for help, I understood that height = 3 pixel is too small... But now I've one more problem...
The light grey rectangle in the center, should be a square, and the black part should be a "circle".
Does anyone know the cause of the wrong proportions? Thanks!
Upvotes: 0
Views: 1881
Reputation: 2337
Too small?
What size were you expecting?
drawTexturedModalRect(posX + 9, posY + 3, 0, 9, 71, 3);
Is it not 71 pixels long and 3 tall... just what you provided? Its hard to tell. Maybe the texture is working but you are offseting it by 9 pixels(when you only draw 3 pixels of it), but it looks like you are using bindTexture wrong. It takes an int returned from getTexture.
int i = mc.renderEngine.getTexture("/Items/GUI/mixer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
There is a nice wiki / tutorial on doing the sort of mods you are doing that might help : http://www.minecraftforge.net/wiki/Gui_Overlay#Mod_Code
Upvotes: 1