Jump to content

[1.5] Metadata Item Drops


Neko_Dude

Recommended Posts

In this set-up how would I add item drops (the items are of a single metadata) to a block of a single metadata? Any help would be appreciated.

 

package tutorial;

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

import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockTutorialBlock extends BlockGeneralTutorial
{
public BlockTutorialBlock(int id, Material par2Material) 
{
	super(id, par2Material);
}

@SideOnly(Side.CLIENT)
private Icon[] icons;

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	icons = new Icon[4];

	for(int i = 0; i < icons.length; i++)
	{
		icons[i] = par1IconRegister.registerIcon(Tutorial.modid + ":" + (this.getUnlocalizedName().substring(5)) + i);
	}
}

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	switch(par2)
	{
		case 0:
			return icons[0];
		case 1:
		{
			switch(par1)
			{
				case 0:
					return icons[1];
				case 1:
					return icons[2];
				default:
					return icons[3];
			}
		}
		default: 
		{
			System.out.println("Invalid metadata for " + this.getUnlocalizedName());
			return icons[0];
		}
	}
}

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


public int damageDropped (int metadata) 
{
	return metadata;
}

@Override
    public int idDropped (int metadata, Random random, int par2) {
        switch (metadata) {
        case 0:
            return Tutorial.tutorialItem.itemID;
        case 1:
            return Tutorial.tutorialItem.itemID; //Different ID Here
        default:
            // Error case!
            return -1; // air
        }
    }

}

 

Link to comment
Share on other sites

Some thoughts:

1) Please post code in [nobbc]


[/nobbc] tags. Much easier to read.

2) You should use @Override, it helps you resolve possible errors in the future

3) Change your damageDropped method to return the damage value of the Item you want to drop

 

I'm sorry and thanks I'm sort of new here.

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.



×
×
  • Create New...

Important Information

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