Jump to content

Recommended Posts

Posted

Hi, I'm super tired and having an issue with getting my block variants to have the correct model while displaying in the inventory/hand. They render as a large cube with the missing texture. 

 

Here is my ModBlocks class, where the blocks are registered, along with the models. Something is obviously wrong here, as the models aren't being loaded properly for some reason.

 
public class ModBlocks {

    public static BlockGeodeStone geodeStone;
    public static ItemBlockMetadata itemblockGeodeStone;

    public static void register(){
        geodeStone = new BlockGeodeStone(BlockNames.GEODE_STONE);
        itemblockGeodeStone = new ItemBlockMetadata(geodeStone);
        itemblockGeodeStone.setRegistryName(BlockNames.GEODE_STONE);

        GameRegistry.register(geodeStone);
        GameRegistry.register(itemblockGeodeStone);
    }



    @SideOnly(Side.CLIENT)
    public static void preInitRegisterRenderers(){

        for (int i = 0; i < BlockNames.GEODE_STONE_VARIANTS.length; i++) {
            ModelResourceLocation resourceLocation = new ModelResourceLocation(BeyondMod.MODID+":"+BlockNames.GEODE_STONE_VARIANTS[i], "inventory");
            ModelLoader.setCustomModelResourceLocation(itemblockGeodeStone, i, resourceLocation);
        }

    }

    @SideOnly(Side.CLIENT)
    public static void registerRenderers(){
        for (int i = 0; i < BlockNames.GEODE_STONE_VARIANTS.length; i++) {
            registerRenderer(geodeStone, i, BlockNames.GEODE_STONE);
        }
    }

    @SideOnly(Side.CLIENT)
    public static void registerRenderer(Block block, int meta, String file){
        Item item = Item.getItemFromBlock(block);
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
                item, meta, new ModelResourceLocation(BeyondMod.MODID+":"+file, "inventory")
        );
    }

}

 

Here's the block class for GeodeStone.

public class BlockGeodeStone extends Block {

    public static final PropertyEnum<GeodeStoneVariant> variant = PropertyEnum.create("variant", GeodeStoneVariant.class);

    public BlockGeodeStone(String registryName){
        super(Material.ROCK);
        setDefaultState(this.blockState.getBaseState().withProperty(variant, GeodeStoneVariant.SMOOTH));
        setRegistryName(registryName);
        setUnlocalizedName(registryName);
    }

    public BlockStateContainer createBlockState(){
        return new BlockStateContainer(this, new IProperty[]{variant});
    }

    public int getMetaFromState(IBlockState state){
        return state.getValue(variant).ordinal();
    }

    public IBlockState getStateFromMeta(int meta){
        return getDefaultState().withProperty(variant, GeodeStoneVariant.values()[meta]);
    }

    public int damageDropped(IBlockState blockState){
        return getMetaFromState(blockState);
    }

    public void getSubBlocks(Item item, CreativeTabs tab, NonNullList<ItemStack> list){
        for (int i = 0; i < GeodeStoneVariant.values().length; i++){
            list.add(new ItemStack(item, 1, i));
        }
    }

    public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){
        return new ItemStack(this, 1, getMetaFromState(state));
    }

}

 

This is the ItemBlockMetadata class I'm using.

public class ItemBlockMetadata extends ItemBlock {

    public ItemBlockMetadata(Block block){
        super(block);
        this.setHasSubtypes(true);
    }

    public String getUnlocalizedName(ItemStack stack){
        return super.getUnlocalizedName(stack) + "_" + GeodeStoneVariant.values()[stack.getItemDamage()].toString().toLowerCase();
    }

    public int getMetadata(int meta){
        return meta;
    }

    public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
        return super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
    }

}

 

This is the block state file for geode stone:

{
    "variants": {
        "variant=smooth": { "model": "beyond:geode_stone_smooth" },
        "variant=cobble": { "model": "beyond:geode_stone_cobble" },
        "variant=brick": { "model": "beyond:geode_stone_brick" }
    }
}

 

And finally, what seems to be causing the issue: an item model for one of these variants.

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

 

Now, for whatever reason, this doesn't give any errors related to missing/malformed files AT ALL. Nothing. It just refuses to load the item model for some reason.

Sorry for the long winded post, I've been at this for a long time and I've tried nearly everything to no avail. Thanks guys.

Posted

Stop using ModelMesher and start using ModelLoader (and call it during preInit). All your problems will magically go away.

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.

Posted
2 hours ago, iWasHere said:

You're a wizard. That worked perfect! Thank you!

Yes. I am. But the tutorial you were using is old and shitty.

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.

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.