def getBlockWithNBT(self, *args): """ Get block with data and nbt (x,y,z) => Block (if no NBT) or (Block,nbt) For this to work, you first need to do setting("include_nbt_with_data",1) """ if not self.enabledNBT: self.setting("include_nbt_with_data",1) self.enabledNBT = True try: ans = self.conn.sendReceive_flat("world.getBlockWithData", floorFlatten(args)) except RequestError: # retry in case we had a Fail from the setting ans = self.conn.receive() else: ans = self.conn.sendReceive_flat("world.getBlockWithData", floorFlatten(args)) id,data = (map(int, ans.split(",")[:2])) commas = 0 for i in range(0,len(ans)): if ans[i] == ',': commas += 1 if commas == 2: if '{' in ans[i+1:]: return Block(id,data,ans[i+1:]) else: break return Block(id,data)
def getBlockWithNBT(self, *args): """ Get block with data and nbt (x,y,z) => Block (if no NBT) or (Block,nbt) For this to work, you first need to do setting("include_nbt_with_data",1) """ if not self.enabledNBT: self.setting("include_nbt_with_data",1) self.enabledNBT = True try: ans = self.conn.sendReceive_flat("world.getBlockWithData", floorFlatten(args)) except RequestError: # retry in case we had a Fail from the setting ans = self.conn.receive() else: ans = self.conn.sendReceive_flat("world.getBlockWithData", floorFlatten(args)) return stringToBlockWithNBT(ans)
def getBlocksWithData(self, *args): """Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [Block(id:int, meta:int)]""" try: ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args)) return [Block(*map(int, x.split(",")[:2])) for x in ans.split("|")] except: self.getBlocksWithData = self.fallbackGetBlocksWithData return self.fallbackGetBlocksWithData(*args)
def getBlocksWithNBT(self, *args): """Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [Block(id, meta, nbt)]""" try: if not self.enabledNBT: self.setting("include_nbt_with_data",1) self.enabledNBT = True try: ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args)) except RequestError: # retry in case we had a Fail from the setting ans = self.conn.receive() else: ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args)) ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args)) return [stringToBlockWithNBT(x, pipeFix = True) for x in ans.split("|")] except: self.getBlocksWithNBT = self.fallbackGetBlocksWithNBT return self.fallbackGetBlocksWithNBT(*args)
def getBlocks(self, *args): """ Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [id:int] Packed with a y-loop, x-loop, z-loop, in this order. """ try: ans = self.conn.sendReceive_flat("world.getBlocks", floorFlatten(args)) return map(int, ans.split(",")) except: self.getBlocks = self.fallbackGetBlocks return self.fallbackGetBlocks(*args)
def setTilePos(self, id, *args): """Set entity tile position (entityId:int) => Vec3""" self.conn.send_flat(self.pkg + ".setTile", id, floorFlatten(*args))
def getBlock(self, *args): """Get block (x,y,z) => id:int""" return int(self.conn.sendReceive_flat("world.getBlock", floorFlatten(args)))
def getPlayerId(self, *args): """Get the id of the current player""" return int(self.conn.sendReceive_flat("world.getPlayerId", floorFlatten(args)))
def getHeight(self, *args): """Get the height of the world (x,z) => int""" return int(self.conn.sendReceive_flat("world.getHeight", floorFlatten(args)))
def setBlocksWithNBT(self, *args): """Set a cuboid of blocks (x0,y0,z0,x1,y1,z1,id,data,nbt)""" data = list(flatten(args)) self.conn.send_flat("world.setBlocks", list(floorFlatten(data[:8]))+data[8:])
def setBlocks(self, *args): """Set a cuboid of blocks (x0,y0,z0,x1,y1,z1,id,[data])""" self.conn.send_flat("world.setBlocks", floorFlatten(args))
def setBlockWithNBT(self, *args): """Set block (x,y,z,id,data,nbt)""" data = list(flatten(args)) self.conn.send_flat("world.setBlock", list(floorFlatten(data[:5]))+data[5:])
def setBlock(self, *args): """Set block (x,y,z,id,[data])""" self.conn.send_flat("world.setBlock", floorFlatten(args))
def getBlocks(self, *args): """Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [id:int]""" return int(self.conn.sendReceive_flat("world.getBlocks", floorFlatten(args)))
def getBlockWithData(self, *args): """Get block with data (x,y,z) => Block""" ans = self.conn.sendReceive_flat("world.getBlockWithData", floorFlatten(args)) return Block(*map(int, ans.split(",")[:2]))
def getBlock(self, *args): """Get block (x,y,z) => id:int""" return int( self.conn.sendReceive_flat("world.getBlock", floorFlatten(args)))