Jump to content

Recommended Posts

Posted

Forge Version [14.21.1.2387]

 

I am having trouble figuring out why my textures are not loading. If I press F3+T in-game the resources reload and the textures display as they should but if i restart the game the textures don't display again. What could be causing this?

 

 

before_texture_reload.PNG

after_texture_reload.PNG

Posted

///////// CODE///////////

public class ItemInit {
    public static ArrayList<esgItem> itemList;

    public static void init() {
        itemList = new ArrayList<esgItem>();
        itemList.add(new ItemRawNaquadah("raw_naquadah"));
        itemList.add(new ItemRawNaquadah("raw_naquadria"));
        itemList.add(new ItemRawNaquadah("raw_trinium"));
    }

    public static void register() {
        // run through and register all items in itemList
        for (esgItem object: itemList) {
            registerItem(object);
        }
    }

    public static void registerItem(esgItem item) {
        ForgeRegistries.ITEMS.register(item);

//        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
//                new ModelResourceLocation(Reference.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
        
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
                new ModelResourceLocation(Reference.MODID + ":" + item.getItemName(), "inventory"));
    }

}

 

///////// MODEL///////////

{
    "parent": "item/generated",
    "textures": {
        "layer0": "esg:items/raw_naquadah"
    }
}
 

Posted

Is this how the model should be registered?

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Reference.MODID + ":" + item.getItemName(), "inventory"));

as for registering the items im unsure as to how to implement the " RegistryEvent.Register<Item> " instead of "ForgeRegistries.ITEMS.register(item);"

Posted
  On 7/8/2017 at 9:40 AM, Luke6905 said:

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Reference.MODID + ":" + item.getItemName(), "inventory"));

Expand  

Yes, but you should use item.getRegistryName() instead of Reference.MODID + ":" + item.getItemName().

  On 7/8/2017 at 9:40 AM, Luke6905 said:

as for registering the items im unsure as to how to implement the " RegistryEvent.Register<Item> " instead of "ForgeRegistries.ITEMS.register(item);"

Expand  

Take a look at this example code:

@Mod.EventBusSubscriber(modid = Reference.MOD_ID)
public class Test {
	public static Item testItem;
	@SubscribeEvent
	public static void registerItems(RegistryEvent.Register<Item> event) {
		event.getRegistry().register(testItem = new Item().setUnlocalizedName("test").setRegistryName("test"));
	}
}

 

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Posted
  On 7/8/2017 at 9:56 AM, diesieben07 said:
Expand  

I have had a look at the docs before coming here, was just getting a bit lost with the whole thing.

 

  On 7/8/2017 at 9:48 AM, Kokkie said:

Yes, but you should use item.getRegistryName() instead of Reference.MODID + ":" + item.getItemName().

Take a look at this example code:

@Mod.EventBusSubscriber(modid = Reference.MOD_ID)
public class Test {
	public static Item testItem;
	@SubscribeEvent
	public static void registerItems(RegistryEvent.Register<Item> event) {
		event.getRegistry().register(testItem = new Item().setUnlocalizedName("test").setRegistryName("test"));
	}
}

 

Expand  

Ok but what is passing the RegistryEvent into 'registerItems'? I think maybe how I have my classes setup is messing with it a bit

Posted
  On 7/8/2017 at 9:59 AM, Luke6905 said:

Ok but what is passing the RegistryEvent into 'registerItems'?

Expand  

Forge itself does, again:

  On 7/8/2017 at 9:56 AM, diesieben07 said:
Expand  

Basically Forge calls every method annotated with @SubscribeEvent and passes the parameter into it...

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Posted

Okay, thank you so much for the help I have it all working now. I was just unfamiliar with all the '@' annotations and how they worked. Making a lot more sense now, cheers.

Posted
  On 7/8/2017 at 10:13 AM, Luke6905 said:

Okay, thank you so much for the help I have it all working now. I was just unfamiliar with all the '@' annotations and how they worked. Making a lot more sense now, cheers.

Expand  

Magic. All that is important to you as the mod developer is that methods marked with certain annotations are called automatically for you. SubscribeEvent and EventHandler are of that type. You only need to tell Forge about the class in some manner (in this case, that's handled by another annotation: @Mod.EventBusSubscriber).

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.

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.