Posted July 11, 201312 yr 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 } } }
July 11, 201312 yr Author 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.
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.