from ..__memory__ import Mem as Mem
from ..constants import official_lib_used as official_lib_used
from ..utils.io import set_json_encoder as set_json_encoder, write_function as write_function
from beet.core.utils import JsonDict as JsonDict

class CustomOreGeneration:
    dimensions: list[str]
    maximum_height: int
    minimum_height: int | None
    veins_per_region: float
    vein_size_logic: float
    provider: str | list[str]
    placer_command: str
    def __init__(self, dimensions: list[str], maximum_height: int = 70, minimum_height: int | None = None, veins_per_region: float = 4, vein_size_logic: float = 0.4, provider: str | list[str] = '#minecraft:overworld_carver_replaceables', placer_command: str = '') -> None:
        ''' Creates a custom ore generation configuration.

\t\tArgs:
\t\t\tdimensions\t\t\t(list[str]):\t\tThe dimensions to generate the ore in (ex: ["minecraft:overworld"])
\t\t\tmaximum_height\t\t(int):\t\t\t\tThe maximum height the ore can generate at
\t\t\tminimum_height\t\t(int|None):\t\t\tThe minimum height the ore can generate at (default: None for bedrock to maximum_height)
\t\t\tveins_per_region\t(float):\t\t\tThe number of veins per region
\t\t\tvein_size_logic\t\t(float):\t\t\tThe logic to calculate the vein size, higher = more ores (0.0 = single block veins, 0.4 = small veins, 1.0 = large veins, etc)
\t\t\tprovider\t\t\t(str|list[str]):\tThe block or block tag to check for the ore to generate (default is same as vanilla ores in overworld), can be either a string or a list of strings
\t\t\tplacer_command\t\t(str):\t\t\t\tThe placer command to use for the ore generation, usually a function to place the custom ore but can be anything, default is autogenerated
\t\t'''
    def check_validity(self) -> None:
        """ Check if the custom ore generation configuration is valid """
    def generate_files(self, custom_ore: str, number: int | None = None) -> None:
        ''' Generate the files for the custom ore generation.

\t\tArgs:
\t\t\tcustom_ore (str):\tThe custom ore to generate, ex: "adamantium_ore"
\t\t\tnumber (int|None):\t(optional) The number of the custom ore to generate, ex: 1 for "adamantium_ore_1", used when having multiple configurations for the same ore
\t\t'''
    def _setup_placer_command(self, custom_ore: str) -> None:
        """ Setup the placer command for the ore generation.

\t\tArgs:
\t\t\tcustom_ore (str):\tThe custom ore to generate
\t\t"""
    def _generate_main_function(self, beautify_ore: str, vein_path: str) -> None:
        """ Generate the main ore generation function.

\t\tArgs:
\t\t\tbeautify_ore (str):\tThe beautified ore name
\t\t\tvein_path (str):\tThe path to the vein function
\t\t"""
    def _generate_vein_function(self, beautify_ore: str, vein_path: str) -> None:
        """ Generate the vein function for ore generation.

\t\tArgs:
\t\t\tbeautify_ore (str):\tThe beautified ore name
\t\t\tvein_path (str):\tThe path to the vein function
\t\t"""
    @staticmethod
    def all_with_config(ore_configs: dict[str, list[CustomOreGeneration]]) -> None:
        ''' Generate all custom ore generation files with the configurations provided

\t\tArgs:
\t\t\tore_configs (dict[str, list[CustomOreGeneration]]):\tThe custom ore generation configurations, ex:

\t\t```py
\t\t{
\t\t\t"super_iron_ore": [
\t\t\t\tCustomOreGeneration(
\t\t\t\t\tdimensions = ["minecraft:overworld","stardust:cavern","some_other:dimension"],
\t\t\t\t\tmaximum_height = 50,
\t\t\t\t\tminimum_height = 0,
\t\t\t\t\tveins_per_region = 2,
\t\t\t\t\tvein_size_logic = 0.4,
\t\t\t\t)
\t\t\t],
\t\t\t"deepslate_super_iron_ore": [
\t\t\t\tCustomOreGeneration(
\t\t\t\t\tdimensions = ["minecraft:overworld"],
\t\t\t\t\tmaximum_height = 0,
\t\t\t\t\tveins_per_region = 2,
\t\t\t\t\tvein_size_logic = 0.4,
\t\t\t\t),
\t\t\t\tCustomOreGeneration(
\t\t\t\t\tdimensions = ["stardust:cavern"],
\t\t\t\t\tmaximum_height = 0,
\t\t\t\t\tveins_per_region = 8,
\t\t\t\t\tvein_size_logic = 0.8,
\t\t\t\t)
\t\t\t], ...
\t\t}
\t\t```
\t\t'''
