Jump to content

[1.12] [Fixed] Assets not showing up on in-game item.


I'veGotNoName

Recommended Posts

I've been following this tutorial on youtube and I've been having trouble with things I put into assets folders actually doing anything to my items. To clarify, I have my en_US.lang, johncena.json, and johncena.png files in my resources like the image shows, but when I launch the game, my item still shows up as item.johncena.name and has no texture.

 

(If anyone wonders, "johncena" was my idea of a joke :S)

assetserror.PNG

Edited by I'veGotNoName
Link to comment
Share on other sites

Here's a few things that could be wrong:
1. Your mod id isn't "m1". In that case, change the "assets/m1" folder name accordingly.
2. Your item's registry name isn't "johncena". If it isn't, either change the model name or the registry name to match.
3. Your lang and/or model file could be formatted incorrectly. Post them here or on a service like pastebin so I can make sure they're correct.
 

And just a tip: the unlocalized name should be unique from any other mod. I'd reccomend changing it to "<modid>.johncena" to avoid conflicts with any other mod.

 

EDIT: Looking at this tutorial, it seems to use some old ways of registering items and models, the latter of which could be causing your model problem. For items, you should listen on the RegistryEvent.Register<Item> event (make a method with this type as a parameter, annotate the method with @EventSubscriber, and annotate the class with @Mod.EventBusSubscriber) and call "event.getRegistry().register(item)". Likewise, you should listen on the ModelRegistryEvent and use ModelLoader.setCustomModelResourceLocation instead of Minecraft.getMinecraft().getRenderItem()... for your item models. Also, the first parameter should just be "item.getRegistryName" instead of manually putting it together.

Edited by TheReturningVoid
Link to comment
Share on other sites

Firstly, in 1.11 and above, all your asset filenames must be lower case; I see you have en_US.lang, which won't work. That's why the item name isn't being translated properly.
 

As for why the model isn't loading, I can't watch the full video now, but if it's using outdated registration methods, you may want to update to the modern Registry Events and see if that solves your problem. If not, post the code in your .json model file for us to debug.

(Also, a common issue is forgetting to include the namespaces in your model file's paths, so make sure you're doing that!)

Edited by IceMetalPunk

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

3 minutes ago, IceMetalPunk said:

Firstly, in 1.11 and above, all your asset filenames must be lower case; I see you have en_US.lang, which won't work. That's why the item name isn't being translated properly.

I don't think that's correct (or it doesn't apply to localization files at least); I'm using a file with the same name which works fine in 1.12.

Link to comment
Share on other sites

Just now, TheReturningVoid said:

I don't think that's correct (or it doesn't apply to localization files at least); I'm using a file with the same name which works fine in 1.12.

It depends. If you don't have a pack.mcmeta file using format 3, then Forge will try to adapt and use a legacy parser that allows mixed-case filenames. But that's poor practice, and you should be using the modern standards with the pack.mcmeta format and all lowercase names.

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

Just now, IceMetalPunk said:

It depends. If you don't have a pack.mcmeta file using format 3, then Forge will try to adapt and use a legacy parser that allows mixed-case filenames. But that's poor practice, and you should be using the modern standards with the pack.mcmeta format and all lowercase names.

I was completely unaware of the existence of pack.mcmeta :P I'll have to look into that.

Link to comment
Share on other sites

13 hours ago, TheReturningVoid said:

Here's a few things that could be wrong:
1. Your mod id isn't "m1". In that case, change the "assets/m1" folder name accordingly.
2. Your item's registry name isn't "johncena". If it isn't, either change the model name or the registry name to match.
3. Your lang and/or model file could be formatted incorrectly. Post them here or on a service like pastebin so I can make sure they're correct.
 

And just a tip: the unlocalized name should be unique from any other mod. I'd reccomend changing it to "<modid>.johncena" to avoid conflicts with any other mod.

 

EDIT: Looking at this tutorial, it seems to use some old ways of registering items and models, the latter of which could be causing your model problem. For items, you should listen on the RegistryEvent.Register<Item> event (make a method with this type as a parameter, annotate the method with @EventSubscriber, and annotate the class with @Mod.EventBusSubscriber) and call "event.getRegistry().register(item)". Likewise, you should listen on the ModelRegistryEvent and use ModelLoader.setCustomModelResourceLocation instead of Minecraft.getMinecraft().getRenderItem()... for your item models. Also, the first parameter should just be "item.getRegistryName" instead of manually putting it together.

I changed my previous Item Initialization to this. However, I now have a problem with my registry handler. Pics are attached, the one with events in it is the new one. I'm not sure what do to from here now that the register method is gone, and to be honest, I probably completely misunderstood what you were trying to tell me in your edit. Thank you in advance. My source is attached to this post if you want it. Also, my johncena.json and en_US.lang files are also attached if you don't feel like extracting my src. 

 

src.zip

en_US.lang

johncena.json

iteminitprevious.PNG

newiteminit.PNG

registryhandler error.PNG

Edited by I'veGotNoName
Link to comment
Share on other sites

You have deleted the register method, but you are still referencing it. Remove the references to the method. You should really use refactor to delete/move methods anyway.

 

If you are using 1.12 you should use ObjectHolders. Do not assign values to your item fields directly.

 

ModelLoader.setCustomModelResourceLocation(johncena, 0, (ModelResourceLocation) johncena.getRegistryName());

Item::getRegistryName returns you a ResourceLocation, not a ModelResourceLocation, you can't just cast it like this. Instantinate a new ModelResourceLocation object, the first parameter is a ResourceLocation(hint - it is the registry name), the second is your variant(usually it's "inventory" for items.)

 

Assets must be entirely lowercase is 1.12. That includes your language file if you specify your pack format as 3 in your pack.mcmeta. You do. Rename the en_US to en_us then.

 

It is a good practice to use your registry name as the unlocalized name for the item, as it includes your modid and avoids potential conflicts.

Link to comment
Share on other sites

2 hours ago, V0idWa1k3r said:

You have deleted the register method, but you are still referencing it. Remove the references to the method. You should really use refactor to delete/move methods anyway.

 

If you are using 1.12 you should use ObjectHolders. Do not assign values to your item fields directly.

 


ModelLoader.setCustomModelResourceLocation(johncena, 0, (ModelResourceLocation) johncena.getRegistryName());

Item::getRegistryName returns you a ResourceLocation, not a ModelResourceLocation, you can't just cast it like this. Instantinate a new ModelResourceLocation object, the first parameter is a ResourceLocation(hint - it is the registry name), the second is your variant(usually it's "inventory" for items.)

 

Assets must be entirely lowercase is 1.12. That includes your language file if you specify your pack format as 3 in your pack.mcmeta. You do. Rename the en_US to en_us then.

 

It is a good practice to use your registry name as the unlocalized name for the item, as it includes your modid and avoids potential conflicts.

Oh, I know that the reason for the error is the referenced method is now deleted. I thought that I need something in my Registry handler for the client (excuse me if what I just said makes no sense, I was struggling to find words for what I meant.). 

So I deleted the line from my registry handler, and changed 

ModelLoader.setCustomModelResourceLocation(johncena, 0, (ModelResourceLocation) johncena.getRegistryName());

to

ModelLoader.setCustomModelResourceLocation(johncena, 0, new ModelResourceLocation(johncena.getRegistryName(), "inventory"));

I also renamed en_US.lang to en_us.lang.

Worked perfectly, thanks!

2017-07-11_13.40.58.png

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.