Jump to content

Recommended Posts

Posted (edited)

I am trying to get meta items working in 1.12.

Right now I have a basic  meta item setup and use the following code to register my item render:

	public static void registerItemRenderer() {
		for(ItemBasic item : ItemRegistry.items) {
			register(item);
		}
	}

	public static void register(ItemBasic item) {
		//normal items
		if(!item.getHasSubtypes()) {			
			Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
			.register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
		} else {
			NonNullList<ItemStack> list = NonNullList.create();
			item.getSubItems(null, list);
			for(ItemStack stack : list) {
				Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
				.register(item, stack.getItemDamage(), new ModelResourceLocation(item.getRegistryName(), "inventory"));
			}
		}
		

	}

 

which makes sure that my items have the same texture my main item had. The problem is that I have no idea how I can get variants working inside an items json file.

Edited by Jacky2611

Here could be your advertisement!

Posted
  On 7/22/2017 at 6:04 AM, Jacky2611 said:

which makes sure that my items have the same texture my main item had. The problem is that I have no idea how I can get variants working inside an items json

Expand  

This is very important, don't use the ItemModelMesher, instead use the ModelLoader.setCustomModelResourceLocation.

Second register your models in the ModelRegistryEvent.

Third you can call ModelLoader.setCustomModelResourceLocation for the item * the max metadata and append a string that correlates to the sub item/metadata.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 7/22/2017 at 6:10 AM, Animefan8888 said:

This is very important, don't use the ItemModelMesher, instead use the ModelLoader.setCustomModelResourceLocation.

Second register your models in the ModelRegistryEvent.

Third you can call ModelLoader.setCustomModelResourceLocation for the item * the max metadata and append a string that correlates to the sub item/metadata.

Expand  

Didn't know we had register events for the client side too. Thanks. I switched over to ItemModelMesher too. But are you sure that the second argument is supposed to be the max metadata? I think it's supposed to be the current sub items meta, so that variants can be mapped to metadata(numbers).

 

But I didn't actually get the variants working. Sorry if this is something totally obvious, I recently returned to forge and a LOT has changed.

Here are my json file and what I currently use to register my items:

  Reveal hidden contents

Now at least I can put something else than inventory in the last string without mc crashing.

Here could be your advertisement!

Posted
  On 7/22/2017 at 6:40 AM, Jacky2611 said:

I think it's supposed to be the current sub items meta, so that variants can be mapped to metadata(numbers).

Expand  

That is what I meant, but i worded it weirdly.

  On 7/22/2017 at 6:40 AM, Jacky2611 said:

Sorry if this is something totally obvious, I recently returned to forge and a LOT has changed.

Expand  

I understand, and it is kinda obvious, but I did explain it not that well.

Instead of

new ModelResourceLocation(item.getRegistryName(), variantName);

do

new ModelResourceLocation(item.getRegistryName() + "variantName", "inventory");

 

This will require an item model for each metadata at assets/<modid>/models/item/registryName+variantName

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

well yeah, I could create multiple json files. But now that we have to use the json stuff I want to at least use it properly. And I am afraid that I will need a lot of subitems in the future. Creating new json files for each and every one of them would be a nightmare.

Here could be your advertisement!

Posted

Minecraft uses = to separate properties and values in variant strings, not :. Instead of "test:2", use "test=2".

 

If each metadata value has its own variant in the blockstates file, make sure you use that variant in the ModelResourceLocation you pass to ModelLoader.setCustomModelResourceLocation. e.g. Instead of hardcoding "test=2", use "test=" + meta.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 7/22/2017 at 7:25 AM, Choonster said:

Minecraft uses = to separate properties and values in variant strings, not :. Instead of "test:2", use "test=2".

 

If each metadata value has its own variant in the blockstates file, make sure you use that variant in the ModelResourceLocation you pass to ModelLoader.setCustomModelResourceLocation. e.g. Instead of hardcoding "test=2", use "test=" + meta.

Expand  

I tried it with a "=", didn't work either.

The items are just transparent. Any ideas why?

Here could be your advertisement!

Posted
  On 7/22/2017 at 7:37 AM, Jacky2611 said:

I tried it with a "=", didn't work either.

The items are just transparent. Any ideas why?

Expand  

 

Post your model registration code and JSON files (including the and the dimensionshiftmain:item/standard_item model) and the FML log.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Ok: ItemRender thingy:

  Reveal hidden contents

Json:

  Reveal hidden contents

standard:

  Reveal hidden contents


And log

  Reveal hidden contents

 

Edited by Jacky2611

Here could be your advertisement!

Posted
  On 7/22/2017 at 7:43 AM, Jacky2611 said:

And log says that nothing is wrong.

Expand  

Could you also post your Items class, clarify where you put the JSON, make sure the registry name is matching the file name, and you might need to update your forge version I believe there was a bug that would cause the exceptions to not be printed.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

The logging of missing models was broken in Forge 1.12-14.21.0.2363 (commit dc043ac) and fixed in Forge 1.12-14.21.1.2390 (commit ede05a2). Update Forge and run Minecraft again to see the model errors.

 

