Exemplo n.º 1
0
    def __init__(self,
                 app,
                 creative: bool = False,
                 tag: Optional[nbt.TAG_Compound] = None):
        self.dimension = 'minecraft:overworld'

        # FIXME: ID
        super().__init__(app, 1, 'player', 0.0, 0.0, 0.0, nbt=tag)

        self.reach = 4.0

        self.creative = creative
        self.flying = False

        self.portalCooldown = 80

        if self.creative:
            if len(app.itemTextures) > 36:
                # TODO:
                1 / 0

            self.inventory = [
                Slot(stack=Stack(name, -1)) for name in app.itemTextures
            ]

            while len(self.inventory) < 36:
                self.inventory.append(Slot(stack=Stack('', 0)))
        else:
            self.inventory = [Slot() for _ in range(36)]

        if tag is not None:
            for stackTag in tag["Inventory"]:
                (stack, slotIdx) = Stack.fromNbt(stackTag, getSlot=True)
                self.inventory[slotIdx].stack = stack

            gameMode = tag['playerGameType'].value
            if gameMode == 0:
                self.creative = False
            elif gameMode == 1:
                self.creative = True
            else:
                raise Exception(f'Invalid game mode {gameMode}')

            self.flying = tag['abilities']['flying'].value != 0

            self.dimension = tag['dimension'].value
Exemplo n.º 2
0
 def fromNbt(self, tag: nbt.TAG_Compound):
     self.age = tag['Age'].value
     self.pickupDelay = tag['PickupDelay'].value
     self.stack = Stack.fromNbt(tag['Item'])