Jump to content

[1.12] Blockstates for versions of item in inventory?


dakamojo

Recommended Posts

Here is my current blockstates file.

 

{
  "forge_marker": 1,
  "defaults": {
    "model": "earlygameminer:miner"
  },
  "variants": {
    "inventory": {
      "model": "cube_all",
      "textures": {
        "all": "blocks/dirt"
      }
    },
    "variant": {
      "stone": {
        "textures": {
          "top": "blocks/stone",
          "side": "earlygameminer:blocks/miner_stone_side"
        }
      },
      "iron": {
        "textures": {
          "top": "blocks/iron_block",
          "side": "earlygameminer:blocks/miner_iron_side"
        }
      },
      "diamond": {
        "textures": {
          "top": "blocks/diamond_block",
          "side": "earlygameminer:blocks/miner_diamond_side"
        }
      }
    }
  }
}

 

My block has three versions (stone, iron, and diamond) which is indicated by an iProperty named "variant". All three varients render correctly in world.  However in inventory only the "inventory" section is used.  I set it as dirt so that I could see it is actually working.  What is the syntax to have the inventory use the exact same logic as when placed?

 

My block code is modeled after BlockPlanks.  However I can't seem to understand where BlockPlanks sets up its blockstates file.

Link to comment
Share on other sites

You have to register your variant with the ModelLoader.

 

For example, I have this:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L147

I have my code set up to take an arbitrary property as a variant, I get the metadata value and state information for each subblock, then register it:

https://github.com/Draco18s/ReasonableRealism/blob/1.11.2/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L162-L169

(The 1.12 code I use is more complicated due to the ModelRegistryEvent nonsense, so I linked the simpler snippet from 1.11)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I'm not completely able to follow the logic in your helper class.  Here is what I think you are doing.  Please correct me where I am wrong.  I'm using the ores in your mod as an example.

 

1) You have an ItemRawOre that implements subtypes.  I didn't create a ItemMiner because the generic BlockItem seems to work fine.  When each of the three variants of my block are mined, I get BlockItems of the three variants.  Is creating a custom Item required?

2) You register all the ItemRawOre variants by calling EasyRegistry#registerItemWithVariants.  

3) This loops through each of the subTypes of ItemRawOre calling ModelLoader#setCustomModelResourceLocation for each one.

4) Each one of the subTypes has its own blockState json file.

 

Assuming all that is correct, here's what I don't understand.  Why can I define one blockState json file for all the variants of my block in world, but I would need a different blockState json file for each of the variants in inventory?

Link to comment
Share on other sites

59 minutes ago, dakamojo said:

I'm not completely able to follow the logic in your helper class.  Here is what I think you are doing.  Please correct me where I am wrong.  I'm using the ores in your mod as an example.

 

1) You have an ItemRawOre that implements subtypes.  I didn't create a ItemMiner because the generic BlockItem seems to work fine.  When each of the three variants of my block are mined, I get BlockItems of the three variants.  Is creating a custom Item required?2) You register all the ItemRawOre variants by calling EasyRegistry#registerItemWithVariants.  

My ItemRawOre is not a block, it is an item. This is so my ores can be subject to Fortune enchantments (among others).

Quote

 

3) This loops through each of the subTypes of ItemRawOre calling ModelLoader#setCustomModelResourceLocation for each one.

4) Each one of the subTypes has its own blockState json file.

4 is Incorrect. I have one blockstate file. https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/harderores/blockstates/orechunks.json

Each ore block also has a blockstate file, but the ore items themselves only have 1. The two do not have a relationship with each other.
 

Quote

Assuming all that is correct, here's what I don't understand.  Why can I define one blockState json file for all the variants of my block in world, but I would need a different blockState json file for each of the variants in inventory?

You don't.

Here is my block json:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/harderores/blockstates/ore_hardiron.json

Here's where I register it:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/ores/OresBase.java#L181

The easy registry is a mess because of the way I want to handle things in my main mod class (as a single function call). But here's a break down of what it does:

 

1) register and item the block with the game

2) get all valid states for the block and register an item model: https://github.com/Draco18s/ReasonableRealism/blob/1.11.2/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L46-L55

3) That involves calling ModelLoader.setCustomModelResourceLocation for each variant from the block's state: https://github.com/Draco18s/ReasonableRealism/blob/1.11.2/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L162-L169

My 1.12 code makes a hash of that process because it has to cache the object to register and then wait for the ModelRegistryEvent, but it still does just that: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L197-L199

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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