Jump to content

[SOLVED][1.8] Problem rendering textures in inventory


Recommended Posts

Posted

So I have recently started modding on this minecraft version and I can't get textures to worki. I have implemented a block and an item, the block textures in the world are working but neither of the item/block are working in the inventory. Any solution?

ModItem json:

{

    "parent": "somelxmod:builtin/generated",

    "textures": {

        "all": "somelxmod:items/moditems"

    },

    "display": {

        "thirdperson": {

            "rotation": [ -90, 0, 0 ],

            "translation": [ 0, 1, -3 ],

            "scale": [ 0.55, 0.55, 0.55 ]

        },

        "firstperson": {

            "rotation": [ 0, -135, 25 ],

            "translation": [ 0, 4, 2 ],

            "scale": [ 1.7, 1.7, 1.7 ]

        }

    }

}

PS, tell me if you need to know any other files.

PS2,I have been the whole day trying solutions on the internet but they are not working.

Posted

Minecraft only loads one model per

Item

by default:

modid:itemRegistryName

(where

modid

is your lowercase mod ID and

itemRegistryName

is the name you passed to

GameRegistry.registerBlock

/

registerItem

). This resolves to either the assets/modid/models/item/itemRegistryName.json model or the model specified by the

inventory

variant of the assets/modid/blockstates/itemRegistryName.json blockstates file.

 

To load one or more other models, you need to call

ModelBakery.addVariantName

with the names of the models in the same

modid:name

format as above.

 

To specify which model to use for an

Item

, call

ModelLoader.setCustomModelResourceLocation

or

ModelLoader.setCustomMeshDefinition

in preInit.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I'm just trying to make a basic mod and I just want to use one texture but I'm not getting how to do it. I'm using this code to register de texture:

 

ModItems = new Item();

 

ModelResourceLocation mrl = new ModelResourceLocation("somelxmod" + ":" + "moditems", "inventory");

 

renderItem.getItemModelMesher().register(ModItems, 0, mrl);

 

Posted

Minecraft only loads one model per

Item

by default:

modid:itemRegistryName

(where

modid

is your lowercase mod ID and

itemRegistryName

is the name you passed to

GameRegistry.registerBlock

/

registerItem

). This resolves to either the assets/modid/models/item/itemRegistryName.json model or the model specified by the

inventory

variant of the assets/modid/blockstates/itemRegistryName.json blockstates file.

 

To load one or more other models, you need to call

ModelBakery.addVariantName

with the names of the models in the same

modid:name

format as above.

 

To specify which model to use for an

Item

, call

ModelLoader.setCustomModelResourceLocation

or

ModelLoader.setCustomMeshDefinition

in preInit.

 

And I have also this JSON for the blockstates folder:

{

    "variants": {

        "normal": { "model": "somelxmod:moditems" }

    }

}

Posted

Are you registering

ModItems

with the name

"moditems"

? If not, either change the model name to match the registry name of

ModItems

or call

ModelBakery.addVariantName

with

"somelxmod:moditems"

to load that model.

 

The Grey Ghost has a guide to troubleshooting item rendering here, I suggest following it.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Are you registering

ModItems

with the name

"moditems"

? If not, either change the model name to match the registry name of

ModItems

or call

ModelBakery.addVariantName

with

"somelxmod:moditems"

to load that model.

 

The Grey Ghost has a guide to troubleshooting item rendering here, I suggest following it.

 

Yep I have checked that guide and I didn't find any mistake. I am registering the item with this code:

 

ModItems = new Item();

ModItems.setUnlocalizedName("moditems");

ModItems.setCreativeTab(CreativeTabs.tabMisc);

 

GameRegistry.registerItem(ModItems, "moditems");

 

And i have changed everything to lower case but it is not working anyway.

Posted

In future, please use a site like GitHub or BitBucket if you want to share your entire project. It makes it much easier to spot problems without having to download anything. It also makes it easier to share changes.

 

Your code has several issues:

  • In
    ModBlocks.init

    , you overwrite the

    ModBlocks

    field with a new instance of

    Block

    . You do the same thing for the

    ModItems

    field in

    ModItems.init

    .

  • In
    ModBlocks.init

    , you're calling

    BlockModelShapes#registerBuiltInBlocks

    . This will stop your blockstates file from being loaded, which will break your block model.

  • Your JSON files have the .JSON extension instead of .json. Paths in JARs are case-sensitive, so the case of the extension matters.
  • You should move your code to a package that includes your name and the mod's name (e.g.
    somelx.somelxmod

    )

  • You should give your blocks and items proper names that aren't the same as your block/item registration classes. These names should be singular rather than plural (e.g.
    Thing

    , not

    Things

    ).

  • Follow the naming scheme described here for your classes.

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

In future, please use a site like GitHub or BitBucket if you want to share your entire project. It makes it much easier to spot problems without having to download anything. It also makes it easier to share changes.

 

Your code has several issues:

  • In
    ModBlocks.init

    , you overwrite the

    ModBlocks

    field with a new instance of

    Block

    . You do the same thing for the

    ModItems

    field in

    ModItems.init

    .

  • In
    ModBlocks.init

    , you're calling

    BlockModelShapes#registerBuiltInBlocks

    . This will stop your blockstates file from being loaded, which will break your block model.

  • Your JSON files have the .JSON extension instead of .json. Paths in JARs are case-sensitive, so the case of the extension matters.
  • You should move your code to a package that includes your name and the mod's name (e.g.
    somelx.somelxmod

    )

  • You should give your blocks and items proper names that aren't the same as your block/item registration classes. These names should be singular rather than plural (e.g.
    Thing

    , not

    Things

    ).

  • Follow the naming scheme described here for your classes.

.

 

Thank you, I have followed all your steps and now it's working. I will take into consideration for the next time using github, thank you for the advice!

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.