Jump to content

Recommended Posts

Posted

Not sure which of the titles options is actually my problem, but here the problem is:

 

I have a general blockslab class with two variants:

 

The slabs place and appear correctly in the game world as blocks/slabs.

 

However, as inventory and entity items they are untextured (but correctly named).

 

There's an additional error where the game says it cant find the approprite blockstates for an item baring the name the itemBlock is registered with. (i'm assuming this is where the issue is occuring). This currently removed by using the string "mossy_slab" to register the itemblock. note this has no impact on the ingame issue.

 

My blockstate and model files are copy pastes and so contain no information about inventory or ground states. These seems a potentional solution.

 

The blockSlab class (i'm fairly confident this is in order):

 

 

  Reveal hidden contents

 

 

The definition and registration:

 

 

  Reveal hidden contents

 

 

The render:

 

 

  Reveal hidden contents

 

 

edit: to remove commented out experiments/notes/old code

Posted

Where and when do you call your rendering-registration? Main, proxy, preInit, init, postInit?

 

Also, do not use Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), use ModelLoader.setCustomModelResourceLocation instead, and be sure to call that in preInit.

Example would be, (by passing block)

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

ta. problem solved. the original call was in the init event: the itemmeshers would crash the game if put in preinit. moot now, since i switched t the model loaders which have to be put in preinit. one thing to note, the string below had to have the modid added to completely cure the problem.

 

  public static void registerSlabRender(String string, int i, Block block)

  {

        //ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), i, new ModelResourceLocation("thejungle:" + string, "inventory"));

 

  }

Posted
  On 8/9/2016 at 12:36 AM, salvestrom said:

ta. problem solved. the original call was in the init event: the itemmeshers would crash the game if put in preinit. moot now, since i switched t the model loaders which have to be put in preinit. one thing to note, the string below had to have the modid added to completely cure the problem.

 

  public static void registerSlabRender(String string, int i, Block block)

  {

        //ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), i, new ModelResourceLocation("thejungle:" + string, "inventory"));

 

  }

 

To quote the Block#setRegistryName documentation:

  Quote

/**

    * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.

    * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.

    * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.

    *

    * The supplied name will be prefixed with the currently active mod's modId.

    * If the supplied name already has a prefix that is different, it will be used and a warning will be logged.

    *

    * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.

    *

    * Returns 'this' to allow for chaining.

    *

    * @param name Unique registry name

    * @return This instance

    */

Same thing applies to, random strings. You are meant to use RegistryName here, but you imitate it using a string that does what RegistryName does.

It's unlikely, but if ANY mod, literally any ever has a method that checks blocks, and uses Block#getRegistryName, on this block, guess what'll happen. Bam, nullpointerexception.

Sorry if I sound harsh, but this is what you are meant to use! It's actually dangerous to do what you are doing now.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

EDIT: having dwelt on the below, i have to ask if you're sure about the registryname in this instance. the slab variants dont have registry names. in anycase at this point the game just wants the name of the blockstate file. calling the registry name is highly convenient, but not essential. the blockstate file doesnt have to have the registry name, the two simply have to match.

 

EDIT: there are two seperate render calls one for each slab variant. its the passed in block that doesnt change.

 

the code was largely created by scouring the vanilla stuff, which uses a string. i say this merely by way of explaining it. i had looked at it after making the changes you suggested above and thought that it seemed identical to the registry name. but theres a snag here. changing the string to block.getregistryname, while not throwing up errors, gives both slabs the same texture in inventory and as an entity item. this is particularly odd as the passed in string does not change, the line in the post above is called only once.

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.