<commit_before>package tehnut.resourceful.crops.compat.enderio;

import crazypants.enderio.machine.farm.TileFarmStation;
import crazypants.enderio.machine.farm.farmers.HarvestResult;
import crazypants.enderio.machine.farm.farmers.IHarvestResult;
import crazypants.enderio.machine.farm.farmers.PlantableFarmer;
import crazypants.util.BlockCoord;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import tehnut.resourceful.crops.blocks.BlockRCrop;
import tehnut.resourceful.crops.items.ItemSeed;
import tehnut.resourceful.crops.util.Utils;

import java.util.ArrayList;
import java.util.List;

public class ResourcefulCropsFarmer extends PlantableFarmer {

    @Override
    public boolean canHarvest(TileFarmStation farmStation, BlockCoord coord, Block block, int meta) {
        return block instanceof BlockRCrop && farmStation.getWorldObj().getBlockMetadata(coord.x, coord.y, coord.z) == 7;
    }

    @Override
    public boolean canPlant(ItemStack stack) {
        return stack != null && stack.getItem() instanceof ItemSeed && Utils.getItemDamage(stack) != Short.MAX_VALUE;
    }

    @Override
    public boolean prepareBlock(TileFarmStation farmStation, BlockCoord coord, Block block, int meta) {
        if (block == null)
            return false;

        ItemStack seedStack = farmStation.getSeedTypeInSuppliesFor(coord);
        if (seedStack == null)
            return false;

        if (!canPlant(seedStack))
            return false;

        Block plantOn = farmStation.getBlock(coord.getLocation(ForgeDirection.DOWN));

        if (!block.canSustainPlant(farmStation.getWorldObj(), coord.x, coord.y, coord.z, ForgeDirection.UP, new ItemSeed()) && (plantOn == Blocks.dirt || plantOn == Blocks.grass)) {
            farmStation.getWorldObj().setBlock(coord.x, coord.y + 1, coord.z, Blocks.farmland);
            farmStation.damageHoe(1, coord);
        }


        Item seed = seedStack.getItem();

        if (seed.onItemUse(seedStack, farmStation.getFakePlayer(), farmStation.getWorldObj(), coord.x, coord.y - 1, coord.z, 1, 0.5F, 0.5F, 0.5F))
            farmStation.takeSeedFromSupplies(coord);

        return false;
    }

    @Override<commit_msg>Okay, NOW it works correctly.<commit_after>package tehnut.resourceful.crops.compat.enderio;

import crazypants.enderio.machine.farm.TileFarmStation;
import crazypants.enderio.machine.farm.farmers.HarvestResult;
import crazypants.enderio.machine.farm.farmers.IHarvestResult;
import crazypants.enderio.machine.farm.farmers.PlantableFarmer;
import crazypants.util.BlockCoord;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import tehnut.resourceful.crops.blocks.BlockRCrop;
import tehnut.resourceful.crops.items.ItemSeed;
import tehnut.resourceful.crops.util.Utils;

import java.util.ArrayList;
import java.util.List;

public class ResourcefulCropsFarmer extends PlantableFarmer {

    @Override
    public boolean canHarvest(TileFarmStation farmStation, BlockCoord coord, Block block, int meta) {
        return block instanceof BlockRCrop && farmStation.getWorldObj().getBlockMetadata(coord.x, coord.y, coord.z) == 7;
    }

    @Override
    public boolean canPlant(ItemStack stack) {
        return stack != null && stack.getItem() instanceof ItemSeed && Utils.getItemDamage(stack) != Short.MAX_VALUE;
    }

    @Override
    public boolean prepareBlock(TileFarmStation farmStation, BlockCoord coord, Block block, int meta) {
        if (block == null)
            return false;

        ItemStack seedStack = farmStation.getSeedTypeInSuppliesFor(coord);
        if (seedStack == null)
            return false;

        if (!canPlant(seedStack))
            return false;

        if (!farmStation.hasHoe())
            return false;

        Block plantOn = farmStation.getBlock(coord.getLocation(ForgeDirection.DOWN));

        if (!block.canSustainPlant(farmStation.getWorldObj(), coord.x, coord.y, coord.z, ForgeDirection.UP, new ItemSeed()) && (plantOn == Blocks.dirt || plantOn == Blocks.grass)) {
            farmStation.getWorldObj().setBlock(coord.x, coord.y - 1, coord.z, Blocks.farmland);
            farmStation.damageHoe(1, coord);
        }


        Item seed = seedStack.getItem();

        if (seed.onItemUse(seedStack, farmStation.getFakePlayer(), farmStation.getWorldObj(), coord.x, coord.y - 1, coord.z, 1, 0.5F, 0.5F, 0.5F))
            farmStation.takeSeedFromSupplies(coord);

        return false;
    }

    @Override
{'fraction_non_alphanumeric': 0.10930424042815974, 'fraction_numerical': 0.004528612597776863, 'mean_word_length': 3.7684003925417078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '379635', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1520, 'n_words': 291}