Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for e in events:
info = e.split(",")
results.append(ProjectileEvent.Hit(
int(info[0]),
int(info[1]),
int(info[2]),
int(info[3]),
info[4],
info[5]))
return results
def clearEvents(self, *args):
"""Clear the entities events"""
self.conn.send(b"entity.events.clear", intFloor(args))
class CmdPlayer(CmdPositioner):
"""Methods for the host (Raspberry Pi) player"""
def __init__(self, connection):
CmdPositioner.__init__(self, connection, b"player")
self.conn = connection
def getPos(self):
return CmdPositioner.getPos(self, [])
def setPos(self, *args):
return CmdPositioner.setPos(self, [], args)
def getTilePos(self):
return CmdPositioner.getTilePos(self, [])
def setTilePos(self, *args):
return CmdPositioner.setTilePos(self, [], args)
def setDirection(self, *args):
return CmdPositioner.setDirection(self, [], args)
def getDirection(self):
"""get entity rotation (entityId:int) => float"""
return float(self.conn.sendReceive(self.pkg + b".getRotation", id))
def setPitch(self, id, pitch):
"""Set entity pitch (entityId:int, pitch)"""
self.conn.send(self.pkg + b".setPitch", id, pitch)
def getPitch(self, id):
"""get entity pitch (entityId:int) => float"""
return float(self.conn.sendReceive(self.pkg + b".getPitch", id))
def setting(self, setting, status):
"""Set a player setting (setting, status). keys: autojump"""
self.conn.send(self.pkg + b".setting", setting, 1 if bool(status) else 0)
class CmdEntity(CmdPositioner):
"""Methods for entities"""
def __init__(self, connection):
CmdPositioner.__init__(self, connection, b"entity")
def getName(self, id):
"""Get the list name of the player with entity id => [name:str]
Also can be used to find name of entity if entity is not a player."""
return self.conn.sendReceive(b"entity.getName", id)
def getEntities(self, id, distance=10, typeId=-1):
"""Return a list of entities near entity (playerEntityId:int, distanceFromPlayerInBlocks:int, typeId:int) => [[entityId:int,entityTypeId:int,entityTypeName:str,posX:float,posY:float,posZ:float]]"""
"""If distanceFromPlayerInBlocks:int is not specified then default 10 blocks will be used"""
s = self.conn.sendReceive(b"entity.getEntities", id, distance, typeId)
entities = [e for e in s.split("|") if e]
return [ [int(n.split(",")[0]), int(n.split(",")[1]), n.split(",")[2], float(n.split(",")[3]), float(n.split(",")[4]), float(n.split(",")[5])] for n in entities]
def setTilePos(self, *args):
return CmdPositioner.setTilePos(self, [], args)
def setDirection(self, *args):
def setDirection(self, *args):
return CmdPositioner.setDirection(self, [], args)
def getDirection(self):
def getRotation(self):
return CmdPositioner.getRotation(self, [])
def setPitch(self, pitch):
def __init__(self, connection):
CmdPositioner.__init__(self, connection, b"player")
self.conn = connection
def getTilePos(self):
return CmdPositioner.getTilePos(self, [])
def setTilePos(self, *args):
def setPitch(self, pitch):
return CmdPositioner.setPitch(self, [], pitch)
def getPitch(self):
def getTilePos(self):
return CmdPositioner.getTilePos(self, [])
def setTilePos(self, *args):
def getPos(self):
return CmdPositioner.getPos(self, [])
def setPos(self, *args):