Jump to content

Recommended Posts

Posted (edited)

So I'm just trying to register a basic block, and I've created a block handler and registered it and its item, the same way I did for the items in my mod by subscribing to the event bus. However, it's giving me errors that I didn't get when registering items for my swords.

 

The first error is: "Exception loading model for variant koff:bake_kettle#normal for blockstate "koff:bake_kettle"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model koff:bake_kettle#normal with loader VariantLoader.INSTANCE, skipping"

 

Caused by: "java.lang.RuntimeException: Encountered an exception when loading model definition of model koff:blockstates/bake_kettle.json"

 

Caused by: "Caused by: java.io.FileNotFoundException: koff:blockstates/bake_kettle.json"

 

This is my bake_kettle.json (in the same assets directory that all of my custom items are in, under block):

 

{
    "textures": {
        "particle": "koff:blocks/bake_kettle"
    },
    "elements": [
        {   "name": "kettle_body",
            "from": [ -7, 0, -7 ],
            "to": [ 7, 12, 7 ],
            "rotation": {
                "origin": [ 0, 12, 0 ],
                "axis": "z",
                "angle": 0.0
            },
            "faces": {
                "down":  { "uv": [ 10.5, 0.0, 7.0, 3.5 ], "texture": "#particle" },
                "up":  { "uv": [ 7.0, 3.5, 3.5, 0.0 ], "texture": "#particle" },
                "north":  { "uv": [ 3.5, 3.5, 7.0, 6.5 ], "texture": "#particle" },
                "south":  { "uv": [ 10.5, 3.5, 14.0, 6.5 ], "texture": "#particle" },
                "west":  { "uv": [ 7.0, 3.5, 10.5, 6.5 ], "texture": "#particle" },
                "east":  { "uv": [ 0.0, 3.5, 3.5, 6.5 ], "texture": "#particle" }
            }
        },
        {   "name": "kettle_lid_handle",
            "from": [ -2, 12, 0 ],
            "to": [ 2, 14, 1 ],
            "rotation": {
                "origin": [ 0, 14, 0 ],
                "axis": "z",
                "angle": 0.0
            },
            "faces": {
                "down":  { "uv": [ 2.25, 7.5, 1.25, 7.75 ], "texture": "#particle" },
                "up":  { "uv": [ 1.25, 7.75, 0.25, 7.5 ], "texture": "#particle" },
                "north":  { "uv": [ 0.25, 7.75, 1.25, 8.25 ], "texture": "#particle" },
                "south":  { "uv": [ 1.5, 7.75, 2.5, 8.25 ], "texture": "#particle" },
                "west":  { "uv": [ 1.25, 7.75, 1.5, 8.25 ], "texture": "#particle" },
                "east":  { "uv": [ 0.0, 7.75, 0.25, 8.25 ], "texture": "#particle" }
            }
        },
        {   "name": "kettle_left_handle",
            "from": [ 6, 12, -1 ],
            "to": [ 7, 12, 2 ],
            "rotation": {
                "origin": [ 7, 12, 0 ],
                "axis": "z",
                "angle": 0.0
            },
            "faces": {
                "down":  { "uv": [ 3.25, 0.0, 3.0, 0.75 ], "texture": "#particle" },
                "up":  { "uv": [ 3.0, 0.75, 2.75, 0.0 ], "texture": "#particle" },
                "north":  { "uv": [ 2.75, 0.75, 3.0, 0.75 ], "texture": "#particle" },
                "south":  { "uv": [ 3.75, 0.75, 4.0, 0.75 ], "texture": "#particle" },
                "west":  { "uv": [ 3.0, 0.75, 3.75, 0.75 ], "texture": "#particle" },
                "east":  { "uv": [ 2.0, 0.75, 2.75, 0.75 ], "texture": "#particle" }
            }
        },
        {   "name": "kettle_right_handle",
            "from": [ -7, 12, -1 ],
            "to": [ -6, 12, 2 ],
            "rotation": {
                "origin": [ -7, 12, 0 ],
                "axis": "z",
                "angle": 0.0
            },
            "faces": {
                "down":  { "uv": [ 1.25, 0.0, 1.0, 0.75 ], "texture": "#particle" },
                "up":  { "uv": [ 1.0, 0.75, 0.75, 0.0 ], "texture": "#particle" },
                "north":  { "uv": [ 0.75, 0.75, 1.0, 0.75 ], "texture": "#particle" },
                "south":  { "uv": [ 1.75, 0.75, 2.0, 0.75 ], "texture": "#particle" },
                "west":  { "uv": [ 1.0, 0.75, 1.75, 0.75 ], "texture": "#particle" },
                "east":  { "uv": [ 0.0, 0.75, 0.75, 0.75 ], "texture": "#particle" }
            }
        }
    ]
}

 

