Example #1
0
  /** Displays debuff/potion effects that are currently being applied to the player */
  private void displayDebuffEffects() {
    int var1 = this.guiLeft - 124;
    int var2 = this.guiTop;
    Collection var4 = this.mc.thePlayer.getActivePotionEffects();

    if (!var4.isEmpty()) {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glDisable(GL11.GL_LIGHTING);
      int var6 = 33;

      if (var4.size() > 5) {
        var6 = 132 / (var4.size() - 1);
      }

      for (Iterator var7 = this.mc.thePlayer.getActivePotionEffects().iterator();
          var7.hasNext();
          var2 += var6) {
        PotionEffect var8 = (PotionEffect) var7.next();
        Potion var9 =
            Potion.potionTypes[var8.getPotionID()] instanceof TFCPotion
                ? ((TFCPotion) Potion.potionTypes[var8.getPotionID()])
                : Potion.potionTypes[var8.getPotionID()];
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.func_110434_K().func_110577_a(field_110408_a);
        this.drawTexturedModalRect(var1, var2, 0, 166, 140, 32);

        if (var9.hasStatusIcon()) {
          int var10 = var9.getStatusIconIndex();
          this.drawTexturedModalRect(
              var1 + 6, var2 + 7, 0 + var10 % 8 * 18, 198 + var10 / 8 * 18, 18, 18);
        }

        String var12 = StatCollector.translateToLocal(var9.getName());

        if (var8.getAmplifier() == 1) {
          var12 = var12 + " II";
        } else if (var8.getAmplifier() == 2) {
          var12 = var12 + " III";
        } else if (var8.getAmplifier() == 3) {
          var12 = var12 + " IV";
        }

        this.fontRenderer.drawStringWithShadow(var12, var1 + 10 + 18, var2 + 6, 16777215);
        String var11 = Potion.getDurationString(var8);
        this.fontRenderer.drawStringWithShadow(var11, var1 + 10 + 18, var2 + 6 + 10, 8355711);
      }
    }
  }
  @Override
  protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
    if (!this.worldObj.isRemote
        && potionStack.getItem() != null
        && potionStack.getItem() instanceof ItemPotion) {
      @SuppressWarnings("unchecked")
      List<PotionEffect> effectList = ((ItemPotion) potionStack.getItem()).getEffects(potionStack);

      if (effectList != null && !effectList.isEmpty()) {
        AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
        @SuppressWarnings("unchecked")
        List<EntityLivingBase> entityList =
            this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

        if (entityList != null && !entityList.isEmpty()) {
          Iterator<EntityLivingBase> iterator = entityList.iterator();

          while (iterator.hasNext()) {
            EntityLivingBase entityliving = iterator.next();
            double squareDistance = this.getDistanceSqToEntity(entityliving);

            if (squareDistance < 16.0D) {
              double distanceFactor = 1.0D - Math.sqrt(squareDistance) / 4.0D;

              if (entityliving == par1MovingObjectPosition.entityHit) {
                distanceFactor = 1.0D;
              }

              Iterator<PotionEffect> iterator1 = effectList.iterator();

              while (iterator1.hasNext()) {
                PotionEffect potioneffect = iterator1.next();
                int potionID = potioneffect.getPotionID();

                if (Potion.potionTypes[potionID].isInstant()) {
                  Potion.potionTypes[potionID].affectEntity(
                      this.getThrower(), entityliving, potioneffect.getAmplifier(), distanceFactor);
                } else {
                  int potionDuration = (int) (distanceFactor * potioneffect.getDuration() + 0.5D);

                  if (potionDuration > 20) {
                    entityliving.addPotionEffect(
                        new PotionEffect(potionID, potionDuration, potioneffect.getAmplifier()));
                  }
                }
              }
            }
          }
        }
      }

      this.worldObj.playAuxSFX(
          2002,
          (int) Math.round(this.posX),
          (int) Math.round(this.posY),
          (int) Math.round(this.posZ),
          potionStack.getItemDamage());
      this.setDead();
    }
  }
 @Override
 public String getName() {
   switch (handle.getPotionID()) {
     case 1:
       return "SPEED";
     case 2:
       return "SLOW";
     case 3:
       return "FAST_DIGGING";
     case 4:
       return "SLOW_DIGGING";
     case 5:
       return "INCREASE_DAMAGE";
     case 6:
       return "HEAL";
     case 7:
       return "HARM";
     case 8:
       return "JUMP";
     case 9:
       return "CONFUSION";
     case 10:
       return "REGENERATION";
     case 11:
       return "DAMAGE_RESISTANCE";
     case 12:
       return "FIRE_RESISTANCE";
     case 13:
       return "WATER_BREATHING";
     case 14:
       return "INVISIBILITY";
     case 15:
       return "BLINDNESS";
     case 16:
       return "NIGHT_VISION";
     case 17:
       return "HUNGER";
     case 18:
       return "WEAKNESS";
     case 19:
       return "POISON";
     default:
       return "UNKNOWN_EFFECT_TYPE_" + handle.getPotionID();
   }
 }
  public Packet41EntityEffect(int par1, PotionEffect par2PotionEffect) {
    this.entityId = par1;
    this.effectId = (byte) (par2PotionEffect.getPotionID() & 255);
    this.effectAmplifier = (byte) (par2PotionEffect.getAmplifier() & 255);

    if (par2PotionEffect.getDuration() > 32767) {
      this.duration = 32767;
    } else {
      this.duration = (short) par2PotionEffect.getDuration();
    }
  }
  private void renderPotions() {
    GL11.glPushMatrix();
    int var1 = Resilience.getInstance().getValues().enabledModsEnabled ? 76 : 1;
    int var2 = 0;
    boolean var3 = true;
    Collection var4 = wrapper.getPlayer().getActivePotionEffects();

    if (!var4.isEmpty()) {
      ResourceLocation rL = new ResourceLocation("textures/gui/container/inventory.png");
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glDisable(GL11.GL_LIGHTING);
      int var5 = 33;

      if (var4.size() > 5) {
        var5 = 132 / (var4.size() - 1);
      }

      for (Iterator var6 = wrapper.getPlayer().getActivePotionEffects().iterator();
          var6.hasNext();
          var2 += var5) {
        PotionEffect var7 = (PotionEffect) var6.next();
        Potion var8 = Potion.potionTypes[var7.getPotionID()];
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        wrapper.getMinecraft().getTextureManager().bindTexture(rL);
        // this.drawTexturedModalRect(var1, var2, 0, 166, 140, 32);

        if (var8.hasStatusIcon()) {
          int var9 = var8.getStatusIconIndex();
          this.drawTexturedModalRect(
              var1 + 6, var2 + 7, 0 + var9 % 8 * 18, 198 + var9 / 8 * 18, 18, 18);
        }

        String var11 = I18n.format(var8.getName(), new Object[0]);

        if (var7.getAmplifier() == 1) {
          var11 = var11 + " II";
        } else if (var7.getAmplifier() == 2) {
          var11 = var11 + " III";
        } else if (var7.getAmplifier() == 3) {
          var11 = var11 + " IV";
        }

        wrapper.getFontRenderer().drawStringWithShadow(var11, var1 + 10 + 18, var2 + 6, 16777215);
        String var10 = Potion.getDurationString(var7);
        wrapper
            .getFontRenderer()
            .drawStringWithShadow(var10, var1 + 10 + 18, var2 + 6 + 10, 8355711);
      }
    }
    GL11.glPopMatrix();
  }
  public int amplifyEffect(EntityPlayer player, Potion potion) {
    PotionEffect eff = player.getActivePotionEffect(potion);
    if (eff != null) {
      int max = 1;
      max = 6;
      int newAmp = eff.getAmplifier();
      int newDur = eff.getDuration();
      if (newAmp < max) {
        newAmp++;
      }
      newDur += 500;
      eff.combine(new PotionEffect(eff.getPotionID(), newDur, newAmp));

      return newAmp;
    }

    player.addPotionEffect(new PotionEffect(potion.id, 300, 0));
    return 1;
  }
