Exemplo n.º 1
0
  protected void aJ() {
    Iterator iterator = this.effects.keySet().iterator();

    while (iterator.hasNext()) {
      Integer integer = (Integer) iterator.next();
      MobEffect mobeffect = (MobEffect) this.effects.get(integer);

      if (!mobeffect.tick(this)) {
        if (!this.world.isStatic) {
          iterator.remove();
          this.b(mobeffect);
        }
      } else if (mobeffect.getDuration() % 600 == 0) {
        this.a(mobeffect, false);
      }
    }

    int i;

    if (this.updateEffects) {
      if (!this.world.isStatic) {
        if (this.effects.isEmpty()) {
          this.datawatcher.watch(8, Byte.valueOf((byte) 0));
          this.datawatcher.watch(7, Integer.valueOf(0));
          this.setInvisible(false);
        } else {
          i = PotionBrewer.a(this.effects.values());
          this.datawatcher.watch(
              8, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0)));
          this.datawatcher.watch(7, Integer.valueOf(i));
          this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id));
        }
      }

      this.updateEffects = false;
    }

    i = this.datawatcher.getInt(7);
    boolean flag = this.datawatcher.getByte(8) > 0;

    if (i > 0) {
      boolean flag1 = false;

      if (!this.isInvisible()) {
        flag1 = this.random.nextBoolean();
      } else {
        flag1 = this.random.nextInt(15) == 0;
      }

      if (flag) {
        flag1 &= this.random.nextInt(5) == 0;
      }

      if (flag1 && i > 0) {
        double d0 = (double) (i >> 16 & 255) / 255.0D;
        double d1 = (double) (i >> 8 & 255) / 255.0D;
        double d2 = (double) (i >> 0 & 255) / 255.0D;

        this.world.addParticle(
            flag ? "mobSpellAmbient" : "mobSpell",
            this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width,
            this.locY + this.random.nextDouble() * (double) this.length - (double) this.height,
            this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width,
            d0,
            d1,
            d2);
      }
    }
  }
Exemplo n.º 2
0
 private int b(int i, ItemStack itemstack) {
   return itemstack == null
       ? i
       : (Item.byId[itemstack.id].u() ? PotionBrewer.a(i, Item.byId[itemstack.id].t()) : i);
 }