Esempio n. 1
0
class Entity(object):
    id = None
    tagid = None
    alive = True
    visible = True
    invulnerable = False
    despawn = False
    age = 0

    def __init__(self):
        self.loc = Location(0, 0, 0)
        self.velo = Velocity(0, 0, 0)
        self.rotation = Orientation(0, 0)
        self.pos = Position()
        self.pos.onLoad(self)

    def getChunk(self):
        return (int(self.loc.x) >> 4, int(self.loc.z) >> 4)

    def loadFromNbt(self, nbt):
        self.tag = nbt

        # Location/Orientation/Velocity stuff
        self.loc.loadFromNbt(nbt['Pos'])
        self.velo.loadFromNbt(nbt['Motion'])
        self.rotation.loadFromNbt(nbt['Rotation'])

        # Load Hybrid Position Holder
        self.pos.onLoad(self)

        # Static Tags
        self.fall_distance = Tag("FallDistance", TAG_Float, 0)
        self.fire_time = Tag("Fire", TAG_Short, 0)
        self.air_time = Tag("Air", TAG_Short, 0)
        self.invulnerable = Tag("Invulnerable", TAG_Byte, 0)
        self.onGround = Tag("OnGround", TAG_Byte, 0)
        self.name = Tag("CustomName", TAG_String, "")

    def saveToNbt(self):
        return self.tag
Esempio n. 2
0
 def __init__(self):
     self.loc = Location(0, 0, 0)
     self.velo = Velocity(0, 0, 0)
     self.rotation = Orientation(0, 0)
     self.pos = Position()
     self.pos.onLoad(self)