Add biome modifier to remove managed spawns
* add formatters for biome modifiers * streamline building writers in the runner
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
from mcpacker.json import JsonBlob
|
||||
|
||||
|
||||
# Classes ##########################################################################################
|
||||
|
||||
class BiomeModifier:
|
||||
|
||||
def asJsonBlob(self) -> JsonBlob:
|
||||
return {
|
||||
"type": "neoforge:none",
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
from collections.abc import Iterable
|
||||
from mcpacker.format.datapack.biomemodifier import BiomeModifier
|
||||
from mcpacker.format.datapack.biomemodifier.generationstep import GenerationStep
|
||||
from mcpacker.json import JsonBlob
|
||||
|
||||
|
||||
# Class ############################################################################################
|
||||
|
||||
class AddFeatureBiomeModifier(BiomeModifier):
|
||||
|
||||
def __init__(self, biomes:Iterable[str]|str, features:Iterable[str]|str, step:GenerationStep):
|
||||
if isinstance(biomes, str):
|
||||
biomes = [biomes]
|
||||
|
||||
if isinstance(features, str):
|
||||
features = [features]
|
||||
|
||||
self.biomes = biomes
|
||||
self.features = features
|
||||
self.step = step
|
||||
|
||||
def asJsobBlob(self) -> JsonBlob:
|
||||
return {
|
||||
"type": "neoforge:add_features",
|
||||
"biomes": list(self.biomes),
|
||||
"features": list(self.features),
|
||||
"step": str(self.step),
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
# Class ############################################################################################
|
||||
|
||||
class GenerationStep:
|
||||
|
||||
def __init__(self, gameId:str):
|
||||
self.gameId = gameId
|
||||
|
||||
def __eq__(self, other:Any) -> bool:
|
||||
if type(self) != type(other): return False
|
||||
if self.gameId != other.gameId: return False
|
||||
return True
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.gameId)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"GenerationStep(gameId={repr(self.gameId)})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.gameId
|
||||
|
||||
|
||||
# Constants ########################################################################################
|
||||
|
||||
RAW_GENERATION = GenerationStep("raw_generation")
|
||||
LAKES = GenerationStep("lakes")
|
||||
LOCAL_MODIFICATIONS = GenerationStep("local_modifications")
|
||||
UNDERGROUND_STRUCTURES = GenerationStep("underground_structures")
|
||||
SURFACE_STRUCTURES = GenerationStep("surface_structures")
|
||||
STRONGHOLDS = GenerationStep("strongholds")
|
||||
UNDERGROUND_ORES = GenerationStep("underground_ores")
|
||||
UNDERGROUND_DECORATION = GenerationStep("underground_decoration")
|
||||
FLUID_SPRINGS = GenerationStep("fluid_springs")
|
||||
VEGETAL_DECORATION = GenerationStep("vegetal_decoration")
|
||||
TOP_LAYER_MODIFICATION = GenerationStep("top_layer_modification")
|
||||
|
||||
ALL = [
|
||||
RAW_GENERATION,
|
||||
LAKES,
|
||||
LOCAL_MODIFICATIONS,
|
||||
UNDERGROUND_STRUCTURES,
|
||||
SURFACE_STRUCTURES,
|
||||
STRONGHOLDS,
|
||||
UNDERGROUND_ORES,
|
||||
UNDERGROUND_DECORATION,
|
||||
FLUID_SPRINGS,
|
||||
VEGETAL_DECORATION,
|
||||
TOP_LAYER_MODIFICATION,
|
||||
]
|
||||
@@ -0,0 +1,37 @@
|
||||
from collections.abc import Iterable
|
||||
from mcpacker.format.datapack.biomemodifier import BiomeModifier
|
||||
from mcpacker.format.datapack.biomemodifier.generationstep import GenerationStep
|
||||
from mcpacker.json import JsonBlob
|
||||
|
||||
|
||||
# Classes ##########################################################################################
|
||||
|
||||
class RemoveFeatureBiomeModifier(BiomeModifier):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
biomes:Iterable[str]|str,
|
||||
features:Iterable[str]|str,
|
||||
step:GenerationStep|None=None
|
||||
):
|
||||
if isinstance(biomes, str):
|
||||
biomes = [biomes]
|
||||
|
||||
if isinstance(features, str):
|
||||
features = [features]
|
||||
|
||||
self.biomes = biomes
|
||||
self.features = features
|
||||
self.step = step
|
||||
|
||||
def asJsobBlob(self) -> JsonBlob:
|
||||
result:dict[str,JsonBlob] = {
|
||||
"type": "neoforge:remove_features",
|
||||
"biomes": list(self.biomes),
|
||||
"features": list(self.features),
|
||||
}
|
||||
|
||||
if self.step:
|
||||
result["step"] = str(self.step)
|
||||
|
||||
return result
|
||||
@@ -0,0 +1,22 @@
|
||||
from collections.abc import Iterable
|
||||
from mcpacker.format.datapack.biomemodifier import BiomeModifier
|
||||
from mcpacker.json import JsonBlob
|
||||
|
||||
|
||||
# Classes ##########################################################################################
|
||||
|
||||
class RemoveSpawnBiomeModifier(BiomeModifier):
|
||||
|
||||
def __init__(self, biomes:Iterable[str]|str, entityTypes:Iterable[str]):
|
||||
if isinstance(biomes, str):
|
||||
biomes = [biomes]
|
||||
|
||||
self.biomes = biomes
|
||||
self.entityTypes = entityTypes
|
||||
|
||||
def asJsonBlob(self) -> JsonBlob:
|
||||
return {
|
||||
"type": "neoforge:remove_spawns",
|
||||
"biomes": list(self.biomes),
|
||||
"entity_types": list(self.entityTypes),
|
||||
}
|
||||
Reference in New Issue
Block a user