Posted August 26, 201510 yr 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.spawnEntityInWorld(entityitem); } 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.
August 26, 201510 yr Why are you creating a new ItemStack with the same Item and stack size but using the Block 's metadata instead of the existing ItemStack 's metadata? The metadata values used by Saplings aren't the same values as those used by Leaves. Block#getDrops already returns a list of ItemStack s with the correct metadata values for you, there's no need to subvert it. You shouldn't need to create a new Random 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.
August 27, 201510 yr Oh that was it. i had to do it for another block and just copied it from another if clause.
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.