Use block state id to check bed occupancy
This commit is contained in:
parent
324ad41bf7
commit
4d2d358175
|
@ -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