Use shovels, land in water
This commit is contained in:
parent
00846538e8
commit
6ba9288fd7
|
@ -24,6 +24,10 @@ SOUL_TORCH = 4008
|
||||||
TEST_BLOCK = (616, 78, 496)
|
TEST_BLOCK = (616, 78, 496)
|
||||||
|
|
||||||
|
|
||||||
|
WATER = [
|
||||||
|
'water',
|
||||||
|
]
|
||||||
|
|
||||||
AVOID = [
|
AVOID = [
|
||||||
'lava',
|
'lava',
|
||||||
'water',
|
'water',
|
||||||
|
@ -253,6 +257,11 @@ for block_name in AVOID:
|
||||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||||
AVOID_IDS.add(state['id'])
|
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()
|
LOG_IDS = set()
|
||||||
for block_name in LOGS:
|
for block_name in LOGS:
|
||||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||||
|
|
3
bot.py
3
bot.py
|
@ -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))
|
block_below = g.chunks.get_block_at(floor(p.x), ceil(p.y-1), floor(p.z))
|
||||||
in_void = p.y < 0
|
in_void = p.y < 0
|
||||||
in_air = block_below in blocks.NON_SOLID_IDS or in_void
|
in_air = block_below in blocks.NON_SOLID_IDS or in_void
|
||||||
|
in_water = block_below in blocks.WATER_IDS
|
||||||
|
|
||||||
if in_air:
|
if in_air:
|
||||||
g.y_a = -36.0
|
g.y_a = -36.0
|
||||||
|
elif in_water:
|
||||||
|
g.y_a = -16.0
|
||||||
else:
|
else:
|
||||||
p.y = ceil(p.y)
|
p.y = ceil(p.y)
|
||||||
g.y_v = 0
|
g.y_v = 0
|
||||||
|
|
6
game.py
6
game.py
|
@ -431,6 +431,7 @@ class Game:
|
||||||
|
|
||||||
if command == 'stop':
|
if command == 'stop':
|
||||||
self.g.job.state = self.g.job.stop
|
self.g.job.state = self.g.job.stop
|
||||||
|
self.g.path = []
|
||||||
reply = 'ok'
|
reply = 'ok'
|
||||||
|
|
||||||
if command == 'inv':
|
if command == 'inv':
|
||||||
|
@ -514,7 +515,7 @@ class Game:
|
||||||
|
|
||||||
if command == 'sand_slice':
|
if command == 'sand_slice':
|
||||||
try:
|
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)
|
reply = str(result)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -553,7 +554,7 @@ class Game:
|
||||||
self.g.connection.write_packet(packet)
|
self.g.connection.write_packet(packet)
|
||||||
|
|
||||||
self.g.breaking = location
|
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):
|
def break_finish(self):
|
||||||
packet = PlayerDiggingPacket()
|
packet = PlayerDiggingPacket()
|
||||||
|
@ -622,6 +623,7 @@ class Game:
|
||||||
for slot, item in inv_items:
|
for slot, item in inv_items:
|
||||||
if item.item_id in items:
|
if item.item_id in items:
|
||||||
self.g.game.choose_slot(slot)
|
self.g.game.choose_slot(slot)
|
||||||
|
self.g.holding = item.item_id
|
||||||
return True
|
return True
|
||||||
else: #for
|
else: #for
|
||||||
return False
|
return False
|
||||||
|
|
13
items.py
13
items.py
|
@ -22,6 +22,15 @@ BEDS = [
|
||||||
'black_bed',
|
'black_bed',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SHOVELS = [
|
||||||
|
'wooden_shovel',
|
||||||
|
'stone_shovel',
|
||||||
|
'golden_shovel',
|
||||||
|
'iron_shovel',
|
||||||
|
'diamond_shovel',
|
||||||
|
'netherite_shovel',
|
||||||
|
]
|
||||||
|
|
||||||
SAPLINGS = [
|
SAPLINGS = [
|
||||||
'oak_sapling',
|
'oak_sapling',
|
||||||
'spruce_sapling',
|
'spruce_sapling',
|
||||||
|
@ -35,6 +44,10 @@ BED_IDS = set()
|
||||||
for item_name in BEDS:
|
for item_name in BEDS:
|
||||||
BED_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
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()
|
SAPLING_IDS = set()
|
||||||
for item_name in SAPLINGS:
|
for item_name in SAPLINGS:
|
||||||
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
SAPLING_IDS.add(ITEMS['minecraft:'+item_name]['protocol_id'])
|
||||||
|
|
6
jobs.py
6
jobs.py
|
@ -299,6 +299,10 @@ class GatherSandStates:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def init(self):
|
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
|
self.state = self.find_new_slice
|
||||||
|
|
||||||
def find_new_slice(self):
|
def find_new_slice(self):
|
||||||
|
@ -566,7 +570,7 @@ class SleepWithBedStates:
|
||||||
self.g = global_state
|
self.g = global_state
|
||||||
self.state = self.idle
|
self.state = self.idle
|
||||||
|
|
||||||
self.silent = True
|
self.silent = False
|
||||||
|
|
||||||
self.area = None
|
self.area = None
|
||||||
self.opening = None
|
self.opening = None
|
||||||
|
|
1
main.py
1
main.py
|
@ -23,6 +23,7 @@ g.objects = {}
|
||||||
g.window = None
|
g.window = None
|
||||||
g.job = None
|
g.job = None
|
||||||
g.correction_count = 0
|
g.correction_count = 0
|
||||||
|
g.holding = 0
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello_world():
|
def hello_world():
|
||||||
|
|
1
utils.py
1
utils.py
|
@ -71,6 +71,7 @@ def diffrange(n):
|
||||||
|
|
||||||
def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantments=[], effects={}):
|
def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantments=[], effects={}):
|
||||||
# from PrismarineJS/prismarine-block
|
# from PrismarineJS/prismarine-block
|
||||||
|
held_item = str(held_item)
|
||||||
block_data = blocks.get(block_id)
|
block_data = blocks.get(block_id)
|
||||||
|
|
||||||
can_harvest = 'harvestTools' not in block_data or str(held_item) in block_data['harvestTools']
|
can_harvest = 'harvestTools' not in block_data or str(held_item) in block_data['harvestTools']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user