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

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

}

 

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

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.