Jump to content

[1.7.10] Loading Texture for GUI


Sakul6499

Recommended Posts

Hey,

I want to create a custom GUI for a Block.

 

If I Click the Block it's shows a "Interface" but with Purple and Black Points (like: NoTextureFound)

 

My GUIClass:

public class GUIBasic extends GuiScreen {
public GUIBasic() {

}

@Override
public void drawScreen(int par1, int par2, float par3) {
	this.drawDefaultBackground();

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

	ResourceLocation res = new ResourceLocation(ModMain.MODID + ":" + "assets/textures/gui/GUI_Smasher.png");
	this.mc.getTextureManager().bindTexture(res);

	int xSize = 176;
	int ySize = 214;
	int w = this.width;
	int h = this.height;
	int x = ((w - xSize)  / 2);
	int y = ((h - ySize) / 2);

	drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}

 

The GUI_Smasher.png file exist and can be found under:

resources/assets.usefull_extensions.textures.gui.GUI_Smasher.png

 

xSize and ySize describe the Scale of the Picture...

The Original Picture is scaled by 255 x 255.

 

The Exeption:

java.io.FileNotFoundException: usefull_extensions:assets/userfull_extensions/textures/gui/GUI_Smasher.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:65) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:35) ~[simpleTexture.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) [TextureManager.class:?]
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:45) [TextureManager.class:?]
at de.sakul6499.gui.GUIBasic.drawScreen(GUIBasic.java:25) [GUIBasic.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137) [EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]

 

I think it must be something with the path... but i try'ed something but nothing works :/

Link to comment
Share on other sites

First, remove the "assets/" piece from your resource location.

Second, you want to use the ResourceLocation contructor that requires 2 Strings, the modid and the pth, like so:

new ResourceLocation(ModMain.MODID, "textures/gui/GUI_Smasher.png");

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Second, you want to use the ResourceLocation contructor that requires 2 Strings, the modid and the pth, like so:

new ResourceLocation(ModMain.MODID, "textures/gui/GUI_Smasher.png");

.

 

Both work.

 

You Also dont need to create your resource location every render tick just store it in the class.

I am the author of Draconic Evolution

Link to comment
Share on other sites

Thanks too all!

 

It works!

 

my Class:

package de.sakul6499.GUI;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.inventory.GuiFurnace;
import net.minecraft.util.ResourceLocation;
import de.sakul6499.ExoTech;
import de.sakul6499.Blocks.Blocks;
import de.sakul6499.Blocks.TestBlockTileEntity;

public class BasicGui extends GuiScreen {

private static final ResourceLocation texture = new ResourceLocation(ExoTech.MODID + ":" + "textures/gui/guismasher.png");

int xSize = 176;
int ySize = 214;

@Override
public void drawScreen(int mouseX, int mouseY, float renderParticleTicks) {
	mc.getTextureManager().bindTexture(texture);

	int x = ((this.width - this.xSize) / 2);
	int y = ((this.height - this.ySize) / 2);

	this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}

@Override
public boolean doesGuiPauseGame() {
	return false;
}
}

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.



×
×
  • Create New...

Important Information

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