Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

  • Author

///////// 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"
    }
}
 

  • Author

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);"

2 minutes ago, Luke6905 said:

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

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

6 minutes ago, Luke6905 said:

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

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

  • Author
2 minutes ago, diesieben07 said:

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

 

9 minutes ago, 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"));
	}
}

 

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

6 minutes ago, Luke6905 said:

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

Forge itself does, again:

4 minutes ago, diesieben07 said:

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

  • Author

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.

6 hours ago, 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.