Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12] Forge Blockstate Item Block Model error
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
shane020482

[1.12] Forge Blockstate Item Block Model error

By shane020482, May 28, 2018 in Modder Support

  • Reply to this topic
  • Start new topic
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Recommended Posts

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 28, 2018

While trying to use Forge Blockstate the block model  variants work fine however im getting a inventory error.

Exception loading model for variant cbm:block_steel_steel_plating#inventory

 

Blockstate:

https://pastebin.com/j0JTAH5p

Console:

https://pastebin.com/QyVd7agK

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 28, 2018 (edited)

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

 

Also, show your registration code.

Edited May 28, 2018 by Draco18s
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 28, 2018 (edited)
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 May 28, 2018 by shane020482
  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    277

Cadiboo

Cadiboo    277

  • Reality Controller
  • Cadiboo
  • Members
  • 277
  • 3303 posts
Posted May 28, 2018
13 minutes ago, Draco18s said:

show your registration code.

 

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 28, 2018

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"));
		
	}

 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018

Don't construct resource locations yourself.

 

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

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018
10 minutes ago, Draco18s said:

Don't construct resource locations yourself.

 

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

Not sure i fully understand what you mean

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018 (edited)

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 May 29, 2018 by Draco18s
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018
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.

  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    277

Cadiboo

Cadiboo    277

  • Reality Controller
  • Cadiboo
  • Members
  • 277
  • 3303 posts
Posted May 29, 2018
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

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018

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.

  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    277

Cadiboo

Cadiboo    277

  • Reality Controller
  • Cadiboo
  • Members
  • 277
  • 3303 posts
Posted May 29, 2018 (edited)
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 May 29, 2018 by Cadiboo
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018
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 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018

You want metadata blocks?

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

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018
26 minutes ago, Draco18s said:

You want metadata blocks?

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

Man thats a rabbit hole ill havw to sit down and really dig in to see if i can figure it  out. 😀

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018 (edited)

It goes here:

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

The list its adding to gets used here:

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

Edited May 29, 2018 by Draco18s
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018

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;
		}
	}

 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018 (edited)

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 May 29, 2018 by Draco18s
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018
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

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018 (edited)

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 May 29, 2018 by Draco18s
  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018

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.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018

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.

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018

I know GameRegistry is private. But are you saying i cant even use the event method in the base class 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14019 posts
Posted May 29, 2018

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

  • Quote

Share this post


Link to post
Share on other sites

shane020482    2

shane020482

shane020482    2

  • Stone Miner
  • shane020482
  • Members
  • 2
  • 72 posts
Posted May 29, 2018

By registering in the base class anything you put in the init class is automatically registered therefore you dont need to register each block separately. If im being stupid please forgive me im still trying to get a understanding of 1.12

  • Quote

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

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.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • BattleDash
      Get all players connected to a bungee server

      By BattleDash · Posted 41 minutes ago

      Hello all, I'm trying to make a mod that can tell you all the players on a bungee server you're connected to, I've never worked with Forge before and this API is very abstract to me compared to plugin development which is what I normally do. Does anyone know how I would go about getting a list of Player Entities of every player on the network you're connected to?
    • Draco18s
      Trouble getting contents of a Chest

      By Draco18s · Posted 1 hour ago

      It isn't merged, so it won't work yet.
    • saxon564
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564 · Posted 2 hours ago

      Does anyone else have any thoughts as to what might be causing this issue?
    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 2 hours ago

      You cannot call Minecraft methods from a separate thread. You need to wait a tick using ClientTickEvent.
    • bismuth210
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210 · Posted 2 hours ago

      I'm creating a custom gamemode using forge in which players get teleported around regularly. I've run into a problem when I do the following:   I spawn a firework rocket near a player I teleport the player to a different location I wait a couple of seconds (or minutes) I teleport the player back to the same location as in step 1. Doing this will show the firework spawned in step 1 in step 4, despite significant time having passed in 3. This video shows what I mean:   I suspect the reason for why this happens is because once I teleport the player somewhere else, the chunk with the firework is no longer loaded and doesn't get updated.   Is there a simple way for me to simply "get rid" of all active fireworks shortly before teleporting players so that this doesn't occur? Or do I really have to forcibly keep all chunks loaded? To be more clear: I don't want to disable fireworks all together, but I don't want remnants of old fireworks showing up when I teleport players. "Killing" all firework rockets when I teleport a player would work fine, but I don't know if/how I can do that.   I've tried using /kill @e[type=!player] But that doesn't work for firework rockets apparently.
  • Topics

    • BattleDash
      0
      Get all players connected to a bungee server

      By BattleDash
      Started 41 minutes ago

    • MattNL
      5
      Trouble getting contents of a Chest

      By MattNL
      Started 12 hours ago

    • saxon564
      12
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564
      Started Friday at 05:11 AM

    • Filip4223
      5
      [1.12.2] How can I close GUI in Forge?

      By Filip4223
      Started 3 hours ago

    • bismuth210
      0
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210
      Started 2 hours ago

  • Who's Online (See full list)

    • no namezzzz
    • diesieben07
    • Draco18s
    • MrCatPlays
    • DanielMens
    • LexManos
    • MattNL
    • uiytt
    • Crack3dC0d3
    • wilechaote
    • EfrenB
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12] Forge Blockstate Item Block Model error
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community