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
  On 1/21/2016 at 4:06 PM, Choonster said:

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
  On 1/21/2016 at 4:19 PM, Choonster said:

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
  On 1/21/2016 at 11:47 PM, Choonster said:

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Betafort Recovery has emerged as a prominent figure in the realm of cryptocurrency recovery, gaining a reputation for their exceptional ability to retrieve lost Bitcoin (BTC) and other cryptocurrencies. Their expertise and track record have made them a beacon of hope for individuals facing the distressing situation of lost or inaccessible crypto assets.  
    • When you name a method like that, with no return value, it is a constructor. The constructor must have the same name as the class it constructs, in this case, ModItems. I would strongly advise reading up on some basic Java tutorials, because you will definitely be running into a lot more issues as you go along without the basics. *I should also add that the Forge documentation is a reference, not a tutorial. Even following tutorials, you should know Java basics, otherwise the smallest of mistakes will trip you up as you copy someone elses code.
    • so, I'm starting modding and I'm following the official documantation for forge: https://docs.minecraftforge.net, but in the registries part it is not working as it is in the docs:   public class ModItems { private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, DarkStarvation.MOD_ID); public static final RegistryObject<Item> TEST_ITEM = ITEMS.register("test_item", () -> new Item(new Item.Properties())); public DarkStarvation(FMLJavaModLoadingContext context) { ITEMS.register(context.getModEventBus()); } } in 'public DarkStarvation(...' the DarkStarvation has this error: Invalid method declaration; return type required and the getModEventBus(): Cannot resolve method 'getModEventBus' in 'FMLJavaModLoadingContext' please help, I asked gpt but it is saying that I'm using an old method, but I'm following the latest version of Forge Docs???
    • I merged your second post with the original , there is no need to post a new thread asking for an answer. If someone sees your post and can help, they will reply. If you are seeking a quicker response, you could try asking in the Minecraft Forge diacord.
    • Create a new instance and start with cobblemon - if this works, add the rest of your mods in groups   Maybe another mod is conflicting - like Sodium/Iris or Radical Cobblemon Trainers
  • Topics

×
×
  • Create New...

Important Information

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