Port over job sleeping
This commit is contained in:
@@ -8,7 +8,7 @@ from panda3d.core import LPoint3f
|
||||
|
||||
from minecraft.networking.packets import Packet, clientbound, serverbound
|
||||
|
||||
from protocol.packets import TimeUpdatePacket, SetSlotPacket, PlayerDiggingPacket, BlockBreakAnimationPacket, AcknowledgePlayerDiggingPacket
|
||||
from protocol.packets import TimeUpdatePacket, SetSlotPacket, PlayerDiggingPacket, BlockBreakAnimationPacket, AcknowledgePlayerDiggingPacket, HeldItemChangePacket, PickItemPacket
|
||||
|
||||
import utils
|
||||
importlib.reload(utils)
|
||||
@@ -16,6 +16,8 @@ import path
|
||||
importlib.reload(path)
|
||||
import blocks
|
||||
importlib.reload(blocks)
|
||||
import items
|
||||
importlib.reload(items)
|
||||
|
||||
class MCWorld:
|
||||
def __init__(self, global_state):
|
||||
@@ -97,7 +99,7 @@ class MCWorld:
|
||||
def find_bed_areas(self, center, distance):
|
||||
air = []
|
||||
for i in range(5):
|
||||
check = utils.padd(center, alternate(i, 1))
|
||||
check = utils.padd(center, utils.alternate(i, 1))
|
||||
air.extend(self.find_blocks(check, distance, [0], 200))
|
||||
|
||||
areas = []
|
||||
@@ -128,7 +130,7 @@ class MCWorld:
|
||||
def find_sand(self, center, distance, origin):
|
||||
sand = []
|
||||
for i in range(10):
|
||||
check = utils.padd(center, alternate(i, 1))
|
||||
check = utils.padd(center, utils.alternate(i, 1))
|
||||
sand.extend(self.find_blocks(check, distance, [66], 20))
|
||||
|
||||
safe_sand = []
|
||||
@@ -267,6 +269,22 @@ class Game:
|
||||
self.g.job.state = self.g.job.lumberjack
|
||||
reply = 'ok'
|
||||
|
||||
if reply:
|
||||
for i in self.g.inv.values():
|
||||
print(i.item_id)
|
||||
if i.item_id in items.BED_IDS:
|
||||
break
|
||||
else:
|
||||
reply += ', I need a bed'
|
||||
|
||||
if command == 'inv':
|
||||
for i in self.g.inv.values():
|
||||
if i.present:
|
||||
print(items.ITEM_NAMES[i.item_id], 'x', i.item_count)
|
||||
|
||||
if command == 'time':
|
||||
reply = str(self.g.time)
|
||||
|
||||
if reply:
|
||||
print(reply)
|
||||
self.g.chat.send(reply)
|
||||
@@ -316,7 +334,7 @@ class Game:
|
||||
def place_block(self, location, face):
|
||||
packet = serverbound.play.PlayerBlockPlacementPacket()
|
||||
packet.hand = 0
|
||||
packet.location = pos
|
||||
packet.location = location
|
||||
packet.face = face
|
||||
packet.x = 0.5
|
||||
packet.y = 0.5
|
||||
@@ -324,6 +342,23 @@ class Game:
|
||||
packet.inside_block = False
|
||||
self.g.connection.write_packet(packet)
|
||||
|
||||
def pick(self, slot):
|
||||
packet = PickItemPacket()
|
||||
packet.slot_to_use = slot
|
||||
self.g.connection.write_packet(packet)
|
||||
|
||||
def hold(self, slot):
|
||||
packet = HeldItemChangePacket()
|
||||
packet.slot = slot
|
||||
self.g.connection.write_packet(packet)
|
||||
|
||||
def choose_slot(self, slot):
|
||||
if slot >= 36:
|
||||
slot -= 36
|
||||
self.hold(slot)
|
||||
else:
|
||||
self.pick(slot)
|
||||
|
||||
def tick(self):
|
||||
if self.g.breaking:
|
||||
self.animate()
|
||||
|
||||
Reference in New Issue
Block a user