예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 def setTilePos(self, id, *args):
     """Set entity tile position (entityId:int) => Vec3"""
     self.conn.send_flat(self.pkg + ".setTile", id, floorFlatten(*args))
예제 #7
0
 def getBlock(self, *args):
     """Get block (x,y,z) => id:int"""
     return int(self.conn.sendReceive_flat("world.getBlock", floorFlatten(args)))
예제 #8
0
 def getPlayerId(self, *args):
     """Get the id of the current player"""
     return int(self.conn.sendReceive_flat("world.getPlayerId", floorFlatten(args)))
예제 #9
0
 def getHeight(self, *args):
     """Get the height of the world (x,z) => int"""
     return int(self.conn.sendReceive_flat("world.getHeight", floorFlatten(args)))
예제 #10
0
 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:])
예제 #11
0
 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))
예제 #12
0
 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:])
예제 #13
0
 def setBlock(self, *args):
     """Set block (x,y,z,id,[data])"""
     self.conn.send_flat("world.setBlock", floorFlatten(args))
예제 #14
0
 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)))
예제 #15
0
 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]))
예제 #16
0
 def getBlock(self, *args):
     """Get block (x,y,z) => id:int"""
     return int(
         self.conn.sendReceive_flat("world.getBlock", floorFlatten(args)))