Jump to content

[SOLVED][1.7.10] drop sapling with right id

Guest Abrynos

Recommended Posts

Guest Abrynos

right now i'm dropping a sapling with this function:

ArrayList<ItemStack> items = mined.getDrops(world, x, y, z, meta, level);
		for(ItemStack item : items){
			item = new ItemStack(item.getItem(), item.stackSize, world.getBlockMetadata(x, y, z));
			float f = 0.7F;
	        Random rand = new Random();
	        double d0 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
	        double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
	        double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
	        int l = world.getBlockMetadata(x, y, z);
	        EntityItem entityitem = new EntityItem(world, (double) player.posX + d0, (double) player.posY + d1, (double) player.posZ + d2, item);
	        entityitem.delayBeforeCanPickup = 10;

		world.setBlock(x, y, z, Blocks.air);


but somehow it drops oak saplings which grow to the tree they came from. but sadly they have the name oak sapling and the oak saplings texture.

Link to comment
Share on other sites

Why are you creating a new


with the same


and stack size but using the


's metadata instead of the existing


's metadata?


The metadata values used by Saplings aren't the same values as those used by Leaves.


already returns a list of


s with the correct metadata values for you, there's no need to subvert it.


You shouldn't need to create a new


for each iteration of the loop, create an instance once, store it as an instance field of your class and use that.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.

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.