Example #7
0
  /**
   * Renders the duration any potion effects that the player currently has on the left side of the
   * screen.
   */
  public static void RenderOntoHUD() {
    // if the player is in the world
    // and not in a menu (except for chat and the custom Options menu)
    // and F3 not shown
    if (PotionTimers.Enabled && mc.inGameHasFocus
        || (mc.currentScreen != null
                && (mc.currentScreen instanceof GuiChat || TabIsSelectedInOptionsGui()))
            && !mc.gameSettings.showDebugInfo) {
      Collection potionEffects =
          mc.thePlayer.getActivePotionEffects(); // key:potionId, value:potionEffect
      Iterator it = potionEffects.iterator();

      int x = potionLocX;
      int y = potionLocY;

      x /= PotionScale;
      y /= PotionScale;
      GL11.glScalef(PotionScale, PotionScale, PotionScale);

      int i = 0;
      while (it.hasNext()) {
        PotionEffect potionEffect = (PotionEffect) it.next();
        Potion potion = Potion.potionTypes[potionEffect.getPotionID()];
        Boolean isFromBeacon = potionEffect.getIsAmbient(); // Minecraft bug: this is always false

        if (!isFromBeacon) // ignore effects from Beacons (Minecraft bug: isFromBeacon is always
        // false)
        {
          if (ShowPotionIcons) {
            DrawPotionIcon(x, y, potion);
            DrawPotionDuration(x + 10, y, potion, potionEffect);
          } else DrawPotionDuration(x, y, potion, potionEffect);

          y += 10;
          i++;
        }
      }

      GL11.glScalef(1f / PotionScale, 1f / PotionScale, 1f / PotionScale);
    }
  }
 @Override
 public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
   double totalEnergy = ElectricItemUtils.getPlayerEnergy(player);
   PotionEffect invis = null;
   Collection<PotionEffect> effects = player.getActivePotionEffects();
   for (PotionEffect effect : effects) {
     if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
       invis = effect;
       break;
     }
   }
   if (50 < totalEnergy) {
     if (invis == null || invis.getDuration() < 210) {
       player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
       ElectricItemUtils.drainPlayerEnergy(player, 50);
     }
   } else {
     if (invis != null) {
       player.removePotionEffect(Potion.invisibility.id);
     }
   }
 }
 public CraftPotionEffectType(PotionEffect handle) {
   super(handle.getPotionID());
   this.handle = handle;
 }
 public boolean isPotionApplicable(PotionEffect par1PotionEffect) {
   return par1PotionEffect.getPotionID() == Potion.poison.id
       ? false
       : super.isPotionApplicable(par1PotionEffect);
 }
