Add the ability to specify companion plants

- add full list of disabled plant placed features
This commit is contained in:
Andrew Miner
2025-10-21 10:12:46 -06:00
parent 0a7fe05c4f
commit 3a62225c9e
4 changed files with 88 additions and 3 deletions
+10
View File
@@ -0,0 +1,10 @@
from mcpacker.model.core.flora.plant import Plant
# Class ############################################################################################
class Companion:
def __init__(self, plant:Plant, weight:int):
self.plant = plant
self.weight = weight
@@ -0,0 +1,7 @@
import mcpacker.model.core.flora.companion
# Tests ############################################################################################
def test_syntax():
pass
+12 -2
View File
@@ -1,5 +1,6 @@
from collections.abc import Iterable from collections.abc import Iterable
from mcpacker.model.core.blockstate import BlockState from mcpacker.model.core.blockstate import BlockState
from mcpacker.model.core.flora.companion import Companion
from mcpacker.model.core.flora.density import Density from mcpacker.model.core.flora.density import Density
from mcpacker.model.core.flora.immersion import Immersion from mcpacker.model.core.flora.immersion import Immersion
from mcpacker.model.core.flora.plant import Plant from mcpacker.model.core.flora.plant import Plant
@@ -22,18 +23,26 @@ class Patch(Plant):
density:Density=DE.THICK, density:Density=DE.THICK,
radius:int=4, radius:int=4,
substrates:Iterable[ResourceId]|Iterable[str]|ResourceId|str|None=None, substrates:Iterable[ResourceId]|Iterable[str]|ResourceId|str|None=None,
companions:Iterable[Companion]|Companion|None=None,
immersion:Immersion=IM.DRY, immersion:Immersion=IM.DRY,
): ):
super().__init__(name) super().__init__(name)
if isinstance(blocks, str) or isinstance(blocks, BlockState): if isinstance(blocks, str) or isinstance(blocks, BlockState):
blocks = [blocks] blocks = [blocks]
if not companions:
companions = []
if isinstance(companions, Companion):
companions = [companions]
if not substrates: if not substrates:
substrates = ["#minecraft:dirt"] substrates = ["#minecraft:dirt"]
if not isinstance(substrates, Iterable): if not isinstance(substrates, Iterable):
substrates = [substrates] substrates = [substrates]
self.blocks = [BlockState.parse(b) for b in blocks] self.blocks = [BlockState.parse(b) for b in blocks]
self.companions = list(companions)
self.density = density self.density = density
self.immersion = immersion self.immersion = immersion
self.radius = radius self.radius = radius
@@ -43,6 +52,7 @@ class Patch(Plant):
return ( return (
"Patch(" "Patch("
f"blocks={self.blocks!r}, " f"blocks={self.blocks!r}, "
f"companions={self.companions!r}, "
f"density={self.density!r}, " f"density={self.density!r}, "
f"immersion={self.immersion!r}, " f"immersion={self.immersion!r}, "
f"radius={self.radius!r}, " f"radius={self.radius!r}, "
@@ -56,8 +66,8 @@ class Patch(Plant):
The value models repeated random placement within a circular area until the expected The value models repeated random placement within a circular area until the expected
fraction of successful placements (`coverage`) for the patch's density is reached. It fraction of successful placements (`coverage`) for the patch's density is reached. It
accounts for both failed placements (controlled by `successRate`) and duplicate hits on accounts for both for the presumed rate of successful placements (controlled by
alreadyfilled blocks. `successRate`) and duplicate hits on alreadyfilled blocks.
The relationship is derived from the expected coverage equation: The relationship is derived from the expected coverage equation:
@@ -9,7 +9,7 @@ def addDisabledFeatures(pack:ModPack):
def add(resourceText:str): def add(resourceText:str):
pack.disabledFeatures.append(ResourceId.parse(resourceText)) pack.disabledFeatures.append(ResourceId.parse(resourceText))
# Disable Vanilla ore generation # Disable vanilla ore generation
add("minecraft:ore_coal_lower") add("minecraft:ore_coal_lower")
add("minecraft:ore_coal_upper") add("minecraft:ore_coal_upper")
add("minecraft:ore_copper_large") add("minecraft:ore_copper_large")
@@ -30,3 +30,61 @@ def addDisabledFeatures(pack:ModPack):
add("minecraft:ore_lapis") add("minecraft:ore_lapis")
add("minecraft:ore_redstone_lower") add("minecraft:ore_redstone_lower")
add("minecraft:ore_redstone") add("minecraft:ore_redstone")
# Disable vanilla plant spawning
add("minecraft:flower_default")
add("minecraft:flower_flower_forest")
add("minecraft:flower_forest_flowers")
add("minecraft:flower_meadow")
add("minecraft:flower_plain")
add("minecraft:flower_plains")
add("minecraft:flower_swamp")
add("minecraft:flower_warm")
add("minecraft:forest_flowers")
add("minecraft:patch_berry_bush")
add("minecraft:patch_berry_common")
add("minecraft:patch_berry_rare")
add("minecraft:patch_melon_sparse")
add("minecraft:patch_melon")
add("minecraft:patch_pumpkin")
add("minecraft:patch_sugar_cane_badlands")
add("minecraft:patch_sugar_cane_desert")
add("minecraft:patch_sugar_cane_swamp")
add("minecraft:patch_sugar_cane")
add("minecraft:patch_sunflower")
# Disable mod plant spawning
add("corn_delight:patch_wild_corn")
add("farmersdelight:patch_brown_mushroom_colony")
add("farmersdelight:patch_red_mushroom_colony")
add("farmersdelight:patch_wild_beetroots")
add("farmersdelight:patch_wild_cabbages")
add("farmersdelight:patch_wild_carrots")
add("farmersdelight:patch_wild_onions")
add("farmersdelight:patch_wild_potatoes")
add("farmersdelight:patch_wild_rice")
add("farmersdelight:patch_wild_tomatoes")
add("fruitsdelight:blueberry_bush")
add("fruitsdelight:cranberry_bush")
add("fruitsdelight:hamimelon")
add("fruitsdelight:lemon_tree")
add("fruitsdelight:pineapple")
add("fruitsdelight:tree/apple_tree")
add("fruitsdelight:tree/bayberry_tree")
add("fruitsdelight:tree/durian_tree")
add("fruitsdelight:tree/fig_tree")
add("fruitsdelight:tree/hawberry_tree")
add("fruitsdelight:tree/kiwi_tree")
add("fruitsdelight:tree/lychee_tree")
add("fruitsdelight:tree/mango_tree")
add("fruitsdelight:tree/mangosteen_tree")
add("fruitsdelight:tree/orange_tree")
add("fruitsdelight:tree/peach_tree")
add("fruitsdelight:tree/pear_tree")
add("fruitsdelight:tree/persimmon_tree")
add("immersive_healing:medica_herb_block_spawning")
add("realistic_wheat:wild_wheat_g")
add("rusticdelight:wild_bell_peppers_placed")
add("rusticdelight:wild_coffee_placed")
add("rusticdelight:wild_cotton_placed")
add("supplementaries:wild_flax")