Пример #1
0
 public void levelUp() {
   if (getLevel() != 3) {
     worldObj.playSoundAtEntity(this, "random.levelup", 0.75F, 1.0F);
     Utils.spawnParticlesAroundEntityS(Particle.REDSTONE, this, 16);
     setLevel(getLevel() + 1);
   }
 }
Пример #2
0
  private void updateAbility() {
    if (!worldObj.isRemote) {
      abilityCounter--;

      if (abilityCounter <= 0) {
        // Boom spider throws a boom ball.
        if (spiderType == EnumSpiderType.BOOM && target != null) {
          EntityBoomBall boomBall = new EntityBoomBall(this, target, 2.5F);
          worldObj.spawnEntityInWorld(boomBall);
        }

        // Slinger spider throws a web shot.
        else if (spiderType == EnumSpiderType.SLINGER && target != null) {
          EntityWebShot webShot = new EntityWebShot(this, target, 2.5F);
          worldObj.spawnEntityInWorld(webShot);

          worldObj.playSoundAtEntity(this, "random.bow", 0.75F, 1.0F);
        }

        // Nova spider heals nearby spiders.
        else if (spiderType == EnumSpiderType.NOVA && RadixLogic.getBooleanWithProbability(20)) {
          EntitySpiderEx spider =
              (EntitySpiderEx)
                  RadixLogic.getNearestEntityOfTypeWithinDistance(EntitySpiderEx.class, this, 8);

          if (spider != null && spider.getHealth() < spider.getMaxHealth()) {
            int healthIncrease = getLevel() * 5;
            spider.setHealth(healthIncrease);
            Utils.spawnParticlesAroundEntityS("heart", this, 6);
            Utils.spawnParticlesAroundEntityS("heart", spider, 6);
          }
        }

        // Ender spider throws targets into the air.
        else if (spiderType == EnumSpiderType.ENDER && target != null) {
          if (worldObj.canBlockSeeTheSky((int) posX, (int) posY, (int) posZ)) {
            Utils.spawnParticlesAroundEntityS(Particle.PORTAL, this, 6);
            target.motionY = 1.0F + (0.3F * getLevel());

            target.motionX =
                rand.nextBoolean()
                    ? rand.nextDouble()
                    : rand.nextBoolean() ? rand.nextDouble() * -1 : 0;
            target.motionZ =
                rand.nextBoolean()
                    ? rand.nextDouble()
                    : rand.nextBoolean() ? rand.nextDouble() * -1 : 0;

            if (getLevel() == 3) {
              target.motionX = target.motionX > 0 ? target.motionX + 2.0F : target.motionX - 2.0F;
              target.motionZ = target.motionZ > 0 ? target.motionZ + 2.0F : target.motionZ - 2.0F;
            }

            worldObj.playSoundAtEntity(target, "mob.endermen.portal", 1.0F, 1.0F);

            Utils.spawnParticlesAroundEntityS(Particle.PORTAL, target, 6);
          }
        }

        abilityCounter = abilityThreshold;
      }
    }
  }