Posted July 22, 201312 yr Hello everyone, I am a novice to Forge API. I'm following the tutorials on wiki. Now I'm working on this one: http://www.minecraftforge.net/wiki/Gui_Overlay. When I try to access the texture file saved in the folder of my mod, it works well. package tutorial.generic.client; import java.util.Collection; import java.util.Iterator; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.event.EventPriority; import net.minecraftforge.event.ForgeSubscribe; import org.lwjgl.opengl.GL11; // // GuiBuffBar implements a simple status bar at the top of the screen which // shows the current buffs/debuffs applied to the character. // public class GuiBuffBar extends Gui { private Minecraft mc; public GuiBuffBar(Minecraft mc) { super(); // We need this to invoke the render engine. this.mc = mc; } private static final int BUFF_ICON_SIZE = 18; private static final int BUFF_ICON_SPACING = BUFF_ICON_SIZE + 2; // 2 pixels between buff icons private static final int BUFF_ICON_BASE_U_OFFSET = 0; private static final int BUFF_ICON_BASE_V_OFFSET = 198; private static final int BUFF_ICONS_PER_ROW = 8; // // This event is called by GuiIngameForge during each frame by // GuiIngameForge.pre() and GuiIngameForce.post(). // @ForgeSubscribe(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { // // We draw after the ExperienceBar has drawn. The event raised by GuiIngameForge.pre() // will return true from isCancelable. If you call event.setCanceled(true) in // that case, the portion of rendering which this event represents will be canceled. // We want to draw *after* the experience bar is drawn, so we make sure isCancelable() returns // false and that the eventType represents the ExperienceBar event. if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } // Starting position for the buff bar - 2 pixels from the top left corner. int xPos = 2; int yPos = 2; Collection collection = this.mc.thePlayer.getActivePotionEffects(); if (!collection.isEmpty()) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.func_110434_K().func_110577_a(new ResourceLocation("generic:/textures/gui/inventory.png")); //problem on this line. for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects() .iterator(); iterator.hasNext(); xPos += BUFF_ICON_SPACING) { PotionEffect potioneffect = (PotionEffect) iterator.next(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; if (potion.hasStatusIcon()) { int iconIndex = potion.getStatusIconIndex(); this.drawTexturedModalRect( xPos, yPos, BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_SIZE, BUFF_ICON_SIZE); } } } } } But actually, "Inventory.png" is exactly what I have copied from "assets.minecraft.textures.gui.container" in referenced library "1.6.2.jar". However, when I try this: ...... this.mc.func_110434_K().func_110577_a(new ResourceLocation("minecraft:/textures/gui/container/inventory.png")); ...... There would be: "2013-07-22 21:52:09 [WARNING] [Minecraft-Client] Failed to load texture: minecraft:/textures/gui/container/inventory.png" output in console. Any response will be appreciated. Thanks.
July 29, 201312 yr Having a similar issue. How does one reference to a png in "assets/modid/textures/gui/gui.png" using a ResourceLocation?
July 29, 201312 yr Nevermind I found it. I used "new ResourceLocation(UniversalCoins.modid, "textures/gui/tradeStation.png")"
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.