Example usage for net.minecraftforge.common IPlantable getPlantType

List of usage examples for net.minecraftforge.common IPlantable getPlantType

Introduction

In this page you can find the example usage for net.minecraftforge.common IPlantable getPlantType.

Prototype

default PlantType getPlantType(IBlockReader world, BlockPos pos) 

Source Link

Usage

From source file:com.robrit.snad.common.block.BlockSnad.java

License:Open Source License

@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction,
        net.minecraftforge.common.IPlantable plantable) {
    BlockPos plantPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
    Block plant = plantable.getPlant(world, plantPos).getBlock();
    EnumPlantType plantType = plantable.getPlantType(world, plantPos);

    switch (plantType) {
    case Desert: {
        return true;
    }/*from w  w  w. ja va 2  s.  c  o m*/
    case Water: {
        return world.getBlockState(pos).getBlock().getMaterial(world.getBlockState(pos)) == Material.WATER
                && world.getBlockState(pos) == getDefaultState();
    }
    case Beach: {
        return (world.getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())).getBlock()
                .getMaterial(world
                        .getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()))) == Material.WATER
                || world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())).getBlock()
                        .getMaterial(world.getBlockState(
                                new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()))) == Material.WATER
                || world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)).getBlock()
                        .getMaterial(world.getBlockState(
                                new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()))) == Material.WATER
                || world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)).getBlock()
                        .getMaterial(world.getBlockState(
                                new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()))) == Material.WATER);
    }
    }

    return false;
}

From source file:vazkii.quark.tweaks.feature.HoeSickle.java

License:Creative Commons License

private boolean canHarvest(World world, BlockPos pos, IBlockState state) {
    Block block = state.getBlock();//from www.j  a  va2 s  . c  om
    if (block instanceof IPlantable) {
        IPlantable plant = (IPlantable) block;
        EnumPlantType type = plant.getPlantType(world, pos);
        return type != EnumPlantType.Water && type != EnumPlantType.Desert;
    }

    return false;
}