Java 类net.minecraft.block.BlockCrops 实例源码

项目:R0b0ts    文件:AIHarvest.java   
@Override
public boolean shouldExecute()
{
    if (pos == null)
        pos = robot.getBoundInventory();
    if (robot.worldObj.isRemote)
        return true;
    if (target == null)
    {
        int range = robot.getChipset().getRange();
        List<Vector3> result = WorldHelper.getBlocksWithinAABB(robot.worldObj, BlockCrops.class, AxisAlignedBB.getBoundingBox(pos.x - range / 2, pos.y - 1, pos.z - range / 2, pos.x + range / 2, pos.y + 1, pos.z + range / 2));
        if (result.size() > 0)
        {
            for (Vector3 vec : result)
            {
                if (robot.worldObj.getBlockMetadata((int) vec.x, (int) vec.y, (int) vec.z) == 7)
                {
                    target = vec;
                    break;
                }
            }
        }
    }
    return true;
}
项目:Project-Zed    文件:TileEntityIndustrialHarvester.java   
@Override
public void update() {
    super.update();

    if (!worldObj.isRemote && boundedRect != null && worldObj.getTotalWorldTime() % 20L == 0) {
        if (currentCheckingVec == null)
            currentCheckingVec = new Vector3<Integer>(boundedRect.min.x.intValue(), pos.getY(), boundedRect.min.y.intValue());

        // ProjectZed.logHelper.info("boundedRect", boundedRect, "currentCheckingVec", currentCheckingVec, getCurrentFacing());

        final Block currentBlock = BlockUtils.getBlock(worldObj, currentCheckingVec).getBlock();
        final int currentMeta = BlockUtils.getBlockMetadata(worldObj, currentCheckingVec);

        if (currentBlock instanceof BlockLog || (currentBlock instanceof BlockCrops && currentMeta >= 7)) {
            // chopTree((BlockLog) currentBlock);
            chopTree();
            return;
        }

        incrementVector();
    }
}
项目:ForestryLegacy    文件:MillForester.java   
@Override
public void growCrop(World world, int cropId, Vect pos) {

    if (cropId == Block.sapling.blockID) {
        ((BlockSapling) Block.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
    }

    if (cropId == ForestryBlock.firsapling.blockID) {
        ((BlockFirSapling) ForestryBlock.firsapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
    }

    if (cropId == ForestryBlock.sapling.blockID) {
        ((BlockSaplings) ForestryBlock.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
    }

    if (cropId == Block.crops.blockID) {
        ((BlockCrops) Block.crops).fertilize(world, pos.x, pos.y, pos.z);
    }

    if (cropId == Block.netherStalk.blockID) {
        world.setBlockAndMetadataWithNotify(pos.x, pos.y, pos.z, Block.netherStalk.blockID, 3);
    }
}
项目:Bewitchment    文件:TileApiary.java   
private void lookForFlowers() {
    getArea().forEach(
            pos -> {
                final Block block = world.getBlockState(pos).getBlock();
                if ((block instanceof BlockCrops) || block == Blocks.RED_FLOWER || block == Blocks.YELLOW_FLOWER) {
                    if (++flowerCount > 200) flowerCount = 200;
                }
            }
    );
}
项目:Bewitchment    文件:TileApiary.java   
private void bonemealArea() {
    getArea().forEach(
            pos -> {
                final IBlockState state = world.getBlockState(pos);
                if (state.getBlock() instanceof BlockCrops && world.rand.nextInt(400 - flowerCount) == 0) {
                    if (((BlockCrops) state.getBlock()).canGrow(world, pos, state, false)) {
                        ((BlockCrops) state.getBlock()).grow(world, world.rand, pos, state);
                    }
                }
            }
    );
}
项目:Bewitchment    文件:HarvestBrew.java   
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
    int box = 1 + (int) ((float) amplifier / 2F);

    BlockPos posI = pos.add(box, 1, box);
    BlockPos posF = pos.add(-box, -1, -box);

    Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
    int chance = 10 + amplifier * 2;
    int fortune = MathHelper.clamp(amplifier, 0, 5);
    for (BlockPos spot : spots) {
        IBlockState state = world.getBlockState(spot);
        boolean place = amplifier > 1 || world.rand.nextBoolean();
        if (place && state.getBlock() instanceof BlockCrops) {
            BlockCrops crop = (BlockCrops) state.getBlock();
            if (crop.isMaxAge(state)) {
                crop.dropBlockAsItemWithChance(world, spot, state, chance, fortune);
                world.setBlockToAir(spot);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
项目:DecompiledMinecraft    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
项目:Wurst-MC-1.12    文件:BonemealAuraMod.java   
private boolean isCorrectBlock(BlockPos pos)
{
    Block block = WBlock.getBlock(pos);

    if(!(block instanceof IGrowable) || block instanceof BlockGrass
        || !((IGrowable)block).canGrow(WMinecraft.getWorld(), pos,
            WBlock.getState(pos), false))
        return false;

    if(block instanceof BlockSapling)
        return saplings.isChecked();
    else if(block instanceof BlockCrops)
        return crops.isChecked();
    else if(block instanceof BlockStem)
        return stems.isChecked();
    else if(block instanceof BlockCocoa)
        return cocoa.isChecked();
    else
        return other.isChecked();
}
项目:BaseClient    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
项目:BaseClient    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
项目:uniquecrops    文件:Millennium.java   
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {

    if (getAge(state) < ((BlockCrops)state.getBlock()).getMaxAge()) {
        Random rand1 = new Random(getAge(state) + rand.nextInt());
        if (rand1.nextInt(100 * (getAge(state) + 1)) == 0 && world.rand.nextInt(2) == 0) {
            world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(getAge(state) + 1));
        }
    }
}
项目:uniquecrops    文件:Collis.java   
private void checkHighplant(World world, BlockPos pos, IBlockState state, int age) {

    int chanceByHeight = Math.round(pos.getY() / 16);

    if (world.getLightFromNeighbors(pos.up()) >= 9) {
        if (age < ((BlockCrops)state.getBlock()).getMaxAge() && world.rand.nextInt(16 - chanceByHeight) == 0) {
            world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(age + 1));
        }
    }
}
项目:uniquecrops    文件:Enderlily.java   
private void enderlilyTele(World world, BlockPos pos, IBlockState state, int age) {

    if (world.getLightFromNeighbors(pos.up()) >= 9) {
        if (age < ((BlockCrops)state.getBlock()).getMaxAge()) {
            Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
            Iterator it = getBox.iterator();
            while (it.hasNext()) {
                BlockPos looppos = (BlockPos)it.next();
                Block loopblock = world.getBlockState(looppos).getBlock();
                if (loopblock != null && (world.isAirBlock(looppos) || (loopblock instanceof IGrowable && loopblock != this))) {
                    IBlockState savestate = world.getBlockState(looppos);
                    if (world.getBlockState(looppos.add(0, -1, 0)).getBlock() == Blocks.FARMLAND && world.rand.nextInt(7) == 0)
                    {
                        world.setBlockState(looppos, ((BlockCrops)state.getBlock()).withAge(age + 1), 2);
                        world.setBlockState(pos, savestate);
                        UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.PORTAL, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
                        UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.PORTAL, pos.getX(), pos.getY(), pos.getZ(), 6));
                        return;
                    }
                }
            }
        }
    }
}
项目:uniquecrops    文件:TileArtisia.java   
private boolean canAccept(World world, BlockPos pos) {

    Block block = world.getBlockState(pos).getBlock();
    if (block != null && block instanceof BlockCrops) {
        return world.getBlockState(pos).getValue(BlockCrops.AGE) >= ((BlockCrops)block).getMaxAge();
    }
    return false;
}
项目:uniquecrops    文件:EntityLivingBlock.java   
@Override
public void onImpact(RayTraceResult result) {

    if (fallingTile == null) {
        this.setDead();
        return;
    }
    BlockPos pos = new BlockPos(result.hitVec);
    if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
        IBlockState state = worldObj.getBlockState(pos);
        if (!(state.getBlock() instanceof BlockCrops)) {
            worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
            this.setDead();
            return;
        }
    }
    else this.setDead();
}
项目:uniquecrops    文件:ItemGeneric.java   
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
        Block crops = world.getBlockState(pos).getBlock();
        if (crops != null && crops instanceof BlockCrops) {
            if (crops != UCBlocks.cropMerlinia)
                world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
            else if (crops == UCBlocks.cropMerlinia)
                ((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
            else if (crops instanceof BlockNetherWart)
                ((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
            if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
                stack.stackSize--;
            UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
            return EnumActionResult.SUCCESS;
        }
    }
    return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
项目:Backmemed    文件:StructureVillagePieces.java   
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_)
{
    super.readStructureFromNBT(tagCompound, p_143011_2_);
    this.cropTypeA = Block.getBlockById(tagCompound.getInteger("CA"));
    this.cropTypeB = Block.getBlockById(tagCompound.getInteger("CB"));
    this.cropTypeC = Block.getBlockById(tagCompound.getInteger("CC"));
    this.cropTypeD = Block.getBlockById(tagCompound.getInteger("CD"));

    if (!(this.cropTypeA instanceof BlockCrops))
    {
        this.cropTypeA = Blocks.WHEAT;
    }

    if (!(this.cropTypeB instanceof BlockCrops))
    {
        this.cropTypeB = Blocks.CARROTS;
    }

    if (!(this.cropTypeC instanceof BlockCrops))
    {
        this.cropTypeC = Blocks.POTATOES;
    }

    if (!(this.cropTypeD instanceof BlockCrops))
    {
        this.cropTypeD = Blocks.BEETROOTS;
    }
}
项目:Backmemed    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.FARMLAND)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate) && this.wantsToReapStuff && (this.currentTask == 0 || this.currentTask < 0))
        {
            this.currentTask = 0;
            return true;
        }

        if (iblockstate.getMaterial() == Material.AIR && this.hasFarmItem && (this.currentTask == 1 || this.currentTask < 0))
        {
            this.currentTask = 1;
            return true;
        }
    }

    return false;
}
项目:CustomWorldGen    文件:StructureVillagePieces.java   
/**
 * (abstract) Helper method to read subclass data from NBT
 */
protected void readStructureFromNBT(NBTTagCompound tagCompound)
{
    super.readStructureFromNBT(tagCompound);
    this.cropTypeA = Block.getBlockById(tagCompound.getInteger("CA"));
    this.cropTypeB = Block.getBlockById(tagCompound.getInteger("CB"));
    this.cropTypeC = Block.getBlockById(tagCompound.getInteger("CC"));
    this.cropTypeD = Block.getBlockById(tagCompound.getInteger("CD"));

    if (!(this.cropTypeA instanceof BlockCrops))
    {
        this.cropTypeA = Blocks.WHEAT;
    }

    if (!(this.cropTypeB instanceof BlockCrops))
    {
        this.cropTypeB = Blocks.CARROTS;
    }

    if (!(this.cropTypeC instanceof BlockCrops))
    {
        this.cropTypeC = Blocks.POTATOES;
    }

    if (!(this.cropTypeD instanceof BlockCrops))
    {
        this.cropTypeD = Blocks.BEETROOTS;
    }
}
项目:CustomWorldGen    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.FARMLAND)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate) && this.wantsToReapStuff && (this.currentTask == 0 || this.currentTask < 0))
        {
            this.currentTask = 0;
            return true;
        }

        if (iblockstate.getMaterial() == Material.AIR && this.hasFarmItem && (this.currentTask == 1 || this.currentTask < 0))
        {
            this.currentTask = 1;
            return true;
        }
    }

    return false;
}
项目:BetterWithAddons    文件:BlockCropRush.java   
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
    checkAndDropBlock(world, pos, state);
    BlockPos up = pos.up();

    int meta = state.getValue(AGE);

    double growthChance = 15D;

    if(world.getBlockState(pos.down()).getBlock().isFertile(world, pos.down()))
        growthChance /= 1.33D;
    else if(world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, this))
        growthChance /= 1.2D;
    for(EnumFacing facing : EnumFacing.HORIZONTALS) {
        IBlockState check = world.getBlockState(pos.offset(facing));
        if(check.getBlock() instanceof BlockCrops)
            growthChance /= 1.1D;
    }

    if(!isMaxAge(state))
    {
        if(world.getLightFromNeighbors(up) > 12)
        {
            if(rand.nextInt(MathHelper.floor(growthChance)) == 0)
                world.setBlockState(pos, state.withProperty(AGE, meta + 1));
        }
    }
}
项目:BetterWithAddons    文件:BlockCropRice.java   
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
    checkAndDropBlock(world, pos, state);

    int meta = state.getValue(AGE);

    double growthChance = 15D;

    if(world.getBlockState(pos.down()).getBlock().isFertile(world, pos.down()))
        growthChance /= 1.33D;
    else if(world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, this))
        growthChance /= 1.2D;
    for(EnumFacing facing : EnumFacing.HORIZONTALS) {
        IBlockState check = world.getBlockState(pos.offset(facing));
        if(check.getBlock() instanceof BlockCrops)
            growthChance /= 1.1D;
    }

    if(!isMaxAge(state))
    {
        if(rand.nextInt(MathHelper.floor(growthChance)) == 0)
            world.setBlockState(pos, state.withProperty(AGE, meta + 1));
    }
}
项目:LittleThings-old    文件:RightClickCrops.java   
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock e)
{
    if (!e.getWorld().isRemote) {
        BlockPos pos = e.getPos();
        IBlockState state = e.getWorld().getBlockState(pos);
        if (state.getBlock() instanceof BlockCrops) {
            BlockCrops block = (BlockCrops) state.getBlock();
            if ((block == Blocks.wheat || block == Blocks.carrots || block == Blocks.potatoes) && state.getValue(BlockCrops.AGE) == 7) {
                performAction(e.getWorld(), e.getPos(), state, BlockCrops.AGE);
            } else if (block == Blocks.beetroots && state.getValue(BlockBeetroot.BEETROOT_AGE) == 3) {
                performAction(e.getWorld(), e.getPos(), state, BlockBeetroot.BEETROOT_AGE);
            }
        }
    }
}
项目:CrystalMod    文件:FarmUtil.java   
public static void addStandardCrop(ItemStack stack, int grownMeta)
{
    if (Block.getBlockFromItem(stack.getItem()) == null) {
      return;
    }
    if (grownMeta == OreDictionary.WILDCARD_VALUE) {
      for (int a = 0; a < 16; a++) {
         getCrops(CropType.NORMAL).add(Block.getBlockFromItem(stack.getItem()).getUnlocalizedName() + a);
      }
    } else {
        getCrops(CropType.NORMAL).add(Block.getBlockFromItem(stack.getItem()).getUnlocalizedName() + grownMeta);
    }
    if (((Block.getBlockFromItem(stack.getItem()) instanceof BlockCrops)) && (grownMeta != 7)) {
        getCrops(CropType.NORMAL).add(Block.getBlockFromItem(stack.getItem()).getUnlocalizedName() + "7");
    }
}
项目:CrystalMod    文件:FarmUtil.java   
public static void addClickableCrop(ItemStack stack, int grownMeta)
{
    if (Block.getBlockFromItem(stack.getItem()) == null) {
      return;
    }
    Block itemBlock = Block.getBlockFromItem(stack.getItem());
    if (grownMeta == OreDictionary.WILDCARD_VALUE) {
      for (int a = 0; a < 16; a++) {
          getCrops(CropType.CLICKABLE).add(itemBlock.getUnlocalizedName() + a);
      }
    } else {
        getCrops(CropType.CLICKABLE).add(itemBlock.getUnlocalizedName() + grownMeta);
    }
    if ((itemBlock instanceof BlockCrops) && (grownMeta != ((BlockCrops)itemBlock).getMaxAge())) {
        getCrops(CropType.CLICKABLE).add(itemBlock.getUnlocalizedName() + ((BlockCrops)itemBlock).getMaxAge());
    }
}
项目:CrystalMod    文件:FarmUtil.java   
public static void addStackedCrop(Block block, int grownMeta)
{
    if (grownMeta == OreDictionary.WILDCARD_VALUE) {
        for (int a = 0; a < 16; a++) {
            getCrops(CropType.STACKED).add(block.getUnlocalizedName() + a);
        }
    } else {
        getCrops(CropType.STACKED).add(block.getUnlocalizedName() + grownMeta);
    }
    if ((block instanceof BlockCrops) && (grownMeta != ((BlockCrops)block).getMaxAge())) {
        getCrops(CropType.STACKED).add(block.getUnlocalizedName() + ((BlockCrops)block).getMaxAge());
    }
}
项目:CrystalMod    文件:FarmUtil.java   
public static boolean isNormalCrop(World world, BlockPos pos)
{
    if (world.isAirBlock(pos)) {
      return false;
    }
    boolean found = false;
    IBlockState state = world.getBlockState(pos);
    Block bi = state.getBlock();
    for (int a = 0; a < 16; a++) {
      if ((getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + a)))
      {
        found = true;
        break;
      }
    }
    int md = bi.getMetaFromState(state);
    if ((((bi instanceof IGrowable)) && (!(bi instanceof BlockStem))) || (((bi instanceof BlockCrops)) && (!found)) || ((bi == Blocks.NETHER_WART)) || ((bi == Blocks.COCOA)) || (getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + md))) {
      return true;
    }
    return false;
}
项目:FairyFactions    文件:FairyJob.java   
private boolean breakablePlant( final Block i, final int j, final Block above, final Block below ) {
    // we're gonna treat this as everything block that should be punched.
    // cocoa?... hrmmm
    // mushrooms: tricky, when there are at least 4 other mushrooms of same type in 9x3x9 area.
    // snow?  maybe?  if there's plants?  if there's no shovel?

    // crops: that should be wheat, carrots and potatoes, when MD level is 7.
    return (i instanceof BlockCrops && j == 7)
            // not a crop, a bush apparently...
            || i == Blocks.nether_wart && j == 3
            // reeds: when above reeds.
            || i == Blocks.reeds && below == Blocks.reeds
            // cactus: break only when above sand and below cactus, to prevent losing drops.
            || i == Blocks.cactus && above == Blocks.cactus && below != Blocks.cactus
            // melons/pumkins... always?
            || i == Blocks.melon_block || i == Blocks.pumpkin
            // tallgrass, which drops seeds!
            || i == Blocks.tallgrass
            // all other doo-dads? ie bushes and tall plants?
            || i == Blocks.yellow_flower
            || i == Blocks.red_flower
            || i == Blocks.snow;
}
项目:Factorization    文件:ScanColor.java   
@Override
public void motorHit(ServoMotor motor) {
    Coord at = motor.getCurrentPos();
    at = at.add(motor.getOrientation().top);
    FzColor col = FzColor.readColor(at);
    if (col != FzColor.NO_COLOR) {
        motor.getArgStack().push(col);
        return;
    }
    Block block = at.getBlock();
    if (block instanceof BlockReed || block instanceof BlockCactus) return; // Colors don't change, so give nothing.
    Integer age = at.getProperty(BlockCrops.AGE);
    if (age != null) {
        int md = age;
        motor.getArgStack().push(colorArray[md]);
    }
}
项目:LegacyFarms    文件:TileMillForester.java   
@Override
public void growCrop(ItemStack crop, BlockPosition blockPos) {
    if (crop.isItemEqual(new ItemStack(Blocks.sapling))) {
        ((BlockSapling) Blocks.sapling).func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
    }
    if (ForestryProxy.moduleArboricultureEnabled) {
        if (crop.isItemEqual(new ItemStack(ForestryProxy.blockSapling))) {
            ForestryProxy.blockSapling.func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
        }
    }
    if (crop.getItem() == Item.getItemFromBlock(Blocks.wheat)) {
        ((BlockCrops) Blocks.wheat).func_149853_b(worldObj, worldObj.rand, blockPos.x, blockPos.y, blockPos.z);
    }
    if (crop.isItemEqual(new ItemStack(Blocks.nether_wart))) {
        blockPos.setBlock(worldObj, blockPos.getBlock(worldObj), 3);
    }
}
项目:Aura-Cascade    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onHarvestEvent(BlockEvent.HarvestDropsEvent event) {

    if (event.getHarvester() != null && event.getHarvester().inventory.getCurrentItem() != null && AngelsteelToolHelper.isAngelsteelTool(event.getHarvester().inventory.getCurrentItem().getItem())) {
        if (event.getHarvester().inventory.getCurrentItem().getTagCompound() == null) {
            event.getHarvester().inventory.getCurrentItem().setTagCompound(AngelsteelToolHelper.getRandomBuffCompound(((IAngelsteelTool) event.getHarvester().inventory.getCurrentItem().getItem()).getDegree()));
        }
        int fortune = AngelsteelToolHelper.readFromNBT(event.getHarvester().inventory.getCurrentItem().getTagCompound())[1];
        if (event.getFortuneLevel() < fortune) {
            //Cancels the event and breaks the block again
            if (event.getDropChance() <= 0 && event.getDrops().size() > 0 && !(event.getState().getBlock() instanceof BlockCrops)) {
                event.setDropChance(0);
                event.getDrops().clear();
                event.getState().getBlock().dropBlockAsItemWithChance(event.getWorld(), event.getPos(), event.getState(), 1F, fortune);
            }
        }
    }
}
项目:ExpandedRailsMod    文件:EntityAIHarvestFarmland.java   
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.FARMLAND)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate) && this.wantsToReapStuff && (this.currentTask == 0 || this.currentTask < 0))
        {
            this.currentTask = 0;
            return true;
        }

        if (iblockstate.getMaterial() == Material.AIR && this.hasFarmItem && (this.currentTask == 1 || this.currentTask < 0))
        {
            this.currentTask = 1;
            return true;
        }
    }

    return false;
}
项目:CrystalMod    文件:FarmUtil.java   
public static boolean isGrownCrop(World world, BlockPos pos)
{
    if (world.isAirBlock(pos)) {
      return false;
    }
    boolean found = false;
    IBlockState state = world.getBlockState(pos);
    Block bi = state.getBlock();
    for (int a = 0; a < 16; a++) {
      if ((getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + a)) || (getCrops(CropType.STACKED).contains(bi.getUnlocalizedName() + a)) || (getCrops(CropType.CLICKABLE).contains(bi.getUnlocalizedName() + a)))
      {
        found = true;
        break;
      }
    }
    Block biB = world.getBlockState(pos.down()).getBlock();
    int md = bi.getMetaFromState(state);

    if ((((bi instanceof IGrowable)) && (!((IGrowable)bi).canGrow(world, pos, state, world.isRemote)) && (!(bi instanceof BlockStem))) 
            || (((bi instanceof BlockCrops)) && ((BlockCrops)bi).isMaxAge(state) && (!found)) 
            || ((bi == Blocks.NETHER_WART) && (state.getValue(BlockNetherWart.AGE).intValue() >= 3)) 
            || ((bi == Blocks.COCOA) && (state.getValue(BlockCocoa.AGE).intValue() >= 2)) 
            || (getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + md)) || (getCrops(CropType.STACKED).contains(bi.getUnlocalizedName() + md)) || ((getCrops(CropType.CLICKABLE).contains(bi.getUnlocalizedName() + md)) && (biB == bi))) {
      return true;
    }
    return false;
}
项目:Microcosm    文件:EventHandler.java   
public void harvestBerryBush(IBlockState blockState, EntityPlayer player, World world, BlockPos blockPos){
    final BlockCrops crops = (BlockCrops) blockState.getBlock();
    if(crops.isMaxAge(blockState)) {
        final ItemStack item = player.getHeldItemMainhand();
        final int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, item);

        final List<ItemStack> drops = crops.getDrops(world, blockPos, blockState, fortune);

        world.setBlockState(blockPos, crops.withAge(0));

        for(ItemStack drop : drops) {
            dropItem(drop, world, blockPos);
        }
    }
}
项目:DynamicSurroundings    文件:FootstepsRegistry.java   
private void seedMap() {
    // Iterate through the blockmap looking for known pattern types.
    // Though they probably should all be registered with Forge
    // dictionary it's not a requirement.
    final Iterator<Block> itr = Block.REGISTRY.iterator();
    while (itr.hasNext()) {
        final Block block = itr.next();
        final String blockName = MCHelper.nameOf(block);
        if (block instanceof BlockCrops) {
            final BlockCrops crop = (BlockCrops) block;
            if (crop.getMaxAge() == 3) {
                this.registerBlocks("#beets", blockName);
            } else if (blockName.equals("minecraft:wheat")) {
                this.registerBlocks("#wheat", blockName);
            } else if (crop.getMaxAge() == 7) {
                this.registerBlocks("#crop", blockName);
            }
        } else if (block instanceof BlockSapling) {
            this.registerBlocks("#sapling", blockName);
        } else if (block instanceof BlockReed) {
            this.registerBlocks("#reed", blockName);
        } else if (block instanceof BlockFence) {
            this.registerBlocks("#fence", blockName);
        } else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
            this.registerBlocks("NOT_EMITTER", blockName);
        } else if (block instanceof BlockLog || block instanceof BlockPlanks) {
            this.registerBlocks("wood", blockName);
        } else if (block instanceof BlockDoor) {
            this.registerBlocks("bluntwood", blockName);
        } else if (block instanceof BlockLeaves) {
            this.registerBlocks("leaves", blockName);
        } else if (block instanceof BlockOre) {
            this.registerBlocks("ore", blockName);
        } else if (block instanceof BlockIce) {
            this.registerBlocks("ice", blockName);
        }
    }
}
项目:GlassWorks    文件:CropEvent.java   
@SubscribeEvent
public void PlayerRightClickEvent(PlayerInteractEvent event)
{
    if(ConfigHandler.allowCropFeature)
    {
        EntityPlayer player = event.entityPlayer;
        World world = event.world;
        Block crop = world.getBlock(event.x, event.y, event.z);
        int cropMeta = world.getBlockMetadata(event.x, event.y, event.z);
        int dropRate = event.world.rand.nextInt(3) + 1;
        ItemStack drops = new ItemStack(crop.getItemDropped(cropMeta, event.world.rand, Short.MAX_VALUE), dropRate);


        if(player.getCurrentEquippedItem() == null && event.action == Action.RIGHT_CLICK_BLOCK && crop != null)
        {   
            if(crop instanceof BlockCrops && cropMeta >= 7)
            {
                event.entityPlayer.swingItem();
                if(!world.isRemote)
                {
                    EntityItem droppedItem = new EntityItem(world, event.x, event.y, event.z, drops);
                    world.setBlockMetadataWithNotify(event.x, event.y, event.z, 0, 3);
                    world.spawnEntityInWorld(droppedItem);
                }
            }
        }
    }
}
项目:Aura-Cascade    文件:EnchantEventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onHarvestEvent(BlockEvent.HarvestDropsEvent event) {
    Block block = event.getState().getBlock();
    World world = event.getWorld();
    if (event.getHarvester() != null && event.getHarvester().inventory.getCurrentItem() != null) {
        ItemStack stack = event.getHarvester().inventory.getCurrentItem();
        //Silk touch
        int multiply = getEffectStrength(stack, EnumRainbowColor.RED, EnumRainbowColor.YELLOW);
        if (new Random().nextInt(4) < multiply && canMultiplyDrops(event)) {
            ArrayList<ItemStack> newDrops = new ArrayList<ItemStack>(event.getDrops().size());
            for (ItemStack dropStack : event.getDrops()) {
                newDrops.add(getDoubleResult(dropStack));
            }
            event.getDrops().clear();
            event.getDrops().addAll(newDrops);
        } else {
            if (getEffectStrength(stack, EnumRainbowColor.RED) > 0 && block.canSilkHarvest(world, event.getPos(), event.getState(), event.getHarvester())) {
                event.setDropChance(0);
                event.getDrops().clear();
                ItemStack itemstack = createStackedBlock(event.getState());
                if (itemstack != null) {
                    dropBlockAsItem(world, event.getPos(), itemstack);
                }
            } else {

                int fortune = getEffectStrength(stack, EnumRainbowColor.YELLOW, EnumRainbowColor.YELLOW);
                //Crops nullifies the fortune level passed to dropBlockAsItemWithChance
                if (fortune != 0 && event.getFortuneLevel() < fortune && !(event.getState().getBlock() instanceof BlockCrops)) {
                    //Cancels the event and breaks the block again
                    event.setDropChance(0);
                    event.getDrops().clear();
                    event.getState().getBlock().dropBlockAsItemWithChance(event.getWorld(), event.getPos(), event.getState(), 1F, fortune);
                }
            }
        }
    }
}
项目:mcplus_mods    文件:EventHandlerSickle.java   
@SubscribeEvent
public void onBreakSpeed(BreakSpeed parEvent)
{
    if (parEvent.state.getBlock() instanceof BlockCrops)
    {
        ItemStack playerItem = parEvent.entityPlayer.getCurrentEquippedItem();
        if (playerItem != null && playerItem.getItem() == _Sickle.sickle)
        {
            if (!isFullGrownCrop(parEvent.entity.worldObj, parEvent.pos, parEvent.state))
            {
                parEvent.newSpeed = 0F;
            }
        }
    }
}
项目:mcplus_mods    文件:EventHandlerSickle.java   
@SubscribeEvent
public void onBlockBreak(BreakEvent parEvent)
{
    if (parEvent.state.getBlock() instanceof BlockCrops)
    {
        ItemStack playerItem = parEvent.getPlayer().getCurrentEquippedItem();
        if (playerItem != null && playerItem.getItem() == _Sickle.sickle)
        {
            if (!isFullGrownCrop(parEvent.world, parEvent.pos, parEvent.state))
            {
                parEvent.setCanceled(true);
            }
        }
    }
}