MC Modding
Please register and join the community!

[1.2.3]making new tool types (example paxel)

View previous topic View next topic Go down

[1.2.3]making new tool types (example paxel)

Post by pv9avenger on Tue Mar 13, 2012 11:22 pm

first of start by coping one of the "ItemSpade, ItemAxe or ItemPickaxe"
now you should have a file like this one
Code:

package net.minecraft.src;

public class ItemAxe extends ItemTool
{
    private static Block blocksEffectiveAgainst[];

    protected ItemAxe(int par1, EnumToolMaterial par2EnumToolMaterial)
    {
        super(par1, 3, par2EnumToolMaterial, blocksEffectiveAgainst);
    }

    public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
    {
        if (par2Block != null && par2Block.blockMaterial == Material.wood)
        {
            return efficiencyOnProperMaterial;
        }
        else
        {
            return super.getStrVsBlock(par1ItemStack, par2Block);
        }
    }

    static
    {
        blocksEffectiveAgainst = (new Block[]
                {
                    Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.stairDouble, Block.stairSingle, Block.pumpkin, Block.pumpkinLantern
                });
    }
}

this is the ItemAxe code now all you have to do is for example add "Block.blockDiamond" at the
Code:

blocksEffectiveAgainst = (new Block[]
                {
                    Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.stairDouble, Block.stairSingle, Block.pumpkin, Block.pumpkinLantern
                });
just add as much as you want to but of course if you would like your tool to be able to get diamonds from a diamond ore then add (the ItemPickaxe code already has the canHarvestBlock code)
Code:

 public boolean canHarvestBlock(Block par1Block)
    {
        if (par1Block == Block.blockDiamond || par1Block == Block.oreDiamond)
        {
            return toolMaterial.getHarvestLevel() >= 2;
        }
    }
right under the
Code:

protected ItemAxe(int par1, EnumToolMaterial par2EnumToolMaterial)
    {
        super(par1, 3, par2EnumToolMaterial, blocksEffectiveAgainst);
    }
i really hope this tut helped you guys Very Happy

pv9avenger
Member

Posts : 8
Join date : 2012-01-31
Age : 18
Location : Iceland

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum