Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Metadata not saving when block is placed


Bobkarate
 Share

Recommended Posts

When I try to place down my block with metadata, it always places down the first metadata.

 

My BlockLeaf class:

public class CanadiaLeaf extends BlockLeaves{

public static final String[][] leafTypes = new String[][] {{"LeafMaple", "LeafRedCedar"}, {"leafMapleOpaque", "leafRedCedarOpaque"}};
public static final String[] leaves = new String[] {"Maple", "RedCedar"};

protected void func_150124_c(World world, int x, int y, int z, int side, int meta)
    {
        if (meta == 1)
        {
            this.dropBlockAsItem(world, x, y, z, new ItemStack(Canadia.maplesap, 1, 0));
        }
    }

    /**
     * Determines the damage on the item the block drops. Used in cloth and wood.
     */

public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
    {
        return Item.getItemFromBlock(Canadia.blockSapling);
    }


    public int damageDropped(int i)
    {
        return super.damageDropped(i) + 0;
    }

    /**
     * Get the block's damage value (for use with pick block).
     */
    public int getDamageValue(World world, int x, int y, int z)
    {
        return world.getBlockMetadata(x, y, z);
    }

    /**
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
     */
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item item, CreativeTabs tab, List list)
    {
    	for(int i = 0; i < leaves.length; i++){
		list.add(new ItemStack(item, 1, i));
	}
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconregister)
    {
        for (int i = 0; i < leafTypes.length; ++i)
        {
            this.field_150129_M[i] = new IIcon[leafTypes[i].length];

            for (int j = 0; j < leafTypes[i].length; ++j)
            {
                this.field_150129_M[i][j] = iconregister.registerIcon(Canadia.MODID + ":" + this.getUnlocalizedName().substring(5) + leafTypes[i][j]);
            }
        }
    }

@Override
public IIcon getIcon(int side, int meta) {
	return (meta & 3) == 1 ? this.field_150129_M[this.field_150127_b][1] : this.field_150129_M[this.field_150127_b][0];
}

@Override
public String[] func_150125_e() {
	return leaves;
}

@Override
public boolean renderAsNormalBlock() {
	return false;
}

@Override
public boolean isOpaqueCube(){
	return false;

}

@Override
public boolean shouldSideBeRendered(IBlockAccess blockaccess, int x, int y, int z, int side){
	return true;
}
}

 

 

And my ItemBlockLeaf class:

 

public class ItemLeafBlocks extends ItemBlock {

public static final String[] leaves = new String[] {"Maple", "RedCedar"};

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

public String getUnlocalizedName(ItemStack itemstack){
	int i = itemstack.getItemDamage();
	if (i < 0 || i >= leaves.length){
		i = 0;
	}

	return super.getUnlocalizedName() + "." + leaves[i];
}

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

 

Thanks for your help!

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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.