diff --git a/mcpacker/format/datapack/__init__.py b/mcpacker/format/datapack/__init__.py index e69de29..96905cc 100644 --- a/mcpacker/format/datapack/__init__.py +++ b/mcpacker/format/datapack/__init__.py @@ -0,0 +1,49 @@ +from collections.abc import Iterable +from mcpacker.format.datapack.moddata import ModData + + +# Class ############################################################################################ + +class DataPack: + """ + A collection of data used to configure a Minecraft instance. + + see: https://minecraft.wiki/w/Data_pack + """ + + def __init__(self, name:str, mods:Iterable[ModData]|None=None): + self.name = name + self._mods:dict[str,ModData] = {} + self._defaultMod:ModData|None = None + + for mod in (mods or []): + self.add(mod) + + def add(self, mod:ModData) -> "DataPack": + if not self._defaultMod: + self._defaultMod = mod + + self._mods[mod.name] = mod + return self + + def get(self, name:str) -> ModData: + result = self._mods.get(name, None) + if not result: + result = self._mods[name] = ModData(name) + + return result + + @property + def defaultMod(self) -> ModData|None: + return self._defaultMod + + @defaultMod.setter + def defaultMod(self, mod:ModData): + if mod: + existingModData = self.get(mod.name) + if not existingModData: + self.add(mod) + elif existingModData != mod: + raise Exception(f"Datapack already has a mod named {mod.name}") + + self._defaultMod = mod diff --git a/mcpacker/model/datapack/__init___test.py b/mcpacker/format/datapack/__init___test.py similarity index 80% rename from mcpacker/model/datapack/__init___test.py rename to mcpacker/format/datapack/__init___test.py index 1e64bad..8aff80e 100644 --- a/mcpacker/model/datapack/__init___test.py +++ b/mcpacker/format/datapack/__init___test.py @@ -1,4 +1,4 @@ -import mcpacker.model.datapack +import mcpacker.format.datapack # Tests ############################################################################################ diff --git a/mcpacker/model/datapack/blockstate.py b/mcpacker/format/datapack/blockstate.py similarity index 100% rename from mcpacker/model/datapack/blockstate.py rename to mcpacker/format/datapack/blockstate.py diff --git a/mcpacker/model/datapack/blockstate_test.py b/mcpacker/format/datapack/blockstate_test.py similarity index 89% rename from mcpacker/model/datapack/blockstate_test.py rename to mcpacker/format/datapack/blockstate_test.py index 5ceb314..582c72e 100644 --- a/mcpacker/model/datapack/blockstate_test.py +++ b/mcpacker/format/datapack/blockstate_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.blockstate import BlockState +from mcpacker.format.datapack.blockstate import BlockState from pytest import fixture diff --git a/mcpacker/model/datapack/blockstateprovider/__init__.py b/mcpacker/format/datapack/blockstateprovider/__init__.py similarity index 100% rename from mcpacker/model/datapack/blockstateprovider/__init__.py rename to mcpacker/format/datapack/blockstateprovider/__init__.py diff --git a/mcpacker/model/datapack/blockstateprovider/simplestateprovider.py b/mcpacker/format/datapack/blockstateprovider/simplestateprovider.py similarity index 79% rename from mcpacker/model/datapack/blockstateprovider/simplestateprovider.py rename to mcpacker/format/datapack/blockstateprovider/simplestateprovider.py index 0d9398e..2f3eedd 100644 --- a/mcpacker/model/datapack/blockstateprovider/simplestateprovider.py +++ b/mcpacker/format/datapack/blockstateprovider/simplestateprovider.py @@ -1,6 +1,6 @@ from mcpacker.json import JsonBlob -from mcpacker.model.datapack.blockstate import BlockState -from mcpacker.model.datapack.blockstateprovider import BlockStateProvider +from mcpacker.format.datapack.blockstate import BlockState +from mcpacker.format.datapack.blockstateprovider import BlockStateProvider from typing import Any diff --git a/mcpacker/model/datapack/blockstateprovider/simplestateprovider_test.py b/mcpacker/format/datapack/blockstateprovider/simplestateprovider_test.py similarity index 82% rename from mcpacker/model/datapack/blockstateprovider/simplestateprovider_test.py rename to mcpacker/format/datapack/blockstateprovider/simplestateprovider_test.py index bc1fa6a..f4b0658 100644 --- a/mcpacker/model/datapack/blockstateprovider/simplestateprovider_test.py +++ b/mcpacker/format/datapack/blockstateprovider/simplestateprovider_test.py @@ -1,5 +1,5 @@ -from mcpacker.model.datapack.blockstate import BlockState -from mcpacker.model.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider +from mcpacker.format.datapack.blockstate import BlockState +from mcpacker.format.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider from pytest import fixture diff --git a/mcpacker/model/datapack/configuredfeature/__init__.py b/mcpacker/format/datapack/configuredfeature/__init__.py similarity index 100% rename from mcpacker/model/datapack/configuredfeature/__init__.py rename to mcpacker/format/datapack/configuredfeature/__init__.py diff --git a/mcpacker/model/datapack/configuredfeature/randompatch.py b/mcpacker/format/datapack/configuredfeature/randompatch.py similarity index 85% rename from mcpacker/model/datapack/configuredfeature/randompatch.py rename to mcpacker/format/datapack/configuredfeature/randompatch.py index 7368d7a..aa56778 100644 --- a/mcpacker/model/datapack/configuredfeature/randompatch.py +++ b/mcpacker/format/datapack/configuredfeature/randompatch.py @@ -1,9 +1,9 @@ -from mcpacker.model.datapack.configuredfeature import ConfiguredFeature +from mcpacker.format.datapack.configuredfeature import ConfiguredFeature from typing import Any from typing import TYPE_CHECKING if TYPE_CHECKING: - from mcpacker.model.datapack.placedfeature import PlacedFeature + from mcpacker.format.datapack.placedfeature import PlacedFeature # Class ############################################################################################ diff --git a/mcpacker/model/datapack/configuredfeature/randompatch_test.py b/mcpacker/format/datapack/configuredfeature/randompatch_test.py similarity index 81% rename from mcpacker/model/datapack/configuredfeature/randompatch_test.py rename to mcpacker/format/datapack/configuredfeature/randompatch_test.py index 9cd6a02..cbdbab2 100644 --- a/mcpacker/model/datapack/configuredfeature/randompatch_test.py +++ b/mcpacker/format/datapack/configuredfeature/randompatch_test.py @@ -1,6 +1,6 @@ -from mcpacker.model.datapack.blockstate import BlockState -from mcpacker.model.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider -from mcpacker.model.datapack.configuredfeature.simpleblock import SimpleBlock +from mcpacker.format.datapack.blockstate import BlockState +from mcpacker.format.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider +from mcpacker.format.datapack.configuredfeature.simpleblock import SimpleBlock from pytest import fixture diff --git a/mcpacker/model/datapack/configuredfeature/simpleblock.py b/mcpacker/format/datapack/configuredfeature/simpleblock.py similarity index 79% rename from mcpacker/model/datapack/configuredfeature/simpleblock.py rename to mcpacker/format/datapack/configuredfeature/simpleblock.py index 5ee4567..c89207e 100644 --- a/mcpacker/model/datapack/configuredfeature/simpleblock.py +++ b/mcpacker/format/datapack/configuredfeature/simpleblock.py @@ -1,6 +1,6 @@ from mcpacker.json import JsonBlob -from mcpacker.model.datapack.blockstateprovider import BlockStateProvider -from mcpacker.model.datapack.configuredfeature import ConfiguredFeature +from mcpacker.format.datapack.blockstateprovider import BlockStateProvider +from mcpacker.format.datapack.configuredfeature import ConfiguredFeature from typing import Any diff --git a/mcpacker/model/datapack/configuredfeature/simpleblock_test.py b/mcpacker/format/datapack/configuredfeature/simpleblock_test.py similarity index 81% rename from mcpacker/model/datapack/configuredfeature/simpleblock_test.py rename to mcpacker/format/datapack/configuredfeature/simpleblock_test.py index 9cd6a02..cbdbab2 100644 --- a/mcpacker/model/datapack/configuredfeature/simpleblock_test.py +++ b/mcpacker/format/datapack/configuredfeature/simpleblock_test.py @@ -1,6 +1,6 @@ -from mcpacker.model.datapack.blockstate import BlockState -from mcpacker.model.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider -from mcpacker.model.datapack.configuredfeature.simpleblock import SimpleBlock +from mcpacker.format.datapack.blockstate import BlockState +from mcpacker.format.datapack.blockstateprovider.simplestateprovider import SimpleStateProvider +from mcpacker.format.datapack.configuredfeature.simpleblock import SimpleBlock from pytest import fixture diff --git a/mcpacker/model/datapack/heightmaptype.py b/mcpacker/format/datapack/heightmaptype.py similarity index 100% rename from mcpacker/model/datapack/heightmaptype.py rename to mcpacker/format/datapack/heightmaptype.py diff --git a/mcpacker/model/datapack/heightmaptype_test.py b/mcpacker/format/datapack/heightmaptype_test.py similarity index 67% rename from mcpacker/model/datapack/heightmaptype_test.py rename to mcpacker/format/datapack/heightmaptype_test.py index fd72efc..bbc5fa5 100644 --- a/mcpacker/model/datapack/heightmaptype_test.py +++ b/mcpacker/format/datapack/heightmaptype_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.heightmaptype import HeightMapType +from mcpacker.format.datapack.heightmaptype import HeightMapType # Tests ############################################################################################ diff --git a/mcpacker/model/datapack/moddata.py b/mcpacker/format/datapack/moddata.py similarity index 83% rename from mcpacker/model/datapack/moddata.py rename to mcpacker/format/datapack/moddata.py index ae2d389..c6ee870 100644 --- a/mcpacker/model/datapack/moddata.py +++ b/mcpacker/format/datapack/moddata.py @@ -1,5 +1,5 @@ -from mcpacker.model.datapack.configuredfeature import ConfiguredFeature -from mcpacker.model.datapack.placedfeature import PlacedFeature +from mcpacker.format.datapack.configuredfeature import ConfiguredFeature +from mcpacker.format.datapack.placedfeature import PlacedFeature from typing import Any diff --git a/mcpacker/model/datapack/moddata_test.py b/mcpacker/format/datapack/moddata_test.py similarity index 76% rename from mcpacker/model/datapack/moddata_test.py rename to mcpacker/format/datapack/moddata_test.py index e7d5821..261548f 100644 --- a/mcpacker/model/datapack/moddata_test.py +++ b/mcpacker/format/datapack/moddata_test.py @@ -1,4 +1,4 @@ -import mcpacker.model.datapack.moddata +import mcpacker.format.datapack.moddata # Tests ############################################################################################ diff --git a/mcpacker/model/datapack/placedfeature.py b/mcpacker/format/datapack/placedfeature.py similarity index 81% rename from mcpacker/model/datapack/placedfeature.py rename to mcpacker/format/datapack/placedfeature.py index a81836e..7734529 100644 --- a/mcpacker/model/datapack/placedfeature.py +++ b/mcpacker/format/datapack/placedfeature.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement import Placement +from mcpacker.format.datapack.placement import Placement # Class ############################################################################################ diff --git a/mcpacker/model/datapack/placedfeature_test.py b/mcpacker/format/datapack/placedfeature_test.py similarity index 67% rename from mcpacker/model/datapack/placedfeature_test.py rename to mcpacker/format/datapack/placedfeature_test.py index d9b4542..ce079bd 100644 --- a/mcpacker/model/datapack/placedfeature_test.py +++ b/mcpacker/format/datapack/placedfeature_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placedfeature import PlacedFeature +from mcpacker.format.datapack.placedfeature import PlacedFeature # Tests ############################################################################################ diff --git a/mcpacker/model/datapack/placement/__init__.py b/mcpacker/format/datapack/placement/__init__.py similarity index 100% rename from mcpacker/model/datapack/placement/__init__.py rename to mcpacker/format/datapack/placement/__init__.py diff --git a/mcpacker/model/datapack/placement/biome.py b/mcpacker/format/datapack/placement/biome.py similarity index 83% rename from mcpacker/model/datapack/placement/biome.py rename to mcpacker/format/datapack/placement/biome.py index cf0f727..85e037a 100644 --- a/mcpacker/model/datapack/placement/biome.py +++ b/mcpacker/format/datapack/placement/biome.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement import Placement +from mcpacker.format.datapack.placement import Placement from typing import Any # Class ############################################################################################ diff --git a/mcpacker/model/datapack/placement/biome_test.py b/mcpacker/format/datapack/placement/biome_test.py similarity index 87% rename from mcpacker/model/datapack/placement/biome_test.py rename to mcpacker/format/datapack/placement/biome_test.py index db26ea0..cd40f4b 100644 --- a/mcpacker/model/datapack/placement/biome_test.py +++ b/mcpacker/format/datapack/placement/biome_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement.biome import Biome +from mcpacker.format.datapack.placement.biome import Biome from pytest import fixture diff --git a/mcpacker/model/datapack/placement/heightmap.py b/mcpacker/format/datapack/placement/heightmap.py similarity index 78% rename from mcpacker/model/datapack/placement/heightmap.py rename to mcpacker/format/datapack/placement/heightmap.py index 2514931..b4faea4 100644 --- a/mcpacker/model/datapack/placement/heightmap.py +++ b/mcpacker/format/datapack/placement/heightmap.py @@ -1,5 +1,5 @@ -from mcpacker.model.datapack.heightmaptype import HeightMapType -from mcpacker.model.datapack.placement import Placement +from mcpacker.format.datapack.heightmaptype import HeightMapType +from mcpacker.format.datapack.placement import Placement from typing import Any # Class ############################################################################################ diff --git a/mcpacker/model/datapack/placement/heightmap_test.py b/mcpacker/format/datapack/placement/heightmap_test.py similarity index 77% rename from mcpacker/model/datapack/placement/heightmap_test.py rename to mcpacker/format/datapack/placement/heightmap_test.py index 1d3fb04..93cfd22 100644 --- a/mcpacker/model/datapack/placement/heightmap_test.py +++ b/mcpacker/format/datapack/placement/heightmap_test.py @@ -1,5 +1,5 @@ -from mcpacker.model.datapack.heightmaptype import WORLD_SURFACE -from mcpacker.model.datapack.placement.heightmap import HeightMap +from mcpacker.format.datapack.heightmaptype import WORLD_SURFACE +from mcpacker.format.datapack.placement.heightmap import HeightMap from pytest import fixture diff --git a/mcpacker/model/datapack/placement/insquare.py b/mcpacker/format/datapack/placement/insquare.py similarity index 84% rename from mcpacker/model/datapack/placement/insquare.py rename to mcpacker/format/datapack/placement/insquare.py index 0e16b99..6e1d49e 100644 --- a/mcpacker/model/datapack/placement/insquare.py +++ b/mcpacker/format/datapack/placement/insquare.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement import Placement +from mcpacker.format.datapack.placement import Placement from typing import Any # Class ############################################################################################ diff --git a/mcpacker/model/datapack/placement/insquare_test.py b/mcpacker/format/datapack/placement/insquare_test.py similarity index 86% rename from mcpacker/model/datapack/placement/insquare_test.py rename to mcpacker/format/datapack/placement/insquare_test.py index d11b769..d02e83c 100644 --- a/mcpacker/model/datapack/placement/insquare_test.py +++ b/mcpacker/format/datapack/placement/insquare_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement.insquare import InSquare +from mcpacker.format.datapack.placement.insquare import InSquare from pytest import fixture diff --git a/mcpacker/model/datapack/placement/rarityfilter.py b/mcpacker/format/datapack/placement/rarityfilter.py similarity index 87% rename from mcpacker/model/datapack/placement/rarityfilter.py rename to mcpacker/format/datapack/placement/rarityfilter.py index c34f349..0d0ace2 100644 --- a/mcpacker/model/datapack/placement/rarityfilter.py +++ b/mcpacker/format/datapack/placement/rarityfilter.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement import Placement +from mcpacker.format.datapack.placement import Placement from typing import Any # Class ############################################################################################ diff --git a/mcpacker/model/datapack/placement/rarityfilter_test.py b/mcpacker/format/datapack/placement/rarityfilter_test.py similarity index 85% rename from mcpacker/model/datapack/placement/rarityfilter_test.py rename to mcpacker/format/datapack/placement/rarityfilter_test.py index c73aeae..21122a4 100644 --- a/mcpacker/model/datapack/placement/rarityfilter_test.py +++ b/mcpacker/format/datapack/placement/rarityfilter_test.py @@ -1,4 +1,4 @@ -from mcpacker.model.datapack.placement.rarityfilter import RarityFilter +from mcpacker.format.datapack.placement.rarityfilter import RarityFilter from pytest import fixture diff --git a/mcpacker/model/datapack/recipe/__init__.py b/mcpacker/format/datapack/recipe/__init__.py similarity index 100% rename from mcpacker/model/datapack/recipe/__init__.py rename to mcpacker/format/datapack/recipe/__init__.py diff --git a/mcpacker/model/datapack/recipe/shapedrecipe.py b/mcpacker/format/datapack/recipe/shapedrecipe.py similarity index 97% rename from mcpacker/model/datapack/recipe/shapedrecipe.py rename to mcpacker/format/datapack/recipe/shapedrecipe.py index 0608b7a..815ffd9 100644 --- a/mcpacker/model/datapack/recipe/shapedrecipe.py +++ b/mcpacker/format/datapack/recipe/shapedrecipe.py @@ -1,6 +1,6 @@ from collections.abc import Iterable from collections.abc import Mapping -from mcpacker.model.datapack.recipe import Recipe +from mcpacker.format.datapack.recipe import Recipe from mcpacker.model.core.resourceid import ResourceId diff --git a/mcpacker/model/datapack/recipe/shapedrecipe_test.py b/mcpacker/format/datapack/recipe/shapedrecipe_test.py similarity index 91% rename from mcpacker/model/datapack/recipe/shapedrecipe_test.py rename to mcpacker/format/datapack/recipe/shapedrecipe_test.py index 7821442..79663c8 100644 --- a/mcpacker/model/datapack/recipe/shapedrecipe_test.py +++ b/mcpacker/format/datapack/recipe/shapedrecipe_test.py @@ -1,5 +1,5 @@ from pytest import fixture -from mcpacker.model.datapack.recipe.shapedrecipe import ShapedRecipe +from mcpacker.format.datapack.recipe.shapedrecipe import ShapedRecipe # Fixtures ######################################################################################### diff --git a/mcpacker/model/datapack/recipe/shapelessrecipe.py b/mcpacker/format/datapack/recipe/shapelessrecipe.py similarity index 94% rename from mcpacker/model/datapack/recipe/shapelessrecipe.py rename to mcpacker/format/datapack/recipe/shapelessrecipe.py index de9eff0..97ba33a 100644 --- a/mcpacker/model/datapack/recipe/shapelessrecipe.py +++ b/mcpacker/format/datapack/recipe/shapelessrecipe.py @@ -1,7 +1,7 @@ from collections.abc import Iterable from collections.abc import Mapping from mcpacker.model.core.resourceid import ResourceId -from mcpacker.model.datapack.recipe import Recipe +from mcpacker.format.datapack.recipe import Recipe # Class ############################################################################################ diff --git a/mcpacker/model/datapack/recipe/shapelessrecipe_test.py b/mcpacker/format/datapack/recipe/shapelessrecipe_test.py similarity index 88% rename from mcpacker/model/datapack/recipe/shapelessrecipe_test.py rename to mcpacker/format/datapack/recipe/shapelessrecipe_test.py index 9b8e08d..4f10042 100644 --- a/mcpacker/model/datapack/recipe/shapelessrecipe_test.py +++ b/mcpacker/format/datapack/recipe/shapelessrecipe_test.py @@ -1,5 +1,5 @@ from pytest import fixture -from mcpacker.model.datapack.recipe.shapelessrecipe import ShapelessRecipe +from mcpacker.format.datapack.recipe.shapelessrecipe import ShapelessRecipe # Fixtures ######################################################################################### diff --git a/mcpacker/model/blockfactory.py b/mcpacker/model/blockfactory.py index 1a1633a..f011310 100644 --- a/mcpacker/model/blockfactory.py +++ b/mcpacker/model/blockfactory.py @@ -3,7 +3,7 @@ from mcpacker.model.resourcepack.variant import Variant from mcpacker.model.resourcepack.model import Model from mcpacker.model.modpack import ModPack from mcpacker.model.core.resourceid import ResourceId -from mcpacker.model.datapack.recipe.shapedrecipe import ShapedRecipe +from mcpacker.format.datapack.recipe.shapedrecipe import ShapedRecipe # Class ############################################################################################ diff --git a/mcpacker/model/datapack/__init__.py b/mcpacker/model/datapack/__init__.py deleted file mode 100644 index 07f72c1..0000000 --- a/mcpacker/model/datapack/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -from collections.abc import Iterable -from mcpacker.model.datapack.moddata import ModData - - -# Class ############################################################################################ - -class DataPack: - """ - A collection of data used to configure a Minecraft instance. - - see: https://minecraft.wiki/w/Data_pack - """ - - def __init__(self, name:str, mods:Iterable[ModData]|None=None): - self.name = name - self._mods:dict[str,ModData] = {} - self._defaultMod:ModData|None = None - - for mod in (mods or []): - self.add(mod) - - def add(self, mod:ModData) -> "DataPack": - if not self._defaultMod: - self._defaultMod = mod - - self._mods[mod.name] = mod - return self - - def get(self, name:str) -> ModData: - result = self._mods.get(name, None) - if not result: - result = self._mods[name] = ModData(name) - - return result - - @property - def defaultMod(self) -> ModData|None: - return self._defaultMod - - @defaultMod.setter - def defaultMod(self, mod:ModData): - if mod: - existingModData = self.get(mod.name) - if not existingModData: - self.add(mod) - elif existingModData != mod: - raise Exception(f"Datapack already has a mod named {mod.name}") - - self._defaultMod = mod diff --git a/mcpacker/model/modpack.py b/mcpacker/model/modpack.py index 77d9c90..4cc0ba1 100644 --- a/mcpacker/model/modpack.py +++ b/mcpacker/model/modpack.py @@ -1,6 +1,6 @@ from collections.abc import Iterable from mcpacker.model.core.world import World -from mcpacker.model.datapack import DataPack +from mcpacker.format.datapack import DataPack from mcpacker.model.mod import Mod from mcpacker.model.resourcepack import ResourcePack from typing import Callable diff --git a/mcpacker/pack/mysteriousisland/adddatapack.py b/mcpacker/pack/mysteriousisland/adddatapack.py index afcbf6c..afeaf89 100644 --- a/mcpacker/pack/mysteriousisland/adddatapack.py +++ b/mcpacker/pack/mysteriousisland/adddatapack.py @@ -1,5 +1,5 @@ from mcpacker.model.modpack import ModPack -from mcpacker.model.datapack import DataPack +from mcpacker.format.datapack import DataPack # Functions ########################################################################################