2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from math import ceil
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from typing import List
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from BaseClasses import Item
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from . import Constants
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from typing import TYPE_CHECKING
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if TYPE_CHECKING:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									from . import MinecraftWorld
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def get_junk_item_names(rand, k: int) -> str:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									junk_weights = Constants.item_info["junk_weights"]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									junk = rand.choices(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										list(junk_weights.keys()),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										weights=list(junk_weights.values()),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										k=k)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return junk
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def build_item_pool(world: "MinecraftWorld") -> List[Item]:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									multiworld = world.multiworld
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									player = world.player
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									itempool = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									total_location_count = len(multiworld.get_unfilled_locations(player))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									required_pool = Constants.item_info["required_pool"]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									# Add required progression items
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for item_name, num in required_pool.items():
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										itempool += [world.create_item(item_name) for _ in range(num)]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									# Add structure compasses
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if world.options.structure_compasses:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										compasses = [name for name in world.item_name_to_id if "Structure Compass" in name]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for item_name in compasses:
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											itempool.append(world.create_item(item_name))
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									# Dragon egg shards
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if world.options.egg_shards_required > 0:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										num = world.options.egg_shards_available
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										itempool += [world.create_item("Dragon Egg Shard") for _ in range(num)]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									# Bee traps
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									bee_trap_percentage = world.options.bee_traps * 0.01
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if bee_trap_percentage > 0:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										bee_trap_qty = ceil(bee_trap_percentage * (total_location_count - len(itempool)))
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										itempool += [world.create_item("Bee Trap") for _ in range(bee_trap_qty)]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									# Fill remaining itempool with randomly generated junk
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-19 15:58:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									junk = get_junk_item_names(world.random, total_location_count - len(itempool))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									itempool += [world.create_item(name) for name in junk]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-08 21:13:52 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return itempool
							 |