Minecraft: Update to new options system. (#3765)

* Move to new options system.
switch to using self.random
reformat rules file.

* further reformats

* fix tests to use new options system.

* fix slot data to not use self.multiworld

* I hate python

* new starting_items docstring to prepare for 1.20.5+ item components.
fix invalid json being output to starting_items

* more typing fixes.

* stupid quotes around type declarations

* removed unused variable in ItemPool.py
change null check in Structures.py

* update rules "self" variable to a "world: MinecraftWorld" variable

* get key, and not value for required bosses.
This commit is contained in:
KonoTyran
2024-08-19 15:58:30 -07:00
committed by GitHub
parent 1e8a8e7482
commit c010c8c938
7 changed files with 517 additions and 308 deletions

View File

@@ -1,10 +1,14 @@
from math import ceil
from typing import List
from BaseClasses import MultiWorld, Item
from worlds.AutoWorld import World
from BaseClasses import Item
from . import Constants
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from . import MinecraftWorld
def get_junk_item_names(rand, k: int) -> str:
junk_weights = Constants.item_info["junk_weights"]
@@ -14,39 +18,38 @@ def get_junk_item_names(rand, k: int) -> str:
k=k)
return junk
def build_item_pool(mc_world: World) -> List[Item]:
multiworld = mc_world.multiworld
player = mc_world.player
def build_item_pool(world: "MinecraftWorld") -> List[Item]:
multiworld = world.multiworld
player = world.player
itempool = []
total_location_count = len(multiworld.get_unfilled_locations(player))
required_pool = Constants.item_info["required_pool"]
junk_weights = Constants.item_info["junk_weights"]
# Add required progression items
for item_name, num in required_pool.items():
itempool += [mc_world.create_item(item_name) for _ in range(num)]
itempool += [world.create_item(item_name) for _ in range(num)]
# Add structure compasses
if multiworld.structure_compasses[player]:
compasses = [name for name in mc_world.item_name_to_id if "Structure Compass" in name]
if world.options.structure_compasses:
compasses = [name for name in world.item_name_to_id if "Structure Compass" in name]
for item_name in compasses:
itempool.append(mc_world.create_item(item_name))
itempool.append(world.create_item(item_name))
# Dragon egg shards
if multiworld.egg_shards_required[player] > 0:
num = multiworld.egg_shards_available[player]
itempool += [mc_world.create_item("Dragon Egg Shard") for _ in range(num)]
if world.options.egg_shards_required > 0:
num = world.options.egg_shards_available
itempool += [world.create_item("Dragon Egg Shard") for _ in range(num)]
# Bee traps
bee_trap_percentage = multiworld.bee_traps[player] * 0.01
bee_trap_percentage = world.options.bee_traps * 0.01
if bee_trap_percentage > 0:
bee_trap_qty = ceil(bee_trap_percentage * (total_location_count - len(itempool)))
itempool += [mc_world.create_item("Bee Trap") for _ in range(bee_trap_qty)]
itempool += [world.create_item("Bee Trap") for _ in range(bee_trap_qty)]
# Fill remaining itempool with randomly generated junk
junk = get_junk_item_names(multiworld.random, total_location_count - len(itempool))
itempool += [mc_world.create_item(name) for name in junk]
junk = get_junk_item_names(world.random, total_location_count - len(itempool))
itempool += [world.create_item(name) for name in junk]
return itempool