Example #11
0
  @SideOnly(Side.CLIENT)
  public void addInformation(ItemStack ist, EntityPlayer player, List list, boolean flag) {
    if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
      return;
    PotionEssence essence = new PotionEssence(ist.getTagCompound());
    if (essence.getEffects().size() > 0) {
      HashMultimap hashmultimap = HashMultimap.create();
      Iterator iterator1;

      if (essence.getEffects() != null && !essence.getEffects().isEmpty()) {
        iterator1 = essence.getEffects().iterator();

        while (iterator1.hasNext()) {
          PotionEffect potioneffect = (PotionEffect) iterator1.next();
          String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim();
          Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
          Map map = potion.func_111186_k();

          if (map != null && map.size() > 0) {
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext()) {
              Map.Entry entry = (Map.Entry) iterator.next();
              AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
              AttributeModifier attributemodifier1 =
                  new AttributeModifier(
                      attributemodifier.getName(),
                      potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier),
                      attributemodifier.getOperation());
              hashmultimap.put(
                  ((IAttribute) entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1);
            }
          }

          if (potioneffect.getAmplifier() > 0) {
            s1 = s1 + " " + (potioneffect.getAmplifier() + 1);
          }

          if (potioneffect.getDuration() > 20) {
            s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")";
          }

          if (potion.isBadEffect()) {
            list.add(EnumChatFormatting.RED + s1);
          } else {
            list.add(EnumChatFormatting.GRAY + s1);
          }
        }
      } else {
        String s = StatCollector.translateToLocal("potion.empty").trim();
        list.add(EnumChatFormatting.GRAY + s);
      }

      if (!hashmultimap.isEmpty()) {
        list.add("");
        list.add(
            EnumChatFormatting.DARK_PURPLE
                + StatCollector.translateToLocal("potion.effects.whenDrank"));
        iterator1 = hashmultimap.entries().iterator();

        while (iterator1.hasNext()) {
          Map.Entry entry1 = (Map.Entry) iterator1.next();
          AttributeModifier attributemodifier2 = (AttributeModifier) entry1.getValue();
          double d0 = attributemodifier2.getAmount();
          double d1;

          if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) {
            d1 = attributemodifier2.getAmount();
          } else {
            d1 = attributemodifier2.getAmount() * 100.0D;
          }

          if (d0 > 0.0D) {
            list.add(
                EnumChatFormatting.BLUE
                    + StatCollector.translateToLocalFormatted(
                        "attribute.modifier.plus." + attributemodifier2.getOperation(),
                        new Object[] {
                          ItemStack.field_111284_a.format(d1),
                          StatCollector.translateToLocal(
                              "attribute.name." + (String) entry1.getKey())
                        }));
          } else if (d0 < 0.0D) {
            d1 *= -1.0D;
            list.add(
                EnumChatFormatting.RED
                    + StatCollector.translateToLocalFormatted(
                        "attribute.modifier.take." + attributemodifier2.getOperation(),
                        new Object[] {
                          ItemStack.field_111284_a.format(d1),
                          StatCollector.translateToLocal(
                              "attribute.name." + (String) entry1.getKey())
                        }));
          }
        }
      }
    }
  }
 public S1EPacketRemoveEntityEffect(int p_i45212_1_, PotionEffect p_i45212_2_) {
   this.field_149079_a = p_i45212_1_;
   this.field_149078_b = p_i45212_2_.getPotionID();
 }
