More specific "Can sustain plants" option for blocks

Status
Migrated
Issue description

The current way it's implemented is a simple toggle, which means either no plants can grow on the block, or any plant can grow on it. Because of it, it's impossible to recreate farmland blocks or make planters for specific plants without coding, as any plant will stay regardless of its type (for example, sugarcane and crops will grow even if there's no water nearby, netherwart is plantable even if the block has nothing to do with soulsand etc.). I suggest that the checkbox is replaced with a list of plant types, similar to the dimensions/biomes ones for ore/plant generation. It would also be fitting, given how 1.9.2 will add the "plant type" option to static plants too. Some code that could be required:

// Gets the plant type of the plant that's going to be on the block
EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

/*
 * Example of how it could be handled
 * It uses a plantTypeCriteria variable, similar to the dimensionCriteria and biomeCriteria ones
 */
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) {
	boolean plantTypeCriteria = false;
	EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
	if (plantType == EnumPlantType.Plains)
		plantTypeCriteria = true;
	// More if statements would be added as the list gets more elements
	return plantTypeCriteria;
}

 

Issue comments