Jump to content

Recommended Posts

Posted

Hello.  I am trying to get an ItemStack to add an item by choosing an subItem but I can't seem to get it to work.  The code works for items with no sub items.  Here is parts of what I have:

 

WIGMbush = new Bush(Constants.WIGMBUSH, new ItemStack(StaticItem.bushleaves, 1, 1), new ItemStack(Seeds.bushseed));
GameRegistry.registerBlock(WIGMbush , Constants.WIGMBUSH);

 

ItemStack(StaticItem.bushleaves, 1, 1) is in question.  This item registers in Minecraft just fine and as I said this code works when I replace this with an item without sub items.  I just want to add the sub item item as a drop.  Anyone that can give me a hint to what I am missing will really make my day :D

Posted

I'm using getDrops in the Bush class with an ArrayList to drop multiple items but when I add an ItemStack with sub items, it doesnt work.  I thought that if I added the ItemStack(Item, Stack, Damage) it would just work.  Has to be something simple, just not able to figure it out.

 

 

Posted

Here is the error I get when I run it:

 

Attempted to add a EntityItem to the world with a invalid item at (94.65,  65.17, 270.77), this is most likely a config issue between you and the server. Please double check your configs

Posted

public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_,
		int p_149690_3_, int p_149690_4_, int p_149690_5_,
		float p_149690_6_, int p_149690_7_) {
	// TODO Auto-generated method stub
	super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_,
			p_149690_4_, p_149690_5_, p_149690_6_, 0);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){
	ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
	System.out.println(metadata);
	if (metadata == 0){
		for (int i = 0; i < 3 + fortune; ++i){
			if (world.rand.nextInt(15) <= 7){
				ret.add(drops);
			}
		}
	}
	for (int i = 0; i < 1 + fortune; ++i){
		if (world.rand.nextInt(16) > {
		ret.add(drops2);
		}
	}
	return ret;
}

 

The drop items are

 

private ItemStack drops;

private ItemStack drops2;

 

They are initialized at constructor

Posted

Oh...I got what you are saying...Sorry.  I should have explained that this is in the preInit. The StaticItem.bushleaves is an Item.

 

I just figured out my issue.  I was doing everything right, but my PreInit was out of order...I needed to created the StaticItem before I made the Bush...."Bashes head on desk"

 

Your comment about the PreInit made me check it.  Thank you for that. :D

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.