Support harvesting and caching red sand
This commit is contained in:
1 parent
9918baefdc
commit
ebf325f48b
7 files changed
+48
-31
No files matched your search
@@ -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]]
|
||||
|
||||
Reference in new issue
Block a user