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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    275

Cadiboo

Cadiboo    275

  • Reality Controller
  • Cadiboo
  • Members
  • 275
  • 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    275

Cadiboo

Cadiboo    275

  • Reality Controller
  • Cadiboo
  • Members
  • 275
  • 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    275

Cadiboo

Cadiboo    275

  • Reality Controller
  • Cadiboo
  • Members
  • 275
  • 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 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

    • diesieben07
      Forge 1.12.2 wont start

      By diesieben07 · Posted just now

      Please post launcher_log.txt as well.
    • diesieben07
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By diesieben07 · Posted 4 minutes ago

      This makes zero sense.     This is chunk of code achieves nothing. It might as well not be there.   You are lacking absolute basic understanding of overriding methods. You need to learn it before you can continue here.
    • J0WAY
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY · Posted 8 minutes ago

      public class EntityBarbarian extends EntityMob {     public EntityBarbarian(World worldIn)      {         super(worldIn);         this.setSize(0.6F, 1.95F);         this.setHealth(50);      }          @Override     protected void initEntityAI()     {              super.initEntityAI();         this.tasks.addTask(0, new EntityAISwimming(this));         this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));         this.tasks.addTask(8, new EntityAIWander(this, 0.6D));         this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 3.0F, 1.0F));         this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));         this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityVindicator.class}));         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));         this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));         this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));     }              @Override     protected void applyEntityAttributes()     {         super.applyEntityAttributes();             this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);           this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);         this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(48.0D);     }          @Override     public float getEyeHeight()     {         return 1.6F;     }     @Override     public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)      {         return super.onInitialSpawn(difficulty, livingdata);     }     @Override     public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)      {         super.setItemStackToSlot(slotIn.MAINHAND, new ItemStack (ModItems.BARBARIAN_SWORD));     } }
    • sondreooos
      Forge 1.12.2 wont start

      By sondreooos · Posted 8 minutes ago

      debug-1.log debug-2.log debug-3.log.gz debug-4.log.gz debug-5.log.gz debug.log
    • diesieben07
      Forge 1.12.2 wont start

      By diesieben07 · Posted 10 minutes ago

      logs/debug.log.
  • Topics

    • sondreooos
      8
      Forge 1.12.2 wont start

      By sondreooos
      Started 1 hour ago

    • J0WAY
      22
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY
      Started Thursday at 09:10 PM

    • FireController1847
      0
      [1.14.4] How to move the position of a HUD element without copying Mojang code?

      By FireController1847
      Started 57 minutes ago

    • Mylystra
      1
      my mods aren't appearing only forge does

      By Mylystra
      Started 1 hour ago

    • Sfgg
      2
      NO SE ME ABRE

      By Sfgg
      Started 4 hours ago

  • Who's Online (See full list)

    • Sfgg
    • Cerandior
    • FireController1847
    • diesieben07
    • Kharmod
    • Draco18s
    • sondreooos
    • Simon_kungen
    • J0WAY
    • sharpiekid414
    • Sushi342
    • Lea9ue
    • gouldendorf
    • LuxXcel
    • vaartis
  • 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