Avoid planted saplings when pathfinding
This commit is contained in:
1 parent
0a499f901a
commit
0b462f4a76
2 files changed
+18
-7
No files matched your search
@@ -60,6 +60,12 @@ def get_set(names):
|
|||||||
SAND_IDS = get_set(['sand', 'red_sand'])
|
SAND_IDS = get_set(['sand', 'red_sand'])
|
||||||
|
|
||||||
|
|
||||||
|
LOGS = sorted(name for name in MCD_BLOCKS
|
||||||
|
if name.endswith(('_log', '_wood', '_stem', '_hyphae')))
|
||||||
|
LEAVES = sorted(name for name in MCD_BLOCKS if name.endswith('_leaves'))
|
||||||
|
SAPLINGS = sorted(name for name in MCD_BLOCKS
|
||||||
|
if name.endswith('_sapling') or name.endswith('_propagule'))
|
||||||
|
|
||||||
# Collision geometry is safer for navigation than the old hard-coded 1.16 list.
|
# Collision geometry is safer for navigation than the old hard-coded 1.16 list.
|
||||||
NON_SOLID_IDS = {
|
NON_SOLID_IDS = {
|
||||||
state_id for state_id, boxes in COLLISION_BOXES.items() if not boxes
|
state_id for state_id, boxes in COLLISION_BOXES.items() if not boxes
|
||||||
@@ -67,19 +73,13 @@ NON_SOLID_IDS = {
|
|||||||
AVOID = {
|
AVOID = {
|
||||||
'lava', 'water', 'fire', 'magma_block', 'sweet_berry_bush',
|
'lava', 'water', 'fire', 'magma_block', 'sweet_berry_bush',
|
||||||
'nether_portal', 'end_portal', 'cactus', 'powder_snow',
|
'nether_portal', 'end_portal', 'cactus', 'powder_snow',
|
||||||
}
|
} | set(SAPLINGS)
|
||||||
AVOID_IDS = get_set(AVOID)
|
AVOID_IDS = get_set(AVOID)
|
||||||
AVOID_IDS.update(
|
AVOID_IDS.update(
|
||||||
state_id for state_id, name in BLOCKS.items()
|
state_id for state_id, name in BLOCKS.items()
|
||||||
if name.endswith(('_fence', '_fence_gate', '_wall'))
|
if name.endswith(('_fence', '_fence_gate', '_wall'))
|
||||||
)
|
)
|
||||||
WATER_IDS = get_set(['water'])
|
WATER_IDS = get_set(['water'])
|
||||||
|
|
||||||
LOGS = sorted(name for name in MCD_BLOCKS
|
|
||||||
if name.endswith(('_log', '_wood', '_stem', '_hyphae')))
|
|
||||||
LEAVES = sorted(name for name in MCD_BLOCKS if name.endswith('_leaves'))
|
|
||||||
SAPLINGS = sorted(name for name in MCD_BLOCKS
|
|
||||||
if name.endswith('_sapling') or name.endswith('_propagule'))
|
|
||||||
BEDS = sorted(name for name in MCD_BLOCKS if name.endswith('_bed'))
|
BEDS = sorted(name for name in MCD_BLOCKS if name.endswith('_bed'))
|
||||||
INDEXED = ['chest', 'trapped_chest', 'emerald_block', 'barrel'] + BEDS + [
|
INDEXED = ['chest', 'trapped_chest', 'emerald_block', 'barrel'] + BEDS + [
|
||||||
'wheat', 'potatoes', 'carrots', 'beetroots', 'nether_wart',
|
'wheat', 'potatoes', 'carrots', 'beetroots', 'nether_wart',
|
||||||
|
|||||||
@@ -27,6 +27,17 @@ class DoorNavigationTests(unittest.TestCase):
|
|||||||
blocks.PROPS[state].get('open') == str(opened).lower() and
|
blocks.PROPS[state].get('open') == str(opened).lower() and
|
||||||
blocks.PROPS[state].get('powered') == str(powered).lower())
|
blocks.PROPS[state].get('powered') == str(powered).lower())
|
||||||
|
|
||||||
|
def test_pathfinder_avoids_all_sapling_and_propagule_states(self):
|
||||||
|
self.assertTrue(blocks.SAPLING_IDS)
|
||||||
|
self.assertLessEqual(blocks.SAPLING_IDS, blocks.AVOID_IDS)
|
||||||
|
|
||||||
|
state_id = next(iter(blocks.SAPLING_IDS))
|
||||||
|
finder = Pathfinder(Munch(
|
||||||
|
chunks=FakeChunks({(1, 64, 0): state_id}),
|
||||||
|
crawling=False, unopenable_doors=set()))
|
||||||
|
self.assertTrue(finder.bavoid((1, 64, 0)))
|
||||||
|
self.assertFalse(finder.check_traverse((0, 64, 0), (1, 0, 0)))
|
||||||
|
|
||||||
def test_pathfinder_treats_openable_doors_as_passable_but_not_iron(self):
|
def test_pathfinder_treats_openable_doors_as_passable_but_not_iron(self):
|
||||||
wooden = self.door_state('oak_door')
|
wooden = self.door_state('oak_door')
|
||||||
iron = self.door_state('iron_door')
|
iron = self.door_state('iron_door')
|
||||||
|
|||||||
Reference in new issue
Block a user