Posted February 19, 20169 yr Help me solve this problem. When I place my block, i want an item to spawn. I tryed this method but it isn't working. @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { if(!worldIn.isRemote) { float f = 0.7F; double d = worldIn.rand.nextFloat() * f + (1.0F - f) * 0.5D; double d1 = worldIn.rand.nextFloat() * f + (1.0F - f) * 0.2D + 0.6D; double d2 = worldIn.rand.nextFloat() * f + (1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem(worldIn, hitX + d, hitY + d1, hitZ + d2, new ItemStack(Items.apple, 1)); //entityitem.delayBeforeCanPickup = 5; worldIn.spawnEntityInWorld(entityitem); } return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer); } anyone knows solution? Thanks _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
February 19, 20169 yr Author Thanks, it works now. One more question, i see that pick up delay int (EntityItem.delayBeforeCanPickup ) is now private, is there any substitute? new code @Override public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { if(!world.isRemote) { EntityItem entityitem = new EntityItem(world, pos.getX(), pos.getY()+1, pos.getZ(), new ItemStack(Items.apple, 1)); //entityitem.delayBeforeCanPickup = 5; world.spawnEntityInWorld(entityitem); } return super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer); } _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
February 19, 20169 yr Author Yes, that worked. Thank you I used entityitem.setPickupDelay(20); to set my own delay _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
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.