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!");
}
}
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);
}
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;
}
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;
}
Aggregations