Compare commits

..

No commits in common. "d69f9cf09e2fefb137e27a7515b20db7ffdc8409" and "4026b410f49dd43e0ef092cba5bfd01ae4d3586e" have entirely different histories.

5 changed files with 14 additions and 55 deletions

View File

@ -520,11 +520,7 @@ class Commands:
pass pass
if reply: if reply:
print('Reply:', reply) print(reply)
if len(reply) >= 256:
reply = 'reply too long, check console'
if private and not reply.startswith('/'): if private and not reply.startswith('/'):
self.g.chat.send('/m ' + sender + ' ' + reply) self.g.chat.send('/m ' + sender + ' ' + reply)
else: else:

View File

@ -89,9 +89,6 @@ for item_name, item in ITEMS.items():
def get_id(name): def get_id(name):
return ITEMS['minecraft:' + name]['protocol_id'] return ITEMS['minecraft:' + name]['protocol_id']
def get_name(idx):
return ITEM_NAMES[idx]
CHEST_ID = get_id('chest') CHEST_ID = get_id('chest')
GAPPLE_ID = get_id('enchanted_golden_apple') GAPPLE_ID = get_id('enchanted_golden_apple')
SAND_ID = get_id('sand') SAND_ID = get_id('sand')
@ -118,10 +115,8 @@ INIT_WANTED_ITEMS = set()
WANTED_ITEMS = INIT_WANTED_ITEMS WANTED_ITEMS = INIT_WANTED_ITEMS
def set_needed(items): def set_needed(items):
global NEEDED_ITEMS
NEEDED_ITEMS = INIT_NEEDED_ITEMS | items NEEDED_ITEMS = INIT_NEEDED_ITEMS | items
def set_wanted(items): def set_wanted(items):
global WANTED_ITEMS
WANTED_ITEMS = INIT_WANTED_ITEMS | items WANTED_ITEMS = INIT_WANTED_ITEMS | items

View File

@ -42,13 +42,8 @@ class SleepWithBedStates:
self.beds = [] self.beds = []
for bed in result: for bed in result:
if bed in self.bad_beds: if bed not in self.bad_beds:
continue self.beds.append(bed)
if w.check_bed_occupied(bed):
continue
self.beds.append(bed)
print('Found:', self.beds) print('Found:', self.beds)
self.state = self.choose_bed self.state = self.choose_bed
@ -89,7 +84,6 @@ class SleepWithBedStates:
def going_to_bed(self): def going_to_bed(self):
if utils.pint(self.g.pos) == self.opening: if utils.pint(self.g.pos) == self.opening:
print('At existing bed')
self.my_bed = False self.my_bed = False
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW) self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW)
self.state = self.use_bed self.state = self.use_bed
@ -134,43 +128,32 @@ class SleepWithBedStates:
def going_to_area(self): def going_to_area(self):
if utils.pint(self.g.pos) == self.opening: if utils.pint(self.g.pos) == self.opening:
print('At bed area')
self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW) self.g.look_at = utils.padd(self.area, path.BLOCK_BELOW)
self.state = self.place_bed self.state = self.place_bed
def place_bed(self): def place_bed(self):
print('Placing bed')
self.g.game.place_block(self.area, BlockFace.TOP) self.g.game.place_block(self.area, BlockFace.TOP)
self.my_bed = True self.my_bed = True
self.state = self.use_bed self.state = self.use_bed
def use_bed(self): def use_bed(self):
w = self.g.world if self.g.time > 12550:
print('Sleeping')
if self.g.time < 12550: self.g.game.place_block(self.area, BlockFace.TOP)
return if not self.silent:
self.g.chat.send('zzz')
if w.check_bed_occupied(self.area): self.state = self.sleep_bed
print('Bed occupied, aborting.')
self.state = self.cleanup
return
print('Using bed')
self.g.game.place_block(self.area, BlockFace.TOP)
if not self.silent:
self.g.chat.send('zzz')
self.state = self.sleep_bed
def sleep_bed(self): def sleep_bed(self):
w = self.g.world w = self.g.world
p = utils.pint(self.g.pos) p = utils.pint(self.g.pos)
threats = w.find_threats(p, 10) threats = w.find_threats(p, 30)
if threats: if threats:
print('Waking up due to threats:') print('Waking up due to threats:')
print(threats) print(threats)
self.g.game.leave_bed() self.g.game.leave_bed()
self.state = self.cleanup self.state = self.break_bed
elif self.g.time < 100: elif self.g.time < 100:
print('Woke up time') print('Woke up time')
self.state = self.break_bed self.state = self.break_bed
@ -182,6 +165,7 @@ class SleepWithBedStates:
else: else:
self.state = self.cleanup self.state = self.cleanup
def collect_bed(self): def collect_bed(self):
if not self.g.breaking: if not self.g.breaking:
self.g.path = [utils.padd(self.area, utils.spiral(n)) for n in range(9)] self.g.path = [utils.padd(self.area, utils.spiral(n)) for n in range(9)]

View File

@ -7,7 +7,6 @@ from minecraft.networking.packets import clientbound, serverbound
from mosfet.protocol import packets from mosfet.protocol import packets
from mosfet import utils from mosfet import utils
from mosfet.info import blocks
class DataManager: class DataManager:
def __init__(self, directory): def __init__(self, directory):
@ -43,7 +42,7 @@ class ChunksManager:
def __init__(self, data_manager): def __init__(self, data_manager):
self.data = data_manager self.data = data_manager
self.chunks = {} self.chunks = {}
#self.biomes = {} self.biomes = {}
self.index = {} self.index = {}
self.loading = False self.loading = False
@ -75,7 +74,7 @@ class ChunksManager:
coords = (dx + l%16, dy + l//256, dz + l%256//16) coords = (dx + l%16, dy + l//256, dz + l%256//16)
self.index[item_id].append(coords) self.index[item_id].append(coords)
#self.biomes[(chunk_packet.x, None, chunk_packet.z)] = chunk_packet.biomes # FIXME self.biomes[(chunk_packet.x, None, chunk_packet.z)] = chunk_packet.biomes # FIXME
if self.loading: if self.loading:
print('.', end='', flush=True) print('.', end='', flush=True)
@ -117,11 +116,6 @@ class ChunksManager:
if not c: return None if not c: return None
c.set_block_at(x%16, y%16, z%16, block) c.set_block_at(x%16, y%16, z%16, block)
if block in blocks.INDEXED_IDS:
if block not in self.index:
self.index[block] = []
self.index[block].append((x, y, z))
def check_loaded(self, position, steps=1): def check_loaded(self, position, steps=1):
x, y, z = utils.pint(position) x, y, z = utils.pint(position)
player_chunk = (x//16, 1, z//16) player_chunk = (x//16, 1, z//16)

View File

@ -259,16 +259,6 @@ class World:
result.append(utils.padd(area, direction)) result.append(utils.padd(area, direction))
return result return result
def check_bed_occupied(self, bed):
# returns true if the bed is occupied by a player
print('Checking bed occupancy:', bed)
for player in self.g.players.values():
ppos = utils.pint((player.x, player.y, player.z))
if utils.phyp(bed, ppos) <= 1 and player.y - int(player.y) == 0.6875:
print('Bed is occupied by:', player, self.g.player_names[player.player_uuid])
return True
return False
def find_cache_openings(self, area): def find_cache_openings(self, area):
return self.find_bed_openings(area) return self.find_bed_openings(area)