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

  • Author

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.

 

 

  • Author

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

  • Author

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

  • Author

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

 

Doesn't this do this create a new ItemStack each time? 

  • Author

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

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.