Jump to content

[1.8][1.9][SOLVED] What's the recommended way to specify item/block models?


target.san

Recommended Posts

Started modding after a break and a bit confused.

 

As I understand, the preferred way to load block models is through blockstate.

Though, it's not clear what's the one for items. Which seem to not load any model data automagically based on their registry names. I found following variants:

 

1.

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register

from BedrockMiner's tutorials

2. Use

ModelBakery.registerItemVariants

3. Use

ModelLoader.registerItemVariants

(which looks like #2)

 

Can anyone point to some mini-guide? Google shows too much info, and Forge docs are rather slim

 

Thanks

 

Sidenote: It'd be nice to have some common entrypoint for all Forge stuff, like root

Forge

class with methods/fields like

gameRegistry

,

modelLoader

etc.

Link to comment
Share on other sites

I've written an explanation of the model loading process here. The summary at the end briefly explains how to load models and how to map them to blocks/items.

 

This was written for 1.9, but it's fairly similar in 1.8.x.

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.

Link to comment
Share on other sites

As I understand, it's possible to apply item model without any code, by just placing properly named JSON where model loader expects it?

I've been trying to use this way, along with model loader way. Though I'm still getting missing texture, along with my item looking like block. So I'm definitely doing something wrong.

 

Link to comment
Share on other sites

As I understand, it's possible to apply item model without any code, by just placing properly named JSON where model loader expects it?

No. Minecraft will automatically load the model with the

Item

's registry name if you don't call

ModelBakery.registerItemVariants

for it, but it won't use that model unless you tell it to.

 

You must call

ModelLoader.setCustomModelResourceLocation

or

ModelLoader.setCustomMeshDefinition

to tell Minecraft which model to use for an

Item

.

 

I've been trying to use this way, along with model loader way. Though I'm still getting missing texture, along with my item looking like block. So I'm definitely doing something wrong.

There should be errors in the log telling you what went wrong. If you don't understand them, upload the FML log (logs/fml-client-latest.log) to Gist and link it here.

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.

Link to comment
Share on other sites

No. Minecraft will automatically load the model with the

Item

's registry name if you don't call

ModelBakery.registerItemVariants

for it, but it won't use that model unless you tell it to.

 

You must call

ModelLoader.setCustomModelResourceLocation

or

ModelLoader.setCustomMeshDefinition

to tell Minecraft which model to use for an

Item

.

 

 

I think that's the problem I'm facing. I was somehow thinking that MC will utilize model which it loaded automatically. A bit surprising, but nothing too hard. Thank you for your time.

Link to comment
Share on other sites

Okie, so that wasn't that smooth for me.

To be clear, I'm using Forge 1.8.9-11.15.1.1722 (latest stable AFAIR)

 

Frankly speaking, the only way of attaching model to item which worked for me was

        Item item = WorldRift.instance.itemRiftWand;
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
        .register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));

invoked in client proxy's init event specialization. Now, some details.

 

1. Resources structure

 

 

+ assets
+ worldrift
  + blockstates
   - rift.json // my block, not related 
  + models
   + block
    - rift.json // my block's model, also not related
   + item
    - riftwand.json // my item model
  + lang
   - en_US.lang // just lang file
  + textures
   + block
    - rift.png // block texture, not related to my case
   + item
    - riftwand.png // item texture

 

 

 

2.

models/item/riftwand.json

 

{
  "parent":"builtin/generated",
  "textures": {
    "layer0": "worldrift:item/riftwand"
  },
  "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 ]
    }
  }
}

 

 

Now, to my findings

1. Adding

blockstates/riftwand.json

without any Java-side code doesn't do any good. File text I used, just for reference

{
  "variants": {
    "normal": { "model": "worldrift:rift" },
    "inventory": { "model": "worldrift:rift" }
  }
}

 

2. Attempt to load via

        Item wand = WorldRift.instance.itemRiftWand;
        ModelResourceLocation loc = new ModelResourceLocation(wand.getRegistryName(), "inventory");
        ModelLoader.registerItemVariants(wand, loc);
        ModelLoader.setCustomModelResourceLocation(wand, 0, loc);

also gives no result. I tried putting model name manually, using empty variant, putting this into both pre-init and init etc.

 

If you ask what were the errors - I encountered either no errors at all or

FileNotFound

for

blockstates/riftwand.json

when loader apparently falled back to blockstates as thelast resort.

 

Several mods I checked on Github also use

getItemMesher

approach.

 

So I'm a bit lost at the end, with recommended ways failing.

Link to comment
Share on other sites

ModelLoader.setCustomModelResourceLocation

will call

ModelBakery.registerItemVariants

for you, so you don't have to call it yourself in this case. You also don't need to call it to load

Item

's default model (the one with the

Item

's registry name).

 

Is your

Item

's registry name

worldrift:riftwand

(with that exact capitalisation)?

 

Could you please do the following to help me narrow down your issue?

  • Remove all model registration code for the wand
  • Call the following code from your client proxy in preInit
  • Run Minecraft
  • Upload the FML log to Gist and post it here

 

Item wand = WorldRift.instance.itemRiftWand;
ModelLoader.setCustomModelResourceLocation(wand, 0, new ModelResourceLocation(wand.getRegistryName(), "inventory"));

 

Edit: Fixed the formatting.

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.

Link to comment
Share on other sites

Seems that ModelLoader way doesn't work during init phase.

 

That's correct.

ModelLoader

methods must be called 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.

Link to comment
Share on other sites

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

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

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