Jump to content

[1.6.4] Problems with ResourceLocation [coolAlias' tutorial]


Ablaze

Recommended Posts

I was making a new bar, here is the code for my GuiKnowledgeBar which extends Gui.

 

 

 

package com.ablaze.knowledge;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.event.ForgeSubscribe;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiKnowledgeBar extends Gui{
private Minecraft mc;

private static final ResourceLocation texture = new ResourceLocation(KnowledgeMain.MODID, "knowledgebar.png");

public GuiKnowledgeBar(Minecraft mc){
	super();
	this.mc = mc;
}

@ForgeSubscribe
public void onRenderExperienceBar(RenderGameOverlayEvent event){
	if (event.isCancelable() || event.type != ElementType.EXPERIENCE)
	{
	return;
	}

	ExtendedPlayerWithKnowledge ep = ExtendedPlayerWithKnowledge.get(this.mc.thePlayer);

	if (ep == null || ep.getMaxKnowledge() == 0){
		return;
	}

	int xPos = 2;
	int yPos = 2;

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	GL11.glDisable(GL11.GL_LIGHTING);
	this.mc.getTextureManager().bindTexture(texture);

	this.drawTexturedModalRect(xPos, yPos, 0, 0, 11, 4);

	int knowledgebarwidth = (int) (((float) ep.getCurrentKnowledge() / ep.getMaxKnowledge()) * 10);
	System.out.println("[GUI KNOWLEDGE] Current knowledge bar width: " + knowledgebarwidth);
	this.drawTexturedModalRect(xPos + 1, yPos + 1, 0, 5, knowledgebarwidth, 3);

}

}

 

 

 

Here is the stack trace I got-

 

 

2014-02-28 11:04:49 [WARNING] [Minecraft-Client] Failed to load texture: knowledge:knowledgebar.png
java.io.FileNotFoundException: knowledge:knowledgebar.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:52)
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:50)
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:26)
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:69)
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:37)
at com.ablaze.knowledge.GuiKnowledgeBar.onRenderExperienceBar(GuiKnowledgeBar.java:44)
at net.minecraftforge.event.ASMEventHandler_5_GuiKnowledgeBar_onRenderExperienceBar_RenderGameOverlayEvent.invoke(.dynamic)
at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39)
at net.minecraftforge.event.EventBus.post(EventBus.java:108)
at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:874)
at net.minecraftforge.client.GuiIngameForge.renderExperience(GuiIngameForge.java:531)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:150)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1014)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:946)
at net.minecraft.client.Minecraft.run(Minecraft.java:838)
at net.minecraft.client.main.Main.main(Main.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

 

Now I understand that it can't find the file. But what exactly should I use as the location? Where should I place my texture and what should I type here:-

 

 

private static final ResourceLocation texture = new ResourceLocation(KnowledgeMain.MODID, "knowledgebar.png");

 

 

I was following coolAlias' tutorial.

 

Keep in mind I'm using the Gradle system not the Python one.

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

Link to comment
Share on other sites

The structure of your assets folder should not change from Python to Gradle, but the assets folder is now located in src/main/resources/

|__assets/modid/textures/ etc.

 

ModInfo.ID, "knowledgebar.png" tells it to look in assets/modid/ for knowledgebar.png, so you should use

 

ModInfo.ID, "textures/whateverfolderforGUIs/knowledgebar.png"

 

The syntax for ResourceLocation is exactly the same as it always has been.

Link to comment
Share on other sites

The structure of your assets folder should not change from Python to Gradle, but the assets folder is now located in src/main/resources/

|__assets/modid/textures/ etc.

 

ModInfo.ID, "knowledgebar.png" tells it to look in assets/modid/ for knowledgebar.png, so you should use

 

ModInfo.ID, "textures/whateverfolderforGUIs/knowledgebar.png"

 

The syntax for ResourceLocation is exactly the same as it always has been.

 

New line of code

private static final ResourceLocation texture = new ResourceLocation(KnowledgeMain.MODID, "textures/gui/knowledgebar.png");

 

Stacktrace

 

 

2014-02-28 12:17:02 [WARNING] [Minecraft-Client] Failed to load texture: knowledge:textures/gui/knowledgebar.png
java.io.FileNotFoundException: knowledge:textures/gui/knowledgebar.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:52)
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:50)
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:26)
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:69)
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:37)
at com.ablaze.knowledge.GuiKnowledgeBar.onRenderExperienceBar(GuiKnowledgeBar.java:44)
at net.minecraftforge.event.ASMEventHandler_5_GuiKnowledgeBar_onRenderExperienceBar_RenderGameOverlayEvent.invoke(.dynamic)
at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39)
at net.minecraftforge.event.EventBus.post(EventBus.java:108)
at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:874)
at net.minecraftforge.client.GuiIngameForge.renderExperience(GuiIngameForge.java:531)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:150)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1014)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:946)
at net.minecraft.client.Minecraft.run(Minecraft.java:838)
at net.minecraft.client.main.Main.main(Main.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

 

My workspace location (extra info)

Modding/forge_164_963 backup/eclipse

 

My texture location

Modding/forge_164_963 backup/src/main/resources/assets/knowledge/textures/gui/knowledgebar.png

 

Please help.

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

Link to comment
Share on other sites

Please watch LexManos'

on setting up your workspace.

 

It should look like:

 

/modding/SomeMod/src/main/java | resources

/modding/SomeOtherMod/src/main/java | resources

 

There is no longer any reason to use a forge or eclipse folder as your workspace. Create a new workspace and import your project directly.

Link to comment
Share on other sites

Please watch LexManos'

on setting up your workspace.

 

It should look like:

 

/modding/SomeMod/src/main/java | resources

/modding/SomeOtherMod/src/main/java | resources

 

There is no longer any reason to use a forge or eclipse folder as your workspace. Create a new workspace and import your project directly.

 

Is the launch config same in 1.6? I'm out of town now, and my internet connection is terribly slow. So I can't redownload forge. Can you explain the steps of converting my setup into Lex's setup?

Add me on Skype: AblazeTheBest. Send a message saying "#HeyAblaze"

 

Currently: Making a mod!

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.