Compare commits
4 Commits
4026b410f4
...
d69f9cf09e
Author | SHA1 | Date | |
---|---|---|---|
d69f9cf09e | |||
8b85de2b2a | |||
ce9613c00c | |||
09b9002c58 |
|
@ -520,7 +520,11 @@ class Commands:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if reply:
|
if reply:
|
||||||
print(reply)
|
print('Reply:', 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:
|
||||||
|
|
|
@ -89,6 +89,9 @@ 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')
|
||||||
|
@ -115,8 +118,10 @@ 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
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,13 @@ class SleepWithBedStates:
|
||||||
|
|
||||||
self.beds = []
|
self.beds = []
|
||||||
for bed in result:
|
for bed in result:
|
||||||
if bed not in self.bad_beds:
|
if bed in self.bad_beds:
|
||||||
self.beds.append(bed)
|
continue
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -84,6 +89,7 @@ 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
|
||||||
|
@ -128,32 +134,43 @@ 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):
|
||||||
if self.g.time > 12550:
|
w = self.g.world
|
||||||
print('Sleeping')
|
|
||||||
self.g.game.place_block(self.area, BlockFace.TOP)
|
if self.g.time < 12550:
|
||||||
if not self.silent:
|
return
|
||||||
self.g.chat.send('zzz')
|
|
||||||
self.state = self.sleep_bed
|
if w.check_bed_occupied(self.area):
|
||||||
|
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, 30)
|
threats = w.find_threats(p, 10)
|
||||||
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.break_bed
|
self.state = self.cleanup
|
||||||
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
|
||||||
|
@ -165,7 +182,6 @@ 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)]
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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):
|
||||||
|
@ -42,7 +43,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
|
||||||
|
|
||||||
|
@ -74,7 +75,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)
|
||||||
|
|
||||||
|
@ -116,6 +117,11 @@ 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)
|
||||||
|
|
|
@ -259,6 +259,16 @@ 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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user