Support harvesting and caching red sand
This commit is contained in:
1 parent
9918baefdc
commit
ebf325f48b
7 files changed
+33
-16
No files matched your search
@@ -86,11 +86,11 @@ mosfet sand origin
|
||||
```
|
||||
|
||||
The bot uses the nearest matching loaded sign within 200 blocks. A full bot
|
||||
name such as `mosfet1` can be used instead of the group name. Sand is harvested
|
||||
in safe 3x3x1 sections. After each section, pickup/cache/food/sleep maintenance
|
||||
runs before the job starts the next one. If no matching sign is found, the job
|
||||
keeps its previous loaded origin, or uses the bot's current block position when
|
||||
no loaded origin is set.
|
||||
name such as `mosfet1` can be used instead of the group name. Sand and red sand
|
||||
are harvested in safe 3x3x1 sections; pickup/cache/food/sleep maintenance runs
|
||||
between sections. If no matching sign is found, the job keeps its previous
|
||||
loaded origin, or uses the bot's current block position when no loaded origin
|
||||
is set.
|
||||
|
||||
### Cache labels
|
||||
|
||||
@@ -105,6 +105,8 @@ Each recognized line adds items to the chest's accepted categories:
|
||||
- `Seeds` — `beetroot_seeds`, `melon_seeds`, `pumpkin_seeds`,
|
||||
`torchflower_seeds`, `wheat_seeds`, and `pitcher_pod`.
|
||||
- `Wheat` — wheat only; wheat seeds are not included.
|
||||
- `Sand` — sand only.
|
||||
- `Red Sand` — red sand only.
|
||||
- `Logs` — every log item in the current 26.3 data, including stripped logs,
|
||||
wood, stems, and hyphae.
|
||||
- `Oak Logs` (and labels such as `Spruce Logs`) — that tree's log family,
|
||||
@@ -299,11 +301,12 @@ These will only run for the bot they are addressed to. Replace `1` with the last
|
||||
|
||||
`1gather wood` - gathers wood from the world
|
||||
|
||||
`1gather sand` - gathers sand from the world
|
||||
`1gather sand` - gathers sand and red sand from the world
|
||||
|
||||
`1farm logs` (or `1farm wood`) - farms trees and caches their logs
|
||||
|
||||
`1farm sand` - gathers sand, first obtaining a shovel from a supply chest
|
||||
`1farm sand` - gathers sand and red sand, first obtaining a shovel from a
|
||||
supply chest
|
||||
|
||||
`1farm wart` - farms netherwart from a certain area
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ BREAK_DISTANCE = 6
|
||||
AIR = MCD_BLOCKS['air']['minStateId']
|
||||
STONE = MCD_BLOCKS['stone']['minStateId']
|
||||
SAND = MCD_BLOCKS['sand']['minStateId']
|
||||
RED_SAND = MCD_BLOCKS['red_sand']['minStateId']
|
||||
SOUL_TORCH = MCD_BLOCKS['soul_torch']['minStateId']
|
||||
EMERALD_BLOCK = MCD_BLOCKS['emerald_block']['minStateId']
|
||||
SINGLE_SNOW = MCD_BLOCKS.get('snow', MCD_BLOCKS.get('snow_layer', {})).get(
|
||||
@@ -56,6 +57,9 @@ def get_set(names):
|
||||
return result
|
||||
|
||||
|
||||
SAND_IDS = get_set(['sand', 'red_sand'])
|
||||
|
||||
|
||||
# Collision geometry is safer for navigation than the old hard-coded 1.16 list.
|
||||
NON_SOLID_IDS = {
|
||||
state_id for state_id, boxes in COLLISION_BOXES.items() if not boxes
|
||||
|
||||
@@ -82,6 +82,8 @@ def get_name(idx):
|
||||
CHEST_ID = get_id('chest')
|
||||
GAPPLE_ID = get_id('enchanted_golden_apple')
|
||||
SAND_ID = get_id('sand')
|
||||
RED_SAND_ID = get_id('red_sand')
|
||||
SAND_IDS = {SAND_ID, RED_SAND_ID}
|
||||
NETHERWART_ID = get_id('nether_wart')
|
||||
CARROT_ID = get_id('carrot')
|
||||
POTATO_ID = get_id('potato')
|
||||
@@ -96,6 +98,8 @@ IRON_INGOT_ID = get_id('iron_ingot')
|
||||
|
||||
|
||||
_LABEL_ITEM_IDS = {
|
||||
'sand': {SAND_ID},
|
||||
'red sand': {RED_SAND_ID},
|
||||
'seeds': get_set({
|
||||
'beetroot_seeds', 'melon_seeds', 'pitcher_pod', 'pumpkin_seeds',
|
||||
'torchflower_seeds', 'wheat_seeds',
|
||||
|
||||
@@ -151,7 +151,7 @@ class GatherSandStates:
|
||||
self.state = self.find_new_sand
|
||||
|
||||
def going_to_sand(self):
|
||||
if self.g.world.block_at(*self.sand) != blocks.SAND:
|
||||
if self.g.world.block_at(*self.sand) not in blocks.SAND_IDS:
|
||||
self.g.path = []
|
||||
self._clear_navigation()
|
||||
self.state = self.find_new_sand
|
||||
@@ -175,7 +175,7 @@ class GatherSandStates:
|
||||
time.monotonic() + self.BREAK_CONFIRM_TIMEOUT)
|
||||
|
||||
def dig_sand(self):
|
||||
if self.g.world.block_at(*self.sand) != blocks.SAND:
|
||||
if self.g.world.block_at(*self.sand) not in blocks.SAND_IDS:
|
||||
self.g.look_at = None
|
||||
self.state = self.find_new_sand
|
||||
return
|
||||
@@ -209,7 +209,7 @@ class GatherSandStates:
|
||||
def wait_break(self):
|
||||
if self.break_deadline is None:
|
||||
self._set_break_deadline()
|
||||
if self.g.world.block_at(*self.sand) != blocks.SAND:
|
||||
if self.g.world.block_at(*self.sand) not in blocks.SAND_IDS:
|
||||
print('Sand break confirmed at', self.sand)
|
||||
self.g.look_at = None
|
||||
self.state = self.find_new_sand
|
||||
|
||||
+3
-3
@@ -807,7 +807,7 @@ class World:
|
||||
state_id = self.block_at(*position)
|
||||
if state_id is None:
|
||||
return False, 'block is not loaded'
|
||||
if state_id != blocks.SAND:
|
||||
if state_id not in blocks.SAND_IDS:
|
||||
name = blocks.BLOCKS.get(state_id, 'unknown block')
|
||||
return False, 'block is {}, not sand'.format(name)
|
||||
|
||||
@@ -845,7 +845,7 @@ class World:
|
||||
name = blocks.BLOCKS.get(adjacent, 'hazard block')
|
||||
return False, 'unsafe adjacent {} at {}'.format(
|
||||
name, adjacent_pos)
|
||||
if adjacent == blocks.SAND:
|
||||
if adjacent in blocks.SAND_IDS:
|
||||
supported, reason = self._sand_has_immediate_support(
|
||||
adjacent_pos)
|
||||
if not supported:
|
||||
@@ -856,7 +856,7 @@ class World:
|
||||
|
||||
def find_sand(self, center, distance, player):
|
||||
sand = []
|
||||
sand.extend(self.find_blocks(center, distance, [blocks.SAND], 25))
|
||||
sand.extend(self.find_blocks(center, distance, blocks.SAND_IDS, 25))
|
||||
|
||||
safe_sand = [sand for sand in sand
|
||||
if self.sand_safety(sand)[0]]
|
||||
|
||||
@@ -47,20 +47,21 @@ class IndexedSearchTests(unittest.TestCase):
|
||||
world_blocks[(1, 63, 0)] = blocks.SAND
|
||||
self.assertTrue(world.sand_safety(sand)[0])
|
||||
|
||||
def test_sand_search_targets_safe_blocks_in_3x3_slice_only(self):
|
||||
def test_sand_search_targets_safe_sand_types_in_3x3_slice_only(self):
|
||||
for sand_state in blocks.SAND_IDS:
|
||||
sand_position = (1, 64, 1)
|
||||
|
||||
class SandChunks:
|
||||
def get_block_at(self, x, y, z):
|
||||
position = (x, y, z)
|
||||
if position == sand_position:
|
||||
return blocks.SAND
|
||||
return sand_state
|
||||
if y < sand_position[1]:
|
||||
return blocks.STONE
|
||||
return blocks.AIR
|
||||
|
||||
with self.subTest(sand_state=sand_state):
|
||||
world = World(Munch(chunks=SandChunks()))
|
||||
|
||||
self.assertTrue(world.check_sand_slice((0, 64, 0)))
|
||||
self.assertEqual(
|
||||
world.find_sand((0, 64, 0), 2, (0, 64, 0)),
|
||||
|
||||
@@ -11,7 +11,12 @@ class StorageLabelTests(unittest.TestCase):
|
||||
wheat = items.storage_item_ids_for_label('Wheat')
|
||||
logs = items.storage_item_ids_for_label('Logs')
|
||||
saplings = items.storage_item_ids_for_label('Saplings')
|
||||
sand = items.storage_item_ids_for_label('Sand')
|
||||
red_sand = items.storage_item_ids_for_label('Red Sand')
|
||||
|
||||
self.assertEqual(sand, {items.SAND_ID})
|
||||
self.assertEqual(red_sand, {items.RED_SAND_ID})
|
||||
self.assertNotEqual(sand, red_sand)
|
||||
self.assertEqual(seeds, items.get_set({
|
||||
'beetroot_seeds', 'melon_seeds', 'pitcher_pod', 'pumpkin_seeds',
|
||||
'torchflower_seeds', 'wheat_seeds',
|
||||
|
||||
Reference in new issue
Block a user