def getPacket(self): #@TODO Support section-packets to save bandwith? inf = [] if self.c.dirty: self.world.level.generateLights() for y in range(0, 256, 16): Blocks = self.c.Blocks[..., y:y + 16].swapaxes(0, 2) inf.append(array(Blocks, 'uint8').tostring()) for y in range(0, 256, 16): Data = self.c.Data[..., y:y + 16].swapaxes(0, 2) inf.append(array(packNibbleArray(Data)).tostring()) for y in range(0, 256, 16): BlockLight = self.c.BlockLight[..., y:y + 16].swapaxes(0, 2) inf.append(array(packNibbleArray(BlockLight)).tostring()) for y in range(0, 256, 16): SkyLight = self.c.SkyLight[..., y:y + 16].swapaxes(0, 2) inf.append(array(packNibbleArray(SkyLight)).tostring()) inf.append("\x00" * 256) #@TODO biome data p = Packet("chunk") p.x, p.z = self.pos p.continuous = True p.primary = 65535 #@TODO LOL STATIC FTW p.add = 0x0 p.data = "".join(inf) return p
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