diff --git a/BaseClasses.py b/BaseClasses.py index 796db592..68166172 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -389,20 +389,14 @@ class MultiWorld(): self.state.collect(item, True) def push_item(self, location: Location, item: Item, collect: bool = True): - if not isinstance(location, Location): - raise RuntimeError( - 'Cannot assign item %s to invalid location %s (player %d).' % (item, location, item.player)) + assert location.can_fill(self.state, item, False), f"Cannot place {item} into {location}." + location.item = item + item.location = location + item.world = self # try to not have this here anymore and create it with item? + if collect: + self.state.collect(item, location.event, location) - if location.can_fill(self.state, item, False): - location.item = item - item.location = location - item.world = self # try to not have this here anymore - if collect: - self.state.collect(item, location.event, location) - - logging.debug('Placed %s at %s', item, location) - else: - raise RuntimeError('Cannot assign item %s to location %s.' % (item, location)) + logging.debug('Placed %s at %s', item, location) def get_entrances(self) -> List[Entrance]: if self._cached_entrances is None: