Search in sources :

Example 1 with EnumPlantType

use of net.minecraftforge.common.EnumPlantType in project MinecraftForge by MinecraftForge.

the class EnumPlantTypeTest method onInit.

@Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
    BiomeType biomeType = null;
    try {
        biomeType = BiomeType.getType("FAKE");
    } catch (NullPointerException npe) {
        LOGGER.warn("EnumHelper in BiomeType is working incorrectly!", npe);
    } finally {
        if (biomeType == null || !biomeType.name().equals("FAKE"))
            LOGGER.warn("EnumHelper in BiomeType is working incorrectly!");
    }
    EnumPlantType plantType = null;
    if (plantType == null || !plantType.name().equals("FAKE"))
        ;
    try {
        plantType = EnumPlantType.getPlantType("FAKE");
    } catch (NullPointerException npe) {
        LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!", npe);
    } finally {
        if (plantType == null || !plantType.name().equals("FAKE"))
            LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!");
    }
}
Also used : BiomeType(net.minecraftforge.common.BiomeManager.BiomeType) EnumPlantType(net.minecraftforge.common.EnumPlantType)

Example 2 with EnumPlantType

use of net.minecraftforge.common.EnumPlantType in project ConvenientAdditions by Necr0.

the class BlockCompostSoilTilled method canSustainPlant.

@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side, IPlantable plantable) {
    BlockPos plantPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
    EnumPlantType plantType = plantable.getPlantType(world, plantPos);
    return plantType == EnumPlantType.Crop || ModBlocks.compostSoilBlock.canSustainPlant(state, world, pos, side, plantable);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EnumPlantType(net.minecraftforge.common.EnumPlantType)

Example 3 with EnumPlantType

use of net.minecraftforge.common.EnumPlantType in project ConvenientAdditions by Necr0.

the class BlockCompostSoil method canSustainPlant.

@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side, IPlantable plantable) {
    BlockPos plantPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
    EnumPlantType plantType = plantable.getPlantType(world, plantPos);
    if (plantable instanceof BlockBush)
        return true;
    switch(plantType) {
        case Desert:
            return false;
        case Nether:
            return false;
        case Crop:
            return false;
        case Cave:
            return true;
        case Plains:
            return true;
        case Water:
            return false;
        case Beach:
            boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER || world.getBlockState(pos.west()).getMaterial() == Material.WATER || world.getBlockState(pos.north()).getMaterial() == Material.WATER || world.getBlockState(pos.south()).getMaterial() == Material.WATER);
            return hasWater;
    }
    return false;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EnumPlantType(net.minecraftforge.common.EnumPlantType)

Example 4 with EnumPlantType

use of net.minecraftforge.common.EnumPlantType in project EnderIO by SleepyTrousers.

the class PlantableFarmer method prepareBlock.

@Override
public boolean prepareBlock(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull Block block, @Nonnull IBlockState meta) {
    ItemStack seedStack = farm.getSeedTypeInSuppliesFor(bc);
    if (Prep.isInvalid(seedStack)) {
        if (!farm.isSlotLocked(bc)) {
            farm.setNotification(FarmNotification.NO_SEEDS);
        }
        return false;
    }
    if (!(seedStack.getItem() instanceof IPlantable)) {
        return false;
    }
    IPlantable plantable = (IPlantable) seedStack.getItem();
    EnumPlantType type = plantable.getPlantType(farm.getWorld(), bc);
    if (type == null) {
        return false;
    }
    if (type == EnumPlantType.Nether) {
        Block ground = farm.getBlockState(bc.down()).getBlock();
        if (ground != Blocks.SOUL_SAND) {
            return false;
        }
        return plantFromInventory(farm, bc, plantable);
    }
    if (type == EnumPlantType.Crop) {
        farm.tillBlock(bc);
        return plantFromInventory(farm, bc, plantable);
    }
    if (type == EnumPlantType.Water) {
        return plantFromInventory(farm, bc, plantable);
    }
    return false;
}
Also used : IPlantable(net.minecraftforge.common.IPlantable) Block(net.minecraft.block.Block) EnumPlantType(net.minecraftforge.common.EnumPlantType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumPlantType (net.minecraftforge.common.EnumPlantType)4 BlockPos (net.minecraft.util.math.BlockPos)2 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 BiomeType (net.minecraftforge.common.BiomeManager.BiomeType)1 IPlantable (net.minecraftforge.common.IPlantable)1