Jump to content

[1.6.4]Custom Log Block Help?


RetsuWolf

Recommended Posts

Greetings! I'm trying to make a custom log block and I think I've gotten half of it done but I don't know how to actually name the block so that it will show up in Creative Tab. Could someone help me out? Here is the code.

 

Log Block Class

 

package fantasy_biomes.blocks;

import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fantasy_biomes.Main;

public class BlockTreeBlock extends BlockLog
{
    public Icon[] icons;
    public String[] textureNames = new String[] { "redwood" };

    public BlockTreeBlock(int id)
    {
        super(id);
        this.setHardness(1.5F);
        this.setResistance(5F);
        this.setStepSound(Block.soundWoodFootstep);
        setBurnProperties(this.blockID, 5, 20);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public Icon getIcon (int side, int metadata)
    {
        int tex = (metadata % 4);
        int orientation = metadata / 4;

        switch (orientation)
        //Ends of logs
        {
        case 0:
            if (side == 0 || side == 1)
                return icons[tex + 4];
            break;
        case 1:
            if (side == 4 || side == 5)
                return icons[tex + 4];
            break;
        case 2:
            if (side == 2 || side == 3)
                return icons[tex + 4];
            break;
        }

        return icons[tex];
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons (IconRegister iconRegister)
    {
        this.icons = new Icon[textureNames.length];

        for (int i = 0; i < this.icons.length; ++i)
        {
            this.icons[i] = iconRegister.registerIcon(Main.modid + ":" + textureNames[i]);
        }
    }

    public int idDropped (int par1, Random par2Random, int par3)
    {
        return this.blockID;
    }

    @Override
    public int damageDropped (int meta)
    {
        return meta % 4;
    }

    public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
    {
        return metadata % 4 != 2 ? blockFlammability[blockID] : 0;
    }

    public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face)
    {
        return metadata % 4 != 2 ? blockFireSpreadSpeed[blockID] : 0;
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
        for (int i = 0; i < 1; i++)
            par3List.add(new ItemStack(par1, 1, i));
    }
}

 

Basically I'm just wanting to know how to name sub blocks so that they'll show in Creative Tab. Any help is greatly appreciated! Thank you!

Link to comment
Share on other sites

if i understand your question right you want to place the (sub)blocks in a creativetab and you want to name them.

if so:

 

for the creativetab you can use setCreativeTab(CreativeTab tab) in the constructor of your block to place it in that creativetab.

 

for the names you can use LanguageRegistry.addName(new ItemStack(BlockTreeBlock, 1, meta), "name of the block"). you can place this in the same spot as where you register your block. you can use a for loop and an array of names to go through all the different meta's and name the subblocks.

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

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.