Skip to content

Commit

Permalink
Emit old block data on world_block_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjum committed Feb 1, 2016
1 parent 655abc3 commit 3ed914e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions spockbot/plugins/helpers/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,27 @@ def handle_multi_block_change(self, name, packet):
x = block['x'] + chunk_x
z = block['z'] + chunk_z
y = block['y']
self.world.set_block(x, y, z, data=block['block_data'])
old_data = self.world.set_block(x, y, z, data=block['block_data'])
self.event.emit('world_block_update', {
'location': {
'x': x,
'y': y,
'z': z,
},
'block_data': block['block_data'],
'old_data': old_data,
})

def handle_block_change(self, name, packet):
"""Block Change - Update a single block"""
p = packet.data['location']
block_data = packet.data['block_data']
self.world.set_block(p['x'], p['y'], p['z'], data=block_data)
self.event.emit('world_block_update', packet.data)
old_data = self.world.set_block(p['x'], p['y'], p['z'], data=block_data)
self.event.emit('world_block_update', {
'location': p,
'block_data': block_data,
'old_data': old_data,
})

def handle_map_chunk_bulk(self, name, packet):
"""Map Chunk Bulk - Update World state"""
Expand Down

0 comments on commit 3ed914e

Please sign in to comment.