Jump to content

[1.12] Forge Blockstate Item Block Model error


shane020482

Recommended Posts

Caused by: java.io.FileNotFoundException: cbm:models/item/block_steel_steel_plating.json

 

Also, show your registration code.

Edited by Draco18s

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.

Link to comment
Share on other sites

6 minutes ago, Draco18s said:

Caused by: java.io.FileNotFoundException: cbm:models/item/block_steel_steel.json

i thought the point of Forge Blockstate "inventory": [{}],  was to provide that info. And yes iv used it as well as removed it from my blockstate and it changes nothing.

Edited by shane020482
Link to comment
Share on other sites

13 minutes ago, Draco18s said:

show your registration code.

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

this is the code i used to get that error and iv tried several other naming methods as well


	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) 
	{
		registerRender(ItemBlockEnum.getItemFromBlock(block_steel));
		for (int i = 0; i < metalType.values().length; i++) {
	
			registerRender(block_steel, i, "block_steel_" + metalType.values()[i].getName());
			
		}
	}
	
	private static void registerRender(Block block, int meta, String fileName) {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta,
				new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, fileName), "inventory"));
		
	}

 

Link to comment
Share on other sites

Don't construct resource locations yourself.

 

block.getRegistryName() (and item.getRegistryName()) returns a ResourceLocation, use it.

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.

Link to comment
Share on other sites

See this?

new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, fileName), "inventory"));

 

Make it this:

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

 

Here's how I do it:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L103

(Commented out is pre-ModelRegistryEvent, but the same information is cached and handed off during said event).

Edited by Draco18s

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.

Link to comment
Share on other sites

3 minutes ago, Draco18s said:

See this?


new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, fileName), "inventory"));

 

Make it this:


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

That only works with blocks that dont have meta and the method calls for block not item. And yes iv tried block.getRegistryName() it doesnt work ether. This method worked fine on older versions i just cant find what has changed. Even looking at the non meta block method the change was from itemstack to item so not a big change there.

Link to comment
Share on other sites

14 minutes ago, shane020482 said:

That only works with blocks that dont have meta and the method calls for block not item. And yes iv tried block.getRegistryName() it doesnt work ether. This method worked fine on older versions i just cant find what has changed. Even looking at the non meta block method the change was from itemstack to item so not a big change there.

If it doesn’t work your likely doing something wrong, also a heads up, metadata is being removed in 1.13

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

12 minutes ago, shane020482 said:

I know im doing something wrong i just cant figure out what and if i dont use meta what could i use for variants. My mod is going to have a lot of blocks and i would like to cut down on the amount of blockstates an models needed.

... your still going to need the same amount of block state models

have a look at BlockResourceBlock in my mod

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/block/BlockResourceBlock.java

and how I have multiple variants with only one class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/init/Blocks.java

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

2 minutes ago, Cadiboo said:

... your still going to need the same amount of block state models

have a look at BlockResourceBlock in my mod

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/block/BlockResourceBlock.java

and how I have multiple variants with only one class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/init/Blocks.java

Yea i was afraid of that im already using that method for blocks that dont have variants. i was just hoping to use Forge Blockstate to cover block models item models and blockstates for up to 16 blocks with just one blockstate. But if i cant get Forge to work then i guess ill just have to suck it up.

Thanks for the advice anyways 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

chasing things down and this is what iv got so far and im still lost. Im not a complete noob to java or MC code but i am self taught and this may just be outside my grasp

public void _registerBlockWithCustomItem(Block block, ItemBlock iBlock, String registryname) 
	{
		StateMapperBase b = new DefaultStateMapper();
		BlockStateContainer bsc = block.getBlockState();
		ImmutableList<IBlockState> values = bsc.getValidStates();
		for(IBlockState state : values) 
		{
			String str = b.getPropertyString(state.getProperties());
			_registerBlockItemModelForMeta(block, block.getMetaFromState(state), str);
		}
	}
	
	
	
	
	private void _registerBlockItemModelForMeta(Block block, int metadata, String variant) {
		final Item item = blockItems.get(block);
		if (item != null) {
			_registerItemModelForMeta(item, metadata, variant);
		}
	}



	private void _registerItemModelForMeta(Item item, int metadata, String variant) {
		ModelResourceLocation res = new ModelResourceLocation(item.getRegistryName(), variant);
		_registerItemModelForMeta(item, metadata, res);
	}

	private void _registerItemModelForMeta(Item item, int metadata, ModelResourceLocation modelResourceLocation) {
		modelsToReg.add(new ModelRegistryObj(item, metadata, modelResourceLocation));
	}

	protected static class ModelRegistryObj {
		final Item item;
		final int meta;
		final ModelResourceLocation resource;
		
		public ModelRegistryObj(Item i, int m, ModelResourceLocation loc) {
			item = i;
			meta = m;
			resource = loc;
		}
	}

 

Link to comment
Share on other sites

You're just blindly copying things. That isn't going to DO anything by itself.

The point was "you need to do these things <link to a function that does these things>" not "Copy-paste my code, cross your fingers, and run it."

 

The one function that you didn't know what it did... all it does is what you were already doing.

Edited by Draco18s

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.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

You're just blindly copying things. That isn't going to DO anything by itself.

The point was "you need to do these things <link to a function that does these things>" not "Copy-paste my code, cross your fingers, and run it."

 

The one function that you didn't know what it did... all it does is what you were already doing.

sry for not being clearer what i was trying to do was get the full code in one place so i could see what i needed to do to make this work for me and thats where i get lost. i myself dont like copy pasting i always modified to to fit my needs

Link to comment
Share on other sites

You need this:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L66-L71

Line 70 in that code is equivalent to ModelLoader.setCustomModelResourceLocation (with the indicated parameters) called during the ModelRegistryEvent.

 

That is:

You need to ask a block what states it has

Get the metadata for those states

Convert those states to variant strings

Register an item model for those metadatas and variant strings

 

There is no canonical block-saved-metadata to item-stack-metadata conversion, however, vanilla (and most mods) treat them as being the same for simplicity's sake. The only place it is explicitly assumed to always be that way is in vanilla's custom world gen settings.

 

Of course, the same would be said of enum values as well, but vanilla went and fucked that up with their colors. WHITE is 15, but also 0.

Edited by Draco18s

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.

Link to comment
Share on other sites

Its fine after sleeping on it i think im going to do it like i did in the past and register in the base class

https://github.com/Shane2482/Deadly-World-1.10/blob/master/src/main/java/shane2482/deadlyworld/blocks/base/blockbase.java 

that is if i can figure out how to do that in 1.12. And even if i dont use enums if i use Forge Blocktates ill still need to create blockstates for all of my blocks but i wont need the models.

Link to comment
Share on other sites

You can't do it like that in 1.12, the GameRegistry is private: the events exist to make sure that everything gets registered at the proper time in the proper order.

 

You cannot get around this.

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.

Link to comment
Share on other sites

It doesn't save you anything.

What do you have access to inside the class object that you don't have access to from outside? Everything you need is public...

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.

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.

Announcements



×
×
  • Create New...

Important Information

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