Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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
Posted (edited)

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.

Posted
  On 7/11/2017 at 1:56 AM, 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.

Expand  

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.

Posted
  On 7/11/2017 at 2:00 AM, 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.

Expand  

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.

Posted
  On 7/11/2017 at 2:02 AM, 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.

Expand  

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

Posted (edited)
  On 7/11/2017 at 12:55 AM, 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.

Expand  

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

en_US.langFetching info...

johncena.jsonFetching info...

iteminitprevious.PNG

newiteminit.PNG

registryhandler error.PNG

Edited by I'veGotNoName
Posted

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.

Posted
  On 7/11/2017 at 2:21 PM, 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.

Expand  

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

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

    • Make a test with another Launcher like the Curseforge Launcher, MultiMC or AT Launcher
    • can anyone help me i am opening forge and add modpacks and then it says unable to update native luancher and i redownlaod java and the luancher it self?
    • The problem occurs also in 1.20.1 Forge, but with an "Error executing task on client" instead. I have "Sinytra Connector" installed. On 1.21.5 Fabric, there is no problem. When this happens, the chat message before the death screen appears gets sent, with an extra dash added.
    • Well, as usual, it was user error. Naming mismatch in sounds.json.  Please delete this post if you find it necessary. 
    • Hello Forge community.  I'm running into an issue with a mod I'm working on.  To preface, I can call /playsound modId:name music @a and I can hear the sound I registered being played in game. Great!  However, I cannot get it to trigger via my mod code.    Registration: public static final RegistryObject<SoundEvent> A_WORLD_OF_MADNESS = SOUND_EVENTS.register("a_world_of_madness", () -> new SoundEvent(new ResourceLocation("tetheredsouls", "a_world_of_madness")));   Playback: Minecraft mc = Minecraft.getInstance(); if (!(mc.player instanceof LocalPlayer) || mc.level == null) return; LocalPlayer player = (LocalPlayer) mc.player; BlockPos pos = player.blockPosition(); SoundEvent track = ModSounds.A_WORLD_OF_MADNESS.get(); System.out.println(track); System.out.println(pos); System.out.println(player); // play exactly like the tutorial: client-only, at the player's position try { mc.level.playLocalSound( player.getX(), player.getY(), player.getZ(), track, SoundSource.MUSIC, // Or MASTER if needed 1f, 1f, false ); System.out.println("[DEBUG] playSound success: " + track.getLocation()); } catch (Exception e) { System.err.println("[ERROR] Failed to play sound: " + track.getLocation()); e.printStackTrace(); } Sounds.json:   { "theme_of_laura": { "category": "music", "sounds": [ { "name": "tetheredsouls:a_world_of_madness", "stream": true } ] } } Things I have tried: - multiple .ogg files. Short .ogg files (5 seconds, <100KB).  - default minecraft sounds imported from import net.minecraft.sounds.SoundEvents; These work given my code. No idea why these are different.  - playSound() method, as well as several others in past iterations that did not work   I would be forever grateful if somebody could point me in the right direction. I've looked at several mod github repositories and found extremely similar code to what I'm doing. I've also found several threads in this forum that did not solve my issue. I just cannot figure out what I'm doing differently, and why I'm able to queue sounds manually with playsound but the code won't play it (despite confirming the code is being run with the debug statements.)
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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