BlockBakeKettle class:

public class BlockBakeKettle extends Block
{
    public BlockBakeKettle()
    {
        super(Material.IRON,MapColor.STONE);
        this.setUnlocalizedName("BakeKettle");
        this.setRegistryName("bake_kettle");
        this.setLightLevel(0.0f);
        useNeighborBrightness = true;
    }

    @Override
    public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos)
    {
        return false;
    }
}

 

BlockHandler class:

@GameRegistry.ObjectHolder(MyFirstMod.MODID)
@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MyFirstMod.MODID)
public final class BlockHandler
{
    public BlockHandler() {}

    public static final BlockBakeKettle BAKE_KETTLE = null;

    @SubscribeEvent
    public static void register(RegistryEvent.Register<Block> event)
    {
        event.getRegistry().registerAll(
                new BlockBakeKettle()
        );
    }
}

 

ItemHandler class:

@GameRegistry.ObjectHolder(MyFirstMod.MODID)
@Mod.EventBusSubscriber(modid = MyFirstMod.MODID)
public final class ItemHandler
{
    public ItemHandler(){};
    public static final ItemWoodenRapier WOODEN_RAPIER = null;
    public static final ItemGoldRapier GOLD_RAPIER = null;
    public static final ItemStoneRapier STONE_RAPIER = null;
    public static final ItemIronRapier IRON_RAPIER = null;
    public static final ItemDiamondRapier DIAMOND_RAPIER = null;
    @SubscribeEvent
    public static void register(RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll
        (
                new ItemBlock(BlockHandler.BAKE_KETTLE).setRegistryName(BlockHandler.BAKE_KETTLE.getRegistryName()),
                new ItemWoodenRapier(Item.ToolMaterial.WOOD),
                new ItemGoldRapier(Item.ToolMaterial.GOLD),
                new ItemStoneRapier(Item.ToolMaterial.STONE),
                new ItemIronRapier(Item.ToolMaterial.IRON),
                new ItemDiamondRapier(Item.ToolMaterial.DIAMOND)
        );
    }
}

 

my mod's model class:

@SideOnly(Side.CLIENT)
@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MyFirstMod.MODID)
public class KoffModels
{
    private KoffModels() {};
    @SubscribeEvent
    public static void register(ModelRegistryEvent event)
    {
        registerBlockModel(BlockHandler.BAKE_KETTLE, "bake_kettle");

        registerItemModel(ItemHandler.WOODEN_RAPIER, "wooden_rapier");
        registerItemModel(ItemHandler.GOLD_RAPIER, "gold_rapier");
        registerItemModel(ItemHandler.STONE_RAPIER, "stone_rapier");
        registerItemModel(ItemHandler.IRON_RAPIER, "iron_rapier");
        registerItemModel(ItemHandler.DIAMOND_RAPIER, "diamond_rapier");
    }
    private static ModelResourceLocation registerBlockModel(Block block, String name) {
        return registerItemModel(Item.getItemFromBlock(block), 0, name);
    }
    private static ModelResourceLocation registerItemModel(Item item, String name) {
        return registerItemModel(item, 0, name);
    }

    private static ModelResourceLocation registerItemModel(Item item, int id, String name) {
        ModelResourceLocation resource = new ModelResourceLocation(MyFirstMod.MODID + ":" + name, "inventory");
        ModelLoader.setCustomModelResourceLocation(item, id, resource);
        return resource;
    }
}

 

Anyone know why this might be?

 

 

EDIT: Figured it out, I forgot the blockstate like an idiot. I really shouldn't doubt the error logs.

Edited by k-off

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.