예제 #1
0
class RemoveEntityPacket:
    def __init__(self, entity):
        self.packet = WritePacket(7)
        self.packet.write_int(entity.id)

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #2
0
class ChatPacket:
    def __init__(self, message):
        self.packet = WritePacket(3)
        self.packet.write_string(message)

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #3
0
class KickPacket:
    def __init__(self, reason):
        self.packet = WritePacket(2)
        self.packet.write_string(reason)

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #4
0
 def __init__(self):
     self.packet = WritePacket(1)
     self.packet.write_float(DEFAULT_SPAWN_POS[0])
     self.packet.write_float(DEFAULT_SPAWN_POS[1])
     self.packet.write_float(DEFAULT_SPAWN_POS[2])
     self.packet.write_float(DEFAULT_DIR[0])
     self.packet.write_float(DEFAULT_DIR[1])
예제 #5
0
class LoginSuccessPacket:
    def __init__(self, client):
        self.packet = WritePacket(0)
        self.packet.write_int(client.id)
        self.packet.write_int((client.view_distance * 2)**3)

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #6
0
 def __init__(self, chunk):
     self.packet = WritePacket(4)
     self.packet.write_int(chunk.pos[0])
     self.packet.write_int(chunk.pos[1])
     self.packet.write_int(chunk.pos[2])
     blocks = []
     for block in chunk.blocks:
         blocks.append(BLOCKS[block.type])
     self.packet.write_bytes(blocks)
예제 #7
0
 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])
예제 #8
0
 def __init__(self, entity, imperative):
     self.packet = WritePacket(8)
     self.packet.write_int(entity.id)
     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])
     self.imperative = imperative
예제 #9
0
class EntityMovementPacket:
    def __init__(self, entity, imperative):
        self.packet = WritePacket(8)
        self.packet.write_int(entity.id)
        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])
        self.imperative = imperative

    def send_to(self, client):
        client.send(self.packet.get_bytes(), self.imperative)
예제 #10
0
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())
예제 #11
0
class JoinWorldPacket:
    def __init__(self):
        self.packet = WritePacket(1)
        self.packet.write_float(DEFAULT_SPAWN_POS[0])
        self.packet.write_float(DEFAULT_SPAWN_POS[1])
        self.packet.write_float(DEFAULT_SPAWN_POS[2])
        self.packet.write_float(DEFAULT_DIR[0])
        self.packet.write_float(DEFAULT_DIR[1])

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #12
0
class ChunkUpdatePacket:
    def __init__(self, chunk):
        self.packet = WritePacket(4)
        self.packet.write_int(chunk.pos[0])
        self.packet.write_int(chunk.pos[1])
        self.packet.write_int(chunk.pos[2])
        blocks = []
        for block in chunk.blocks:
            blocks.append(BLOCKS[block.type])
        self.packet.write_bytes(blocks)

    def send_to(self, client):
        client.send(self.packet.get_bytes())
예제 #13
0
 def __init__(self, reason):
     self.packet = WritePacket(2)
     self.packet.write_string(reason)
예제 #14
0
 def __init__(self, entity):
     self.packet = WritePacket(7)
     self.packet.write_int(entity.id)
예제 #15
0
 def __init__(self, message):
     self.packet = WritePacket(3)
     self.packet.write_string(message)
예제 #16
0
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())
예제 #17
0
 def __init__(self, client):
     self.packet = WritePacket(0)
     self.packet.write_int(client.id)
     self.packet.write_int((client.view_distance * 2)**3)
예제 #18
0
 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])