Where is the dimensionshiftmain:item/standard_item model located? Blockstates files only load models from the models/block directory, so it should be located at assets/dimensionshiftmain/models/block/item/standard_item.json.

 

You should extend minecraft:item/generated instead of copying it.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Ok, gonna update forge. Again.

But I used the same file names and same locations before I gave meta items a try. And back then they worked.

I will report back once I update forge.

Here could be your advertisement!

Posted (edited)

Ok, I updated forge. As far as I can tell there are still no obvious file not found errors. Again, everything worked fine with the same file names back when I only tried to add a normal item.

Here is the new log:

  Reveal hidden contents

My Items Class:

  Reveal hidden contents


Item Basic

  Reveal hidden contents


And my ItemRegistry

  Reveal hidden contents

 

Edited by Jacky2611

Here could be your advertisement!

Posted

I'm not seeing any obvious issues.

 

Is ItemRenderRegister.registerItems being called? Are models being registered for each of your Items? Step through the code in the debugger if you're not sure.

 

I'll need to debug your code locally to help you further. Please create a Git repository of your mod on a site like GitHub (if you haven't already) and link it here. See my repository and its .gitignore file for an example of the structure to use and which files to include.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Right now I am in the process of removing all the unnecessary code I can find to check if any of it interfered with my meta item.

I will check how I can make my bit bucket public once I am back on my PC. And yes all my other items are working (as long as I am not trying to create meta items)

 

 

Here could be your advertisement!

Posted

Ok, so apparently I need my password to access the bitbucket webinterface. Which I only have on my laptop.

I revived my github account and uploaded the project there instead. What I uploaded is the most slimmed down version I could come up with, it should only contain the bare minimum necessary to get MetaItems working.

 

Thanks for helping me btw. Really appreciate it.

Here could be your advertisement!

Posted

I found the issue: glass_bottle_chaos_essence.json uses the Forge blockstates format, but it's located in models/item so Minecraft tries to parse it as an item model rather than a blockstates file. It doesn't have the "parent" or "elements" properties, so it gets parsed as a model with zero elements (annoyingly, Minecraft doesn't detect this as invalid and throw an exception). Since there's zero elements, there's nothing for Minecraft to render and the item appears invisible.

 

You need to move glass_bottle_chaos_essence.json to the blockstates directory. As I said in my previous post, you also need to move standard_item.json to models/block (or a subdirectory) to it can be used by blockstates files. It should also extend minecraft:item/generated instead of copying it.

 

Another issue I noticed is that you're passing null as the CreativeTabs argument of Item#getSubTypes even though it's marked as non-null (by the @ParametersAreNonnullByDefault annotation applied to all vanilla packages). Your IDE should warn you about nullability issues like this. Use CreativeTabs.SEARCH as the default tab for Item#getSubTypes.

 

I also recommend annotating your event handler classes with @Mod.EventBusSubscriber rather than manually registering them with the Forge event bus, but this isn't required.

  • Like 2

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Interesting that I have to place items in the blockstate folder. As far as I can tell Minecraft doesn't have item files in the blockstates folder.

 

And I had a really good reason why I copied the entire generated file instead of extending it, but right now I have absolutely no idea what it was. Thing something else was under some conditions buggy when I didn't put all that stuff into my own file. I will try to extend generated again when I get back to work.

 

Oh, and thanks for pointing out that I could use the search tab. I wasn't sure which one I wanted to use for all my items and in the end I just decided to screw it and override the method in my own item class so that I could ignore the tab.

 

Will report back in a few hours when I wake up again.

Here could be your advertisement!

Posted
  On 7/22/2017 at 4:06 PM, Jacky2611 said:

Interesting that I have to place items in the blockstate folder. As far as I can tell Minecraft doesn't have item files in the blockstates folder.

Expand  

 

Item models loading from blockstates files is a Forge addition, Minecraft itself doesn't allow it.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 7/22/2017 at 3:36 PM, Choonster said:

I found the issue: glass_bottle_chaos_essence.json uses the Forge blockstates format, but it's located in models/item so Minecraft tries to parse it as an item model rather than a blockstates file. It doesn't have the "parent" or "elements" properties, so it gets parsed as a model with zero elements (annoyingly, Minecraft doesn't detect this as invalid and throw an exception). Since there's zero elements, there's nothing for Minecraft to render and the item appears invisible.

Expand  

Sounds like a Forge PR in the making (to at least throw a warning to the log that a model has 0 elements)

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.

Posted

Hahaha! I did it! It works! with just one json file!

 

Turns out that my entire approach was wrong. what I should have used instead was the built in override/predicate stuff.


I rewrote my json to look like this:

  Reveal hidden contents

 created my own property getter:

  Reveal hidden contents

and added it to my item with addPropertyOverride(new ResourceLocation("type"), new SubItemPropertyGetter());

 

And that's all that I had to do! I feel so dumb now. :D

Shouldn't have stayed up so long trying to figure this out yesterday. Thanks for all your ideas guys, really helped to get this working.

 

Now I just have to somehow merge this back into my main project.

Here could be your advertisement!

Posted

That works when the value is natively a number, sure.

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.

Announcements



×
×
  • Create New...

Important Information

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