Jump to content

[Solved]Texture loading help for a newbie.


bullzeye24

Recommended Posts

Hello, I'm new to minecraft modding, and am relatively new to java as well. I have been working on adding a new item, and the item shows up fine. Its when i get to the texture that i have problems. I've checked the case on all of it and still no luck, so I'm posting here hoping one of you can help me out with this hurdle.

My file directory to the texture

 

Desktop\Gunfactory\src\main\resources\assets\gunfactory\textures\items\sulfur.png

 

My main item class.

 

package com.bullzeye.Gunfactory.Items;

import com.bullzeye.Gunfactory.reference.reference;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class item extends Item {
    public item() {
        super();
    }
    @Override
    public String getUnlocalizedName()
    {
        return String.format("item.%s%s", reference.MOD_ID.toLowerCase()+":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));

    }
    @Override
    public String getUnlocalizedName(ItemStack itemStack)
    {
        return String.format("item.%s%s", reference.MOD_ID.toLowerCase()+":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
    }
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister iconRegister)
    {
        itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(":")+1));
    }
    protected String getUnwrappedUnlocalizedName(String unlocalizedName)
    {
        return unlocalizedName.substring(unlocalizedName.indexOf('.')+1);
    }
    }

 

 

My sulfur class

 

package com.bullzeye.Gunfactory.Items;

import com.bullzeye.Gunfactory.reference.reference;

public class Itemsulfur extends item {
    public Itemsulfur() {
        super();
        this.setUnlocalizedName("sulfur");
    }
}

 

My item registry class

 

package com.bullzeye.Gunfactory.init;

import com.bullzeye.Gunfactory.Items.Itemsulfur;
import com.bullzeye.Gunfactory.Items.item;
import cpw.mods.fml.common.registry.GameRegistry;

public class moditems {
    public static final item Sulfur = new Itemsulfur();
    public static void init(){
        GameRegistry.registerItem(Sulfur,"Sulfur");
    }
}

 

My error

 

[Client thread/ERROR]: Using missing texture, unable to load minecraft:textures/items/sulfur.png

java.io.FileNotFoundException: minecraft:textures/items/sulfur.png

 

 

Any and all help is appreciated. Thanks in advance :)

Link to comment
Share on other sites

Oh god.  I've seen this code before.

 

And it's a terrible, terrible way to do it.

 

Long story short: you're stripping your mod ID from your item's unlocalized name in order to register the texture name, which needs your mod ID.

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

Thanks, i knew something was off. I"ve been following along with Pahimar's lets mod tutorials on youtube, since I'm new to all this. So if i add in the modid to the unlocalized name, it should register the texture?

edit...

Went back and tried it, man your a life saver. it was alot simpler than I thought. I guess I kept over complicating the issue. Thanks again.

Link to comment
Share on other sites

I guess I kept over complicating the issue.

 

No, Pahimar overcomplicated it in an attempt to use two strings for fuckeverything.  Rather than doing it in a straightforward way that was easy to understand.

 

setUnlocalizedName("myThing");
setTextureName("myThingsTexture");

 

But no, he had to override getUnlocalizedName so that it would strip out the extra copy of the modID, then add it back in differently for texture registration...

 

It's so bad that nearly all the veterans around here recognize his work on sight.

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

Wow, here i was thinking that it was the right way.. lol . Thanks for opening my eyes to this. I wish i would have seen it sooner. Seems pointless to do all that when you can do it much simpler. I'm going to rewrite it, and get rid of all the excess garbage.

Link to comment
Share on other sites

Wow, here i was thinking that it was the right way.. lol . Thanks for opening my eyes to this. I wish i would have seen it sooner. Seems pointless to do all that when you can do it much simpler. I'm going to rewrite it, and get rid of all the excess garbage.

 

Its not pointless.  It's so that he can change a single string instance and have it update across all usage.  Just that for unlocalized names and file references...you'd then have to update your lang file and file name.  If you really want to rename the block...its not that difficult.

 

The problem is that the way he does it is not newbie friendly.  A fresh hand at modding will see the line and go "ooh magic code..." and not understand what it does so when things go unexpected, they don't understand why.

 

"I told it to use texture name 'sulfur,' it's looking for minecraft:sulfur and can't find it" is a lot easier to solve when you realize you didn't specify your mod-ID.  There's a cause-effect relationship rather than four lines of gibberish.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello...I got a crash, "The game crashed whilst rendering entity in world Error: java.lang.IllegalArgumentException: Duplicate delegates" In game I was walking upstairs in a house, and it suddenly crashed on me. Now it keeps crashing when I try to enter that world. I tried to give more RAM by changing it to 4...I'm not really wanting to get rid of any of the mods I have if possible. I'm absolutely clueless about crashes and whatnot...can anyone tell me what's gone wrong? This is the pastebin crash report Here Let me know if I need to include anything else
    • Hello!! Waiting around 45 seconds to reply can be a drag, especially when you're in the middle of a conversation. It might be worth looking into whether the forum software can tweak things a bit. Like maybe active members could have a shorter delay or none at all, while newbies or less active folks still have to wait. I don't have the power to change this myself, but I'll mention it to the forum mods.  Hang in there!
    • HELLO!! With your setup, you should be getting better performance. Try using Minecraft version 1.12.2 or 1.16.5 for better mod compatibility. I personally advice you to have the latest Optifine installed and tweak settings like lowering render distance and graphics. Also, consider using performance mods like Sodium and updating your GPU drivers. Allocating 4-8 GB RAM in the launcher might help too. Good luck!
    • Getting back into modding, the last time I seriously modded was almost 6 years ago.  I'm pretty rusty and a lot has changed.  What I'm trying to do right now is right a method that can remove an item's recipe using only said item's ResourceLocation as an input. From what I've gathered from older examples online it seems like the preferred method to do this involves using a DummyRecipe as that breaks the least amount of stuff (such as achievements related to a given item). The problem I'm having is that most of these examples are quite dated, usually being for 1.12. It seems that enough of the methods have changed for 1.18.2 forge that the implementation will be quite different, and that is what I'm struggling with so right now.  The basic concepts are still the same, but some of the classes I need to reference and what methods are where on said classes has been swapped around, and its giving me trouble.   I'm sure I could figure it out after a few days, but I figured it would make sense to ask for help as that may expedite the process.   Thanks in advance.
    • i getting same issue with my modpack so how can find the which mod not incompatible with i like wood, i removed variant vanilla mod because was most sense but still red loading screen and closing with world generating screen appering without crash. anyone can help me?
  • Topics

×
×
  • Create New...

Important Information

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