Compare commits

..

No commits in common. "b8cbd9a5f063ba9bd1027488182793eca1932639" and "c33e1e04b8f0c139f0bc8d40a6e617cc4200efa1" have entirely different histories.

5 changed files with 12 additions and 72 deletions

View File

@ -20,7 +20,6 @@ SAND = 66
SINGLE_SNOW = 3921
SOUL_TORCH = 4008
TEST_BLOCK = (616, 78, 496)
AVOID = [

5
bot.py
View File

@ -153,9 +153,6 @@ def init(global_state):
g.breaking = None
g.break_time = 0
g.dumping = None
g.dump_lock = False
g.job = jobs.JobStates(g)
def bot(global_state):
@ -198,8 +195,6 @@ def bot(global_state):
init(g)
print('Initialized.')
print(blocks.mcd.windows)
while g.running:
tick(g)

64
game.py
View File

@ -7,7 +7,6 @@ from itertools import count
from panda3d.core import LPoint3f
from minecraft.networking.packets import Packet, clientbound, serverbound
from minecraft.networking.types import BlockFace
from protocol.packets import TimeUpdatePacket, SetSlotPacket, PlayerDiggingPacket, BlockBreakAnimationPacket, AcknowledgePlayerDiggingPacket, HeldItemChangePacket, PickItemPacket
@ -262,7 +261,7 @@ class Game:
raise
if command == 'break':
self.break_block(blocks.TEST_BLOCK)
self.break_block((616, 78, 496))
reply = 'ok'
if command == 'gather' and data:
@ -286,36 +285,13 @@ class Game:
reply = 'ok'
if command == 'inv':
inv_list = []
for i in self.g.inv.values():
if i.present:
inv_list.append('{}:{} x {}'.format(items.ITEM_NAMES[i.item_id], str(i.item_id), i.item_count))
reply = ', '.join(inv_list)
if command == 'drop':
self.drop_stack()
print(items.ITEM_NAMES[i.item_id], 'x', i.item_count)
if command == 'time':
reply = str(self.g.time)
if command == 'select' and data:
item = int(data)
if self.select_item([item]):
reply = 'ok'
else:
reply = 'not found'
if command == 'dump' and data:
item = int(data)
if self.has_item([item]):
self.g.dumping = item
reply = 'ok'
else:
reply = 'not found'
if command == 'open':
self.place_block(blocks.TEST_BLOCK, BlockFace.TOP)
if reply:
print(reply)
self.g.chat.send(reply)
@ -328,9 +304,6 @@ class Game:
if packet.window_id == 0:
self.g.inv[packet.slot] = packet.slot_data
if not packet.slot_data.present:
self.g.dump_lock = False
def break_block(self, location):
bid = self.g.chunks.get_block_at(*location)
if bid != 0:
@ -352,6 +325,7 @@ class Game:
self.g.chunks.set_block_at(*self.g.breaking, 0)
self.g.breaking = None
def handle_break_animation(self, packet):
print(packet)
@ -392,41 +366,9 @@ class Game:
else:
self.pick(slot)
def has_item(self, items):
# select the first match from items of inv
for slot, item in self.g.inv.items():
if item.item_id in items:
return True
else: #for
return False
def select_item(self, items):
# select the first match from items of inv
for slot, item in self.g.inv.items():
if item.item_id in items:
self.g.game.choose_slot(slot)
return True
else: #for
return False
def drop_stack(self):
packet = PlayerDiggingPacket()
packet.status = 3
packet.location = utils.pint(self.g.pos)
packet.face = 1
self.g.connection.write_packet(packet)
def tick(self):
if self.g.breaking:
self.animate()
if time.time() >= self.g.break_time - 2*utils.TICK:
self.break_finish()
if self.g.dumping and not self.g.dump_lock:
if self.select_item([self.g.dumping]):
self.drop_stack()
self.g.dump_lock = True
else:
self.g.dumping = None

12
jobs.py
View File

@ -310,10 +310,14 @@ class SleepWithBedStates:
self.state = self.select_bed
def select_bed(self):
if self.game.select_item(items.BED_IDS):
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW)
self.state = self.place_bed
else:
for slot, item in self.g.inv.items():
if item.item_id in items.BED_IDS:
print('Found bed in slot', slot)
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW)
self.g.game.choose_slot(slot)
self.state = self.place_bed
break
else: # for
self.g.chat.send('I need a bed')
self.state = self.cleanup

View File

@ -14,7 +14,7 @@ minecraft-data==2.67.0
panda3d==1.10.6.post2
pathtools==0.1.2
pycparser==2.20
pyCraft @ git+https://github.com/ammaraskar/pyCraft.git@903c20f9e2c8751fc28af46fc0dc3f7d3ec14a82
pyCraft @ git+https://github.com/ammaraskar/pyCraft.git@cf93923acc2dcfbc076379b43842228d77aea188
PyNBT==3.0.0
requests==2.24.0
six==1.15.0