@Override public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { if (RANDOM.nextInt(8) != 0) return; ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM, fortune); if (!seed.isEmpty()) drops.add(seed); } }
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List<ItemStack> ret = new java.util.ArrayList<ItemStack>(); if (state.getValue(HALF) == EnumBlockHalf.UPPER) { IBlockState iblockstate = world.getBlockState(pos.down()); ret.add(new ItemStack(iblockstate.getBlock().getItemDropped(iblockstate, RANDOM, fortune))); } else { if (state.getValue(VARIANT) == EnumPlantType.SUNDEW) ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.BIO_LUMINESCENCE.ordinal())); else if (state.getValue(VARIANT) == EnumPlantType.WEEPING_BLUEBELL) ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.BLUEBELL_PETAL.ordinal())); else if (state.getValue(VARIANT) == EnumPlantType.BULLRUSH) ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.PAPYRUS.ordinal())); else if (state.getValue(VARIANT) == EnumPlantType.TALL_BLOOM) ret.add(new ItemStack(this, 1, getMetaFromState(state))); else if (state.getValue(VARIANT) == EnumPlantType.TANGLED_STALK_MUSHROOM) ret.add(new ItemStack(this, 1, getMetaFromState(state))); else if (state.getValue(VARIANT) == EnumPlantType.HIGH_CAPPED_MUSHROOM) ret.add(new ItemStack(this, 1, getMetaFromState(state))); else { ItemStack seed = ForgeHooks.getGrassSeed(RANDOM, fortune); if (!seed.isEmpty()) ret.add(seed); else ret.add(new ItemStack(this, 1, getMetaFromState(state))); } } return ret; }
break; case 1: ItemStack seed = ForgeHooks.getGrassSeed(rand, rand.nextInt(3) + looting); if (seed != null) entityDropItem(seed, 0F);
@Override public ActionResult<ItemStack> onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (player.canPlayerEdit(blockPos, facing, stack) && !world.isAirBlock(blockPos)) { IBlockState blockState = world.getBlockState(blockPos); if (blockState.getBlock() == Blocks.GRASS || blockState.getBlock() == Blocks.DIRT) { if (blockState.getBlock() == Blocks.GRASS && player.isSneaking()) { if(GTUtility.doDamageItem(stack, this.cost, false)) { if (world.rand.nextInt(3) == 0) { ItemStack grassSeed = ForgeHooks.getGrassSeed(world.rand, 0); Block.spawnAsEntity(world, blockPos.up(), grassSeed); } world.playSound(null, blockPos, SoundEvents.ITEM_HOE_TILL, SoundCategory.PLAYERS, 1.0F, 1.0F); world.setBlockState(blockPos, Blocks.DIRT.getDefaultState() .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT)); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } else if (blockState.getBlock() == Blocks.GRASS || blockState.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || blockState.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.COARSE_DIRT) { if (GTUtility.doDamageItem(stack, this.cost, false)) { world.playSound(null, blockPos, SoundEvents.ITEM_HOE_TILL, SoundCategory.PLAYERS, 1.0F, 1.0F); world.setBlockState(blockPos, Blocks.FARMLAND.getDefaultState()); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } } } return ActionResult.newResult(EnumActionResult.FAIL, stack); }