Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

Hi

 

I don't know why, but I suggest:

add a breakpoint in Block.harvestBlock() and step through until you find out where the metadata is being discarded.  It should be pretty easy to track?

 

-TGG

 

  • Author

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.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.