Example #13
0
  public void RenderBuffs(int i, int j) {

    if (!AMCore.config.getShowBuffs()) {
      return;
    }

    int barWidth = i / 8;

    AMVector2 posBuffStart = getShiftedVector(AMCore.config.getPositiveBuffsPosition(), i, j);
    AMVector2 negBuffStart = getShiftedVector(AMCore.config.getNegativeBuffsPosition(), i, j);

    int positive_buff_x = posBuffStart.iX;
    int positive_buff_y = posBuffStart.iY;

    int negative_buff_x = negBuffStart.iX;
    int negative_buff_y = negBuffStart.iY;
    for (PotionEffect pe : getPotionEffectsByTimeRemaining()) {
      this.mc.renderEngine.bindTexture(inventory);

      int potionID = pe.getPotionID();
      if (potionID < 0 || potionID >= Potion.potionTypes.length) continue;

      Potion potion = Potion.potionTypes[potionID];

      if (potion == null) continue;

      if (potion.isBadEffect()) {
        if (potion.hasStatusIcon()) {
          int l = potion.getStatusIconIndex();
          if (pe.getDuration() < 100) {
            GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
          } else if (pe.getDuration() < 200) {
            GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
          }
          this.drawTexturedModalRect_Classic(
              negative_buff_x, negative_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
          GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
          negative_buff_x -= 12;
          if (negative_buff_x <= negBuffStart.iX - 48) {
            negative_buff_x = negBuffStart.iX;
            negative_buff_y += 12;
          }
        }
      } else {
        this.mc.renderEngine.bindTexture(inventory);
        if (potion.hasStatusIcon()) {
          int l = potion.getStatusIconIndex();
          if (pe.getDuration() < 100) {
            GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
          } else if (pe.getDuration() < 200) {
            GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
          }
          this.drawTexturedModalRect_Classic(
              positive_buff_x, positive_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
          GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
          positive_buff_x += 12;
          if (positive_buff_x >= posBuffStart.iX + 48) {
            positive_buff_x = posBuffStart.iX;
            positive_buff_y += 12;
          }
        }
      }
    }
  }