Ejemplo n.º 1
0
    def tick(self):
        if self.player.getScoreboardTags().contains('totem'):
            totem_id = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem', None)
            if not totem_id is None:
                for e in self.player.getWorld().getEntities():
                    if e.getEntityId() == totem_id:
                        e.remove()

            holo_id = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem_holo', None)
            if not holo_id is None:
                for e in self.player.getWorld().getEntities():
                    if e.getEntityId() == holo_id:
                        e.remove()

            totem_task = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem_task', None)
            if not totem_task is None:
                Bukkit.getScheduler().cancelTask(totem_task)

        self.player.addScoreboardTag('totem')

        self.sound(Sound.ENTITY_PLAYER_ATTACK_WEAK, .8, .3)
        self.sound(Sound.ENTITY_IRON_GOLEM_HURT, 1, .8)
        if self.clone:
            self.sound(Sound.ENTITY_BLAZE_SHOOT, 1, .9)
            self.sound(Sound.ENTITY_BLAZE_AMBIENT, .1, .7)

        dir = self.player.getEyeLocation().getDirection().clone().setY(
            self.player.getEyeLocation().getDirection().getY())

        totem = self.player.getWorld().spawnEntity(
            self.player.getLocation().clone().add(0, 1, 0).add(dir),
            EntityType.ARMOR_STAND)

        totem.addScoreboardTag('totem')
        totem.setGravity(True)
        totem.setInvulnerable(True)
        totem.setVisible(True)

        totem_item = ItemStack(Material.STONE_SHOVEL)
        totem_meta = totem_item.getItemMeta()
        totem_meta.setUnbreakable(True)
        totem_meta.setDamage(29 if self.clone else 28)
        totem_item.setItemMeta(totem_meta)

        totem.getEquipment().setHelmet(totem_item)

        totem.setVelocity(dir.setY(1))

        PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player),
                                 'totem', totem.getEntityId())

        self.castSpell('SHAMAN', 5, totem, None, False)
Ejemplo n.º 2
0
    def tick(self):
        if self.t == 0 and self.player.getScoreboardTags().contains('totem'):
            # Find totem
            totem = None
            totem_id = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem', None)
            for e in self.player.getWorld().getEntities():
                if e.getEntityId() == totem_id:
                    totem = e

            if totem is None:
                self.t += 1
                return

            # Reset Totem
            totem_loc = totem.getLocation()
            totem.remove()

            holo_id = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem_holo', None)
            if not holo_id is None:
                for e in self.player.getWorld().getEntities():
                    if e.getEntityId() == holo_id:
                        e.remove()

            task_id = PersistentDataAPI.getInt(
                PersistentDataAPI.getData(self.player), 'totem_task', None)
            if not task_id is None:
                Bukkit.getScheduler().cancelTask(task_id)

            totem = self.player.getWorld().spawnEntity(totem_loc,
                                                       EntityType.ARMOR_STAND)
            totem.setGravity(True)
            totem.setInvulnerable(True)
            totem.setVisible(True)
            totem.addScoreboardTag('totem')

            totem_item = ItemStack(Material.STONE_SHOVEL)
            totem_meta = totem_item.getItemMeta()
            totem_meta.setUnbreakable(True)
            totem_meta.setDamage(29 if self.clone else 28)
            totem_item.setItemMeta(totem_meta)

            totem.getEquipment().setHelmet(totem_item)

            PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player),
                                     'totem', totem.getEntityId())

            holo = self.player.getWorld().spawnEntity(
                totem.getLocation().clone().add(0, 2.7, 0),
                EntityType.ARMOR_STAND)
            holo.setMarker(True)
            holo.setVisible(False)
            holo.setInvulnerable(True)
            holo.setCustomName(PySpell.colorText('20s', 'c'))
            holo.setCustomNameVisible(True)

            PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player),
                                     'totem_holo', holo.getEntityId())

            self.castSpell('SHAMAN', 5, totem, holo, True)

        v = self.player.getEyeLocation().getDirection()
        vr = Vector(1, 0, 0) if v.getY() == 0 else (
            v.clone().setY(0).normalize().rotateAroundY(Math.PI / 2))
        vi = v.clone().rotateAroundAxis(vr, Math.PI / 2)

        l = self.player.getEyeLocation().clone().add(v.clone().multiply(
            self.t))

        if self.t < 20:
            self.catch_mobs = self.catchable_mobs(l)
            if self.catch_mobs.size() > 0:
                self.catch(l, v, vi)
                self.cancel()

            l1 = l.clone().add(vi.clone().multiply(2).rotateAroundAxis(
                v, self.t / 4))
            l2 = l.clone().add(vi.clone().multiply(2).rotateAroundAxis(
                v, (self.t / 4) + Math.PI))

            self.particle(
                l1, Particle.FIREWORKS_SPARK if self.clone else Particle.TOTEM,
                2, 0, 0, 0, .1)
            self.particle(
                l2, Particle.FIREWORKS_SPARK if self.clone else Particle.TOTEM,
                2, 0, 0, 0, .1)

            self.sound(l, Sound.BLOCK_LAVA_EXTINGUISH, .1, .7)
        else:
            self.catch(l, v, vi)