class BlockUpdatePacket:
    def __init__(self, block):
        self.packet = WritePacket(5)
        self.packet.write_int(block.globalpos[0])
        self.packet.write_int(block.globalpos[1])
        self.packet.write_int(block.globalpos[2])
        self.packet.write_byte(BLOCKS[block.type])

    def send_to(self, client):
        client.send(self.packet.get_bytes())
class SpawnEntityPacket:
    def __init__(self, entity):
        self.packet = WritePacket(6)
        self.packet.write_int(entity.id)
        self.packet.write_byte(ENTITIES[entity.type])
        self.packet.write_float(entity.pos[0])
        self.packet.write_float(entity.pos[1])
        self.packet.write_float(entity.pos[2])
        self.packet.write_float(entity.dir[0])
        self.packet.write_float(entity.dir[1])

    def send_to(self, client):
        client.send(self.packet.get_bytes())