def login(self): # Login Packet pk = Packet("login") pk.eid = self.entity.id pk.leveltype = "default" pk.mode = "survival" pk.dimension = "earth" pk.difficulty = "normal" pk.unused = 0 pk.maxplayers = self.server.max_players self.client.write(pk) # Tell the game we have joined self.game.playerJoin(self) # Preload Chunks in a 10x10 around the player self.loadChunkArea(5, 5) # Compass pk = Packet("compass") if self.entity.spawn: pk.x, pk.y, pk.z = self.entity.spawn else: pk.x, pk.y, pk.z = (0, 64, 0) self.client.write(pk) # Position reset self.pos.x = 0 self.pos.loc.y = 64 #64 self.pos.z = 0 self.client.write(self.getLocPak()) # Spawn the player in # Load a larger area for el playero self.game.tm.run(self.loadChunkArea, 10, 10)
def getSpawnPacket(self): p = Packet("spawn") p.eid = self.id p.type = self.entity_type p.x = self.loc.x p.y = self.loc.y p.z = self.loc.z p.pitch = self.rotation.pitch p.yaw = self.rotation.yaw p.data = 1 p.speedx = self.velo.x p.speedz = self.velo.z p.speedy = self.velo.y return p