Compare commits
3 Commits
324ad41bf7
...
261684ea90
Author | SHA1 | Date | |
---|---|---|---|
261684ea90 | |||
09b09b3f96 | |||
4d2d358175 |
|
@ -23,7 +23,7 @@ class Commands:
|
|||
|
||||
def handle_chat(self, message):
|
||||
source, sender, text = message
|
||||
reply = None
|
||||
reply = ''
|
||||
private = False
|
||||
for_me = False
|
||||
authed = sender == '0c123cfa-1697-4427-9413-4b645dee7ec0'
|
||||
|
@ -244,23 +244,67 @@ class Commands:
|
|||
tree = next(self.g.world.find_trees(pos, 50))
|
||||
reply = str(tree)[1:-1]
|
||||
|
||||
## !block x y z - replies what block is at (x, y, z)
|
||||
if command == 'block':
|
||||
try:
|
||||
data = data.replace('(', ' ').replace(')', ' ').replace(',', ' ')
|
||||
x1, y1, z1 = [int(x) for x in data.split()]
|
||||
except (AttributeError, ValueError):
|
||||
reply = 'usage: !block x1 y1 z1'
|
||||
|
||||
## !info [query] - replies with info on a coordinate, block, item, or player
|
||||
if command == 'info':
|
||||
if not reply:
|
||||
try:
|
||||
check = data.replace('(', ' ').replace(')', ' ').replace(',', ' ')
|
||||
x1, y1, z1 = [int(x) for x in check.split()]
|
||||
coord = (x1, y1, z1)
|
||||
block = self.g.world.block_at(*coord)
|
||||
|
||||
if not reply and block is None:
|
||||
reply = 'first coord out of range'
|
||||
reply = 'coord out of range'
|
||||
|
||||
if not reply:
|
||||
reply = blocks.BLOCKS[block] + ':' + str(block)
|
||||
reply = 'Block: ' + blocks.BLOCKS[block] + ':' + str(block)
|
||||
if blocks.PROPS[block]:
|
||||
reply += ' - ' + ', '.join(['{}:{}'.format(k, v) for k, v in blocks.PROPS[block].items()])
|
||||
except (AttributeError, ValueError):
|
||||
pass
|
||||
|
||||
if not reply:
|
||||
try:
|
||||
check = int(data)
|
||||
|
||||
if check in blocks.BLOCKS:
|
||||
block = check
|
||||
reply += 'Block: ' + blocks.BLOCKS[block] + ':' + str(block)
|
||||
if blocks.PROPS[block]:
|
||||
reply += ' - ' + ', '.join(['{}:{}'.format(k, v) for k, v in blocks.PROPS[block].items()])
|
||||
|
||||
if check in blocks.BLOCKS and check in items.ITEM_NAMES:
|
||||
reply += ' / '
|
||||
|
||||
if check in items.ITEM_NAMES:
|
||||
item = check
|
||||
reply += 'Item: ' + items.ITEM_NAMES[item] + ':' + str(item)
|
||||
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
check = data.lower()
|
||||
if not reply and check in self.g.player_names:
|
||||
uuid = self.g.player_names[check]
|
||||
|
||||
for p in self.g.players.values():
|
||||
if p.player_uuid == uuid:
|
||||
player = p
|
||||
break
|
||||
else: # for
|
||||
reply = 'player out of range'
|
||||
|
||||
if not reply:
|
||||
reply += 'Player: '
|
||||
|
||||
results = []
|
||||
for k, v in player.items():
|
||||
try:
|
||||
results.append('{}:{}'.format(k, int(v)))
|
||||
except ValueError:
|
||||
results.append('{}:{}'.format(k, str(v)))
|
||||
|
||||
reply += ', '.join(results)
|
||||
|
||||
|
||||
################# Specific commands ##########################
|
||||
|
|
|
@ -49,6 +49,7 @@ class Game:
|
|||
register(self.handle_spawn_living, SpawnLivingEntityPacket)
|
||||
register(self.handle_entity_position, clientbound.play.EntityPositionDeltaPacket)
|
||||
register(self.handle_entity_position_rotation, EntityPositionRotationPacket)
|
||||
register(self.handle_entity_look, clientbound.play.EntityLookPacket)
|
||||
register(self.handle_destroy_entities, DestroyEntitiesPacket)
|
||||
register(self.handle_spawn_player, clientbound.play.SpawnPlayerPacket)
|
||||
register(self.handle_respawn, clientbound.play.RespawnPacket)
|
||||
|
@ -442,8 +443,14 @@ class Game:
|
|||
player.x += packet.delta_x / 4096.0
|
||||
player.y += packet.delta_y / 4096.0
|
||||
player.z += packet.delta_z / 4096.0
|
||||
player.yaw = packet.yaw
|
||||
player.pitch = packet.pitch
|
||||
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
def handle_entity_look(self, packet):
|
||||
player = self.g.players.get(packet.entity_id, None)
|
||||
if player:
|
||||
player.yaw = packet.yaw
|
||||
player.pitch = packet.pitch
|
||||
|
||||
def handle_entity_teleport(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
|
@ -493,7 +500,8 @@ class Game:
|
|||
for action in packet.actions:
|
||||
if isinstance(action, packet.AddPlayerAction):
|
||||
self.g.player_names[action.uuid] = action.name
|
||||
self.g.player_names[action.name] = action.uuid # porque no los dos?
|
||||
self.g.player_names[action.name] = action.uuid
|
||||
self.g.player_names[action.name.lower()] = action.uuid # porque no los dos?
|
||||
|
||||
def handle_update_health(self, packet):
|
||||
print(packet)
|
||||
|
|
|
@ -15,6 +15,11 @@ for name, data in JSON_BLOCKS.items():
|
|||
for state in data['states']:
|
||||
BLOCKS[state['id']] = name.replace('minecraft:', '')
|
||||
|
||||
PROPS = {}
|
||||
for name, data in JSON_BLOCKS.items():
|
||||
for state in data['states']:
|
||||
PROPS[state['id']] = state.get('properties', {})
|
||||
|
||||
BREAK_DISTANCE = 6
|
||||
|
||||
AIR = 0
|
||||
|
|
|
@ -139,6 +139,14 @@ class SleepWithBedStates:
|
|||
print('Placing bed')
|
||||
self.g.game.place_block(self.area, BlockFace.TOP)
|
||||
self.my_bed = True
|
||||
self.wait_time = 0.5
|
||||
self.state = self.wait_use
|
||||
|
||||
def wait_use(self):
|
||||
# wait to use the bed
|
||||
if self.wait_time > 0:
|
||||
self.wait_time -= utils.TICK
|
||||
else:
|
||||
self.state = self.use_bed
|
||||
|
||||
def use_bed(self):
|
||||
|
|
|
@ -280,12 +280,12 @@ class World:
|
|||
|
||||
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])
|
||||
bid = self.g.chunks.get_block_at(*bed)
|
||||
if blocks.PROPS[bid]['occupied'] == 'true':
|
||||
print('Checking bed occupancy:', bed, '-> occupied')
|
||||
return True
|
||||
else:
|
||||
print('Checking bed occupancy:', bed, '-> free')
|
||||
return False
|
||||
|
||||
def find_cache_openings(self, area):
|
||||
|
|
Loading…
Reference in New Issue
Block a user