Jump to content

[1.8] Organising model files


DARKHAWX

Recommended Posts

Bit of a weird question, but I want to be able to organise my long list of json files for my block models better (by grouping them up in folders). This, I have been able to achieved fine, my problem is organising the folders for the block models in the players inventory (assets/<modname>/models/item). No matter how I put it, they will not work. The inventory models only works if its in the root item folder.

 

Here is all the relevant info:

 

Pic of directory:

 

v9Y2Zw9.pngo5tmWeL.png

 

/blockstates/alchemicalCraftingTable.json

 

{
  "variants": {
    "facing=north": { "model": "alchemistscookbook:alchemicalCraftingTable/alchemicalCraftingTable_north"},
"facing=east": { "model": "alchemistscookbook:alchemicalCraftingTable/alchemicalCraftingTable_east"},
"facing=south": { "model": "alchemistscookbook:alchemicalCraftingTable/alchemicalCraftingTable_south"},
"facing=west": { "model": "alchemistscookbook:alchemicalCraftingTable/alchemicalCraftingTable_west"}
  }
}

 

/models/block/alchemicalCraftingTable/alchemicalCraftingTable_east.json

 

{
"textures": {
    "particle": "alchemistscookbook:blocks/alchemicalCraftingTable_cauldron",
    "texture": "alchemistscookbook:blocks/alchemicalCraftingTable_cauldron",
    "alchemicalCraftingTable_craftingGrid": "alchemistscookbook:blocks/alchemicalCraftingTable_craftingGrid",
    "alchemicalCraftingTable_table": "alchemistscookbook:blocks/alchemicalCraftingTable_table"
},

// Then a bunch of model stuff

 

/models/item/alchemicalCraftingTable/alchemicalCraftingTable.json

 

{
  "parent":"alchemistscookbook:block/alchemicalCraftingTable/alchemicalCraftingTable_east",
  "display": {
    "thirdperson": {
      "rotation": [ 10, -45, 170 ],
      "translation": [ 0, 1.5, -2.75 ],
      "scale": [ 0.375, 0.375, 0.375 ]
    }
  }
}

 

BlockRenderRegister

 

package com.darkhawx.alchemistscookbook.client.render.blocks;

import com.darkhawx.alchemistscookbook.main.AlchemistsCookbookMod;
import com.darkhawx.alchemistscookbook.main.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;

public final class BlockRenderRegister {

    public static String modid = AlchemistsCookbookMod.MODID;

    public static void reg(Block block) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(modid + ":" + block.getUnlocalizedName().substring(5), "inventory"));
    }

    public static void reg(Block block, int meta, String file) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(modid + ":" + file, "inventory"));
    }

    public static void preInit() {
        ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.table), "alchemistscookbook:table_none", "alchemistscookbook:table_north", "alchemistscookbook:table_south", "alchemistscookbook:table_east", "alchemistscookbook:table_west", "alchemistscookbook:table_n_e", "alchemistscookbook:table_n_w", "alchemistscookbook:table_s_e", "alchemistscookbook:table_s_w", "alchemistscookbook:table_n_s", "alchemistscookbook:table_e_w", "alchemistscookbook:table_n_e_2", "alchemistscookbook:table_n_w_2", "alchemistscookbook:table_s_e_2", "alchemistscookbook:table_s_w_2", "alchemistscookbook:table_middle");
        ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.alchemyTable), "alchemistscookbook:alchemyTable_none", "alchemistscookbook:alchemyTable_north", "alchemistscookbook:alchemyTable_east", "alchemistscookbook:alchemyTable_south", "alchemistscookbook:alchemyTable_west");
        ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.philosophersStone), "alchemistscookbook:philosophersStone_north", "alchemistscookbook:philosophersStone_east", "alchemistscookbook:philosophersStone_south", "alchemistscookbook:philosophersStone_west");
        ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.alchemicalCraftingTable), "alchemistscookbook:alchemicalCraftingTable_north", "alchemistscookbook:alchemicalCraftingTable_east", "alchemistscookbook:alchemicalCraftingTable_south", "alchemistscookbook:alchemicalCraftingTable_west");
    }

    public static void registerBlockRenderer() {
        reg(ModBlocks.testBlock);
        reg(ModBlocks.alchemicalCraftingTable, 0, "alchemicalCraftingTable/alchemicalCraftingTable_north");
        reg(ModBlocks.leadOre);
        reg(ModBlocks.philosophersStone, 0, "philosophersStone_north");
        reg(ModBlocks.distiller);
        reg(ModBlocks.table, 0, "table/table_none");
        reg(ModBlocks.alchemyTable, 0, "alchemicalCraftingTable/alchemyTable_none");
        reg(ModBlocks.fountainOfYouth);
        reg(ModBlocks.silverOre);
        reg(ModBlocks.holyGrail);
    }
}

 

 

Does anyone know what I need to change so that it works properly and so I can organised my item model files?

 

(All the models work when I place them, just not when I have to item in my inventory)

No signature for you!

Link to comment
Share on other sites

You need to find a way to specify the model resource location's path; the only way I know of to do this is to use ModelBakeEvent to swap out the default /items/model.json for your item model with a new one that has the correct path.

 

You can also register item variants using

ModelBakery.addVariantName(Item, String...)

- it may be possible to add in the extra directories this way, e.g.:

String model_path = "modid:relative/path/to/model/model_name";
ModelBakery.addVariantName(this, model_path);

 

Remember also you will probably need to register the item renderer using your new path (in fact, this may be the only thing required - haven't tested it personally):

mesher.register(this, 0, new ModelResourceLocation(model_path, "inventory"));

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



×
×
  • Create New...

Important Information

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