Jump to content

Metadata block not dropping with metadata


ss7

Recommended Posts

Hello,

 

I've made a block with metadata. All is working fine except when i break the block, it drops with metadata 0.

I've also tried overriding damageDropped() and idDropped() and getBlockDropped() but no such luck.

 

Here is my Block class:

 

 

public class Phantomblock extends Block
{
public Phantomblock(int par1, Material par2Material)
{
	super(par1, par2Material);
}

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

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
	if (world.getBlockMetadata(x, y, z) == 1)
	{
		return new ItemStack(blockID, 1, 1);
	}

	return new ItemStack(blockID, 1, 0);
}

@Override
public int damageDropped(int par1)
{
	return par1;
}
}

 

 

My ItemBlock class:

 

 

public class PhantomblockItem extends ItemBlock
{
public PhantomblockItem(int par1)
{
	super(par1);
}

@Override
public String getUnlocalizedName(ItemStack par1ItemStack)
{		
	if (par1ItemStack.getItemDamage() == 1)
	{
		return "phantomblock_inverted";
	}

	return "phantomblock";
}

@Override
public int getMetadata(int par1)
{
	return par1;
}
}

 

 

And i register it like this:

 

GameRegistry.registerBlock(phantomblock, PhantomblockItem.class, "phantomblock");

 

I hope you know why it's not dropping with metadata!

 

Thanks in advance!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Hello,

 

@shucke Have you even looked at my Block class? There is already that damageDropped() method!

 

The strange thing is that the block drops with metadata 1.

 

EDIT: OK, i haven't had that setHasSubtypes(true) in my ItemBlock class. That solved everything!

 

This is now

 

SOLVED

 

ss7

You sir are a god damn hero.

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.