Use shovels, land in water

master
Tanner Collin 3 years ago
parent 00846538e8
commit 6ba9288fd7
  1. 9
      blocks.py
  2. 3
      bot.py
  3. 6
      game.py
  4. 13
      items.py
  5. 6
      jobs.py
  6. 1
      main.py
  7. 1
      utils.py

@ -24,6 +24,10 @@ SOUL_TORCH = 4008
TEST_BLOCK = (616, 78, 496)
WATER = [
'water',
]
AVOID = [
'lava',
'water',
@ -253,6 +257,11 @@ for block_name in AVOID:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
AVOID_IDS.add(state['id'])
WATER_IDS = set()
for block_name in WATER:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
WATER_IDS.add(state['id'])
LOG_IDS = set()
for block_name in LOGS:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:

@ -130,9 +130,12 @@ def tick(global_state):
block_below = g.chunks.get_block_at(floor(p.x), ceil(p.y-1), floor(p.z))
in_void = p.y < 0
in_air = block_below in blocks.NON_SOLID_IDS or in_void
in_water = block_below in blocks.WATER_IDS
if in_air:
g.y_a = -36.0
elif in_water:
g.y_a = -16.0
else:
p.y = ceil(p.y)
g.y_v = 0

@ -431,6 +431,7 @@ class Game:
if command == 'stop':
self.g.job.state = self.g.job.stop
self.g.path = []
reply = 'ok'
if command == 'inv':
@ -514,7 +515,7 @@ class Game:
if command == 'sand_slice':
try:
_, result = self.g.world.find_sand_slice(utils.pint(self.g.pos), 50)
result = self.g.world.find_sand_slice(utils.pint(self.g.pos), 50)
reply = str(result)
except:
import traceback
@ -553,7 +554,7 @@ class Game:
self.g.connection.write_packet(packet)
self.g.breaking = location
self.g.break_time = time.time() + utils.break_time(bid)
self.g.break_time = time.time() + utils.break_time(bid, self.g.holding)
def break_finish(self):
packet = PlayerDiggingPacket()
@ -622,6 +623,7 @@ class Game:
for slot, item in inv_items:
if item.item_id in items:
self.g.game.choose_slot(slot)
self.g.holding = item.item_id
return True
else: #for
return False

@ -22,6 +22,15 @@ BEDS = [
'black_bed',
]
SHOVELS = [
'wooden_shovel',
'stone_shovel',
'golden_shovel',
'iron_shovel',
'diamond_shovel',
'netherite_shovel',
]
SAPLINGS = [
'oak_sapling',
'spruce_sapling',
@ -35,6 +44,10 @@ BED_IDS = set()
for item_name in BEDS:
BED_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
SHOVEL_IDS = set()
for item_name in SHOVELS:
SHOVEL_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
SAPLING_IDS = set()
for item_name in SAPLINGS:
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])

@ -299,6 +299,10 @@ class GatherSandStates:
return None
def init(self):
self.state = self.select_shovel
def select_shovel(self):
self.g.game.select_item(items.SHOVEL_IDS)
self.state = self.find_new_slice
def find_new_slice(self):
@ -566,7 +570,7 @@ class SleepWithBedStates:
self.g = global_state
self.state = self.idle
self.silent = True
self.silent = False
self.area = None
self.opening = None

@ -23,6 +23,7 @@ g.objects = {}
g.window = None
g.job = None
g.correction_count = 0
g.holding = 0
@app.route('/')
def hello_world():

@ -71,6 +71,7 @@ def diffrange(n):
def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantments=[], effects={}):
# from PrismarineJS/prismarine-block
held_item = str(held_item)
block_data = blocks.get(block_id)
can_harvest = 'harvestTools' not in block_data or str(held_item) in block_data['harvestTools']

Loading…
Cancel
Save