Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2] Item model depending on capability


Recommended Posts

Hello,

So i basically want to create a item with 20 different models.

1. First of all when creating a ModelResourceLocation what is the use of the variant parameter (when registering a item model)?

2. I have a capability added to my item. Can i somehow change the model of the item depending on the capability? The meta won't really work because i need more than 16 models.

Link to post
Share on other sites
46 minutes ago, Meldexun said:

First of all when creating a ModelResourceLocation what is the use of the variant parameter (when registering a item model)?

When only using an item model (not a blockstate) it must be "inventory". Otherwise you can set it to a variant and it will pick that variant from the blockstate json.

 

46 minutes ago, Meldexun said:

I have a capability added to my item. Can i somehow change the model of the item depending on the capability? The meta won't really work because i need more than 16 models.

ItemStack metadata is a full short (16 bits) not just 4 bits (like blocks). If you really do need the full ItemStack to determine the model you can use ModelLoader.setCustomMeshDefinition. Note however that you will then still need to register all of the possible models using ModelBakery.registerItemVariants.

Link to post
Share on other sites
10 minutes ago, diesieben07 said:

When only using an item model (not a blockstate) it must be "inventory". Otherwise you can set it to a variant and it will pick that variant from the blockstate json.

Yeah i knew how it works with blockstates but i thought it may also work with items.

 

11 minutes ago, diesieben07 said:

ItemStack metadata is a full short (16 bits)

So i just registered a item model with the metadata of 16 and it seems to work ingame.

This is what i have done:

	@SubscribeEvent
	public static void registerItemModels(ModelRegistryEvent event) {
		registerCustomItemModel(ModItems.DUNGEON_PLACER, 16, ModItems.DUNGEON_PLACER.getRegistryName().toString() + "_d" + 16, "inventory");
	}

	private static void registerCustomItemModel(Item item, int meta, String modelLocation, String variant) {
		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(modelLocation, variant));
	}

Is there any reason not to do this?

Link to post
Share on other sites
3 minutes ago, Meldexun said:

Yeah i knew how it works with blockstates but i thought it may also work with items.

Just to clear this up: Items can use blockstate json files, too (with forge).

 

3 minutes ago, Meldexun said:

Is there any reason not to do this?

Perfectly fine to do this. In fact, prefer this over ItemMeshDefinition.

Also note however that in 1.14.4 it is encouraged you flatten your items, so maybe you want to do that already to aid in updating (i.e. make 20 items instead of 1 with 20 metadata values).

Link to post
Share on other sites
10 minutes ago, diesieben07 said:

Also note however that in 1.14.4 it is encouraged you flatten your items, so maybe you want to do that already to aid in updating (i.e. make 20 items instead of 1 with 20 metadata values). 

Iirc in 1.12.2 there is an item limit and you still recommend creating 20 items. Can't this cause issues? I thought only in MC 1.13 and newer i should create 20 items.

Link to post
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.

Guest
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 Privacy Policy.