Ejemplo n.º 1
0
  @Override
  public void onUpdate(
      ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
    super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
    if (par3Entity instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) par3Entity;
      PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
      float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;

      if (player.getCurrentEquippedItem() == par1ItemStack
          && player.swingProgress == check
          && !par2World.isRemote
          && par2World.rand.nextInt(2) == 0) {
        MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48);
        if (pos != null) {
          Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ);
          Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18);
          posVec.add(motVec);
          motVec.normalize().negate().multiply(1.5);

          EntityFallingStar star = new EntityFallingStar(par2World, player);
          star.setPosition(posVec.x, posVec.y, posVec.z);
          star.motionX = motVec.x;
          star.motionY = motVec.y;
          star.motionZ = motVec.z;
          par2World.spawnEntityInWorld(star);

          ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
          par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F);
        }
      }
    }
  }
Ejemplo n.º 2
0
  @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();
    }
  }
Ejemplo n.º 3
0
  private void mixPotions() {
    ItemStack resultPotion = new ItemStack(ModItems.mixedPotion, 1);
    int emulsifierLevel = calculateEmulsifierLevel();
    ArrayList<PotionEffect> resultList = new ArrayList<PotionEffect>();
    NBTTagCompound potionEffects = new NBTTagCompound();
    NBTTagList taglist = new NBTTagList();

    for (int i = POTION_START; i < getSizeInventory(); i++) {
      ItemStack potion = getStackInSlot(i);
      ArrayList<PotionEffect> effectList = getPotionEffects(potion);
      if (resultList.size() == emulsifierLevel) {
        break;
      } else if (resultList.size() + effectList.size() > emulsifierLevel) {
        continue;
      } else {
        for (PotionEffect effect : effectList) {
          if (!resultList.contains(effect)) {
            resultList.add(effect);
            NBTTagCompound effectCompound = new NBTTagCompound();
            taglist.appendTag(effect.writeCustomPotionEffectToNBT(effectCompound));
          }
        }
        // since this potion was used, remove it from the inventory
        setInventorySlotContents(i, null);
      }
    }

    potionEffects.setTag("CustomPotionEffects", taglist);
    resultPotion.setTagCompound(potionEffects);
    setInventorySlotContents(EMULSIFIER_INDEX, decrStackSize(EMULSIFIER_INDEX, 1));
    setInventorySlotContents(RESULT_INDEX, resultPotion);
  }
  public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
    PotionEffect potion = new PotionEffect(EldritchPotions.getPotion(0).id, 100);
    potion.setCurativeItems(null);
    target.addPotionEffect(potion);

    stack.damageItem(1, attacker);

    return false;
  }
Ejemplo n.º 5
0
  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();
  }
Ejemplo n.º 7
0
  /**
   * Draws a potion's remaining duration with a color coded blinking timer
   *
   * @param x
   * @param y
   * @param potion
   * @param potionEffect
   */
  protected static void DrawPotionDuration(int x, int y, Potion potion, PotionEffect potionEffect) {
    String durationString = Potion.getDurationString(potionEffect);
    int potionDuration = potionEffect.getDuration(); // goes down by 20 ticks per second
    int colorInt = 0xFFFFFF;

    if (UsePotionColors) colorInt = potion.getLiquidColor();

    boolean unicodeFlag = mc.fontRenderer.getUnicodeFlag();
    mc.fontRenderer.setUnicodeFlag(true);

    // render the potion duration text onto the screen
    if (potionDuration
        >= blinkingThresholds[
            blinkingThresholds.length - 1]) // if the text is not blinking then render it normally
    {
      mc.fontRenderer.drawStringWithShadow(durationString, x, y, colorInt);
    } else // else if the text is blinking, have a chance to not render it based on the blinking
    // variables
    {
      // logic to determine if the text should be displayed, checks the blinking text settings
      for (int j = 0; j < blinkingThresholds.length; j++) {
        if (potionDuration < blinkingThresholds[j]) {
          if (potionDuration % blinkingSpeed[j] > blinkingDuration[j]) {
            mc.fontRenderer.drawStringWithShadow(durationString, x, y, colorInt);
          }

          break;
        }
      }
    }

    mc.fontRenderer.setUnicodeFlag(unicodeFlag);
  }
Ejemplo n.º 8
0
 @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 static void addOrMergePotionEffect(EntityLivingBase player, PotionEffect newp) {
   if (player.isPotionActive(newp.getPotion())) {
     // do not use built in 'combine' function, just add up duration myself
     PotionEffect p = player.getActivePotionEffect(newp.getPotion());
     int ampMax = Math.max(p.getAmplifier(), newp.getAmplifier());
     player.addPotionEffect(
         new PotionEffect(newp.getPotion(), newp.getDuration() + p.getDuration(), ampMax));
   } else {
     player.addPotionEffect(newp);
   }
 }
Ejemplo n.º 10
0
  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;
  }
Ejemplo n.º 11
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);
     }
   }
 }
Ejemplo n.º 13
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);
      }
    }
  }
Ejemplo n.º 14
0
 @Override
 public double getDurationModifier() {
   return handle.getAmplifier();
 }
Ejemplo n.º 15
0
 public boolean isPotionApplicable(PotionEffect par1PotionEffect) {
   return par1PotionEffect.getPotionID() == Potion.poison.id
       ? false
       : super.isPotionApplicable(par1PotionEffect);
 }
Ejemplo n.º 16
0
 @Override
 public int compare(PotionEffect o1, PotionEffect o2) {
   if (o1.getDuration() < o2.getDuration()) return -1;
   else if (o1.getDuration() > o2.getDuration()) return 1;
   else return 0;
 }
Ejemplo n.º 17
0
  public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
      throw new WrongUsageException("commands.effect.usage", new Object[0]);
    } else {
      EntityLivingBase var3 =
          (EntityLivingBase) func_175759_a(sender, args[0], EntityLivingBase.class);

      if (args[1].equals("clear")) {
        if (var3.getActivePotionEffects().isEmpty()) {
          throw new CommandException(
              "commands.effect.failure.notActive.all", new Object[] {var3.getName()});
        } else {
          var3.clearActivePotions();
          notifyOperators(
              sender, this, "commands.effect.success.removed.all", new Object[] {var3.getName()});
        }
      } else {
        int var4;

        try {
          var4 = parseInt(args[1], 1);
        } catch (NumberInvalidException var11) {
          Potion var6 = Potion.getPotionAtLocation(args[1]);

          if (var6 == null) {
            throw var11;
          }

          var4 = var6.id;
        }

        int var5 = 600;
        int var12 = 30;
        int var7 = 0;

        if (var4 >= 0 && var4 < Potion.potionTypes.length && Potion.potionTypes[var4] != null) {
          Potion var8 = Potion.potionTypes[var4];

          if (args.length >= 3) {
            var12 = parseInt(args[2], 0, 1000000);

            if (var8.isInstant()) {
              var5 = var12;
            } else {
              var5 = var12 * 20;
            }
          } else if (var8.isInstant()) {
            var5 = 1;
          }

          if (args.length >= 4) {
            var7 = parseInt(args[3], 0, 255);
          }

          boolean var9 = true;

          if (args.length >= 5 && "true".equalsIgnoreCase(args[4])) {
            var9 = false;
          }

          if (var12 > 0) {
            PotionEffect var10 = new PotionEffect(var4, var5, var7, false, var9);
            var3.addPotionEffect(var10);
            notifyOperators(
                sender,
                this,
                "commands.effect.success",
                new Object[] {
                  new FormattedTextTranslation(var10.getEffectName(), new Object[0]),
                  Integer.valueOf(var4),
                  Integer.valueOf(var7),
                  var3.getName(),
                  Integer.valueOf(var12)
                });
          } else if (var3.isPotionActive(var4)) {
            var3.removePotionEffect(var4);
            notifyOperators(
                sender,
                this,
                "commands.effect.success.removed",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          } else {
            throw new CommandException(
                "commands.effect.failure.notActive",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          }
        } else {
          throw new NumberInvalidException(
              "commands.effect.notFound", new Object[] {Integer.valueOf(var4)});
        }
      }
    }
  }
 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();
 }
Ejemplo n.º 19
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;
          }
        }
      }
    }
  }
Ejemplo n.º 20
0
 @Override
 public boolean isInstant() {
   return handle.getDuration() < 5;
 }
Ejemplo n.º 21
0
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
    if (p_71515_2_.length >= 2) {
      EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]);
      int var4 = func_71528_a(p_71515_1_, p_71515_2_[1], 1);
      int var5 = 600;
      int var6 = 30;
      int var7 = 0;
      if (var4 >= 0 && var4 < Potion.field_76425_a.length && Potion.field_76425_a[var4] != null) {
        if (p_71515_2_.length >= 3) {
          var6 = func_71532_a(p_71515_1_, p_71515_2_[2], 0, 1000000);
          if (Potion.field_76425_a[var4].func_76403_b()) {
            var5 = var6;
          } else {
            var5 = var6 * 20;
          }
        } else if (Potion.field_76425_a[var4].func_76403_b()) {
          var5 = 1;
        }

        if (p_71515_2_.length >= 4) {
          var7 = func_71532_a(p_71515_1_, p_71515_2_[3], 0, 255);
        }

        if (var6 == 0) {
          if (!var3.func_82165_m(var4)) {
            throw new CommandException(
                "commands.effect.failure.notActive",
                new Object[] {
                  StatCollector.func_74838_a(Potion.field_76425_a[var4].func_76393_a()),
                  var3.func_70023_ak()
                });
          }

          var3.func_82170_o(var4);
          func_71522_a(
              p_71515_1_,
              "commands.effect.success.removed",
              new Object[] {
                StatCollector.func_74838_a(Potion.field_76425_a[var4].func_76393_a()),
                var3.func_70023_ak()
              });
        } else {
          PotionEffect var8 = new PotionEffect(var4, var5, var7);
          var3.func_70690_d(var8);
          func_71522_a(
              p_71515_1_,
              "commands.effect.success",
              new Object[] {
                StatCollector.func_74838_a(var8.func_76453_d()),
                Integer.valueOf(var4),
                Integer.valueOf(var7),
                var3.func_70023_ak(),
                Integer.valueOf(var6)
              });
        }

      } else {
        throw new NumberInvalidException(
            "commands.effect.notFound", new Object[] {Integer.valueOf(var4)});
      }
    } else {
      throw new WrongUsageException("commands.effect.usage", new Object[0]);
    }
  }
Ejemplo n.º 22
0
 public CraftPotionEffectType(PotionEffect handle) {
   super(handle.getPotionID());
   this.handle = handle;
 }
Ejemplo n.º 23
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())
                        }));
          }
        }
      }
    }
  }
Ejemplo n.º 24
0
  @Override
  public void control(EntityPlayerCustom playerCustom, EntityPlayer player, Side side) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);
    int heading = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    if (!playerCustom.isSneaking) {
      if (((((Util.isCube(player.worldObj.getBlock(x, y, z - 1)) && heading == 2)
                  || (Util.isCube(player.worldObj.getBlock(x, y, z + 1)) && heading == 0)
                  || (Util.isCube(player.worldObj.getBlock(x - 1, y, z)) && heading == 1)
                  || (Util.isCube(player.worldObj.getBlock(x + 1, y, z)) && heading == 3))
              && ((!Util.isCube(player.worldObj.getBlock(x, y + 1, z - 1)) && heading == 2)
                  || (!Util.isCube(player.worldObj.getBlock(x, y + 1, z + 1)) && heading == 0)
                  || (!Util.isCube(player.worldObj.getBlock(x - 1, y + 1, z)) && heading == 1)
                  || (!Util.isCube(player.worldObj.getBlock(x + 1, y + 1, z)) && heading == 3))
              && (!Util.isCube(player.worldObj.getBlock(x, y - 2, z)))))
          && player.worldObj.getBlock(x, y, z) != Blocks.ladder
          && player.getCurrentEquippedItem() == null) {
        playerCustom.isGrabbing = true;
        playerCustom.rotationYaw = player.rotationYaw;
        playerCustom.rotationPitch = player.rotationPitch;
        playerCustom.prevRotationPitch = player.prevRotationPitch;
        playerCustom.prevRotationYaw = player.prevRotationYaw;
        playerCustom.grabbingDirections[heading] = true;
        if (heading == 0) {
          playerCustom.grabbingDirections[3] = true;
        } else {
          playerCustom.grabbingDirections[heading - 1] = true;
        }

        if (heading == 3) {
          playerCustom.grabbingDirections[0] = true;
        } else {
          playerCustom.grabbingDirections[heading + 1] = true;
        }
      } else {
        playerCustom.isGrabbing = false;
        playerCustom.rotationYaw = 0;
        if (!playerCustom.isRolling) {
          playerCustom.rotationPitch = 0;
        }
        playerCustom.prevRotationPitch = 0;
        playerCustom.prevRotationYaw = 0;
        playerCustom.grabbingDirections[0] = false;
        playerCustom.grabbingDirections[1] = false;
        playerCustom.grabbingDirections[2] = false;
        playerCustom.grabbingDirections[3] = false;
      }
      if (playerCustom.isGrabbing && !playerCustom.wasSneaking && player.isSneaking()) {
        playerCustom.wasSneaking = true;
      }
      if (!playerCustom.isGrabbing) {
        playerCustom.wasSneaking = false;
      }
      if (playerCustom.wasSneaking) {
        return;
      }
      if (!player.isSneaking()
          && !(Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        if (heading == 1 || heading == 3) {
          player.setPosition(x + 0.5F, y + 0.9F, player.posZ);
          player.motionX = 0;
        }
        if (heading == 2 || heading == 0) {
          player.setPosition(player.posX, y + 0.9F, z + 0.5F);
          player.motionZ = 0;
        }
        player.motionY = 0.0;
        if (player.isSprinting()) {
          player.setSprinting(false);
        }
      } else if ((Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        player.motionY = 0.55D;
      }
    }

    //		if(side == Side.CLIENT){
    ////			Util.channel.sendToServer(new CPacketPlayerAction(playerCustom.isGrabbing ? 0 : 1));
    //		}
    //
    //		if(side == Side.SERVER){
    //			System.out.println("1 : " + playerCustom.isGrabbing);
    //		}
    /*    CLIENT    */
    if (!player.worldObj.isRemote) {
      if (playerCustom.isGrabbing && !player.capabilities.isCreativeMode) {
        PotionEffect potioneffect = player.getActivePotionEffect(Potion.jump);
        float f1 = potioneffect != null ? (float) (potioneffect.getAmplifier() + 1) : 0.0F;
        int i = MathHelper.ceiling_float_int(player.fallDistance - 3.0F - f1);
        if (i > 0) {
          player.playSound(
              i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small", 1.0F, 1.0F);
          damageEntity(EntityLivingBase.class, player, DamageSource.fall, (float) i);
        }
        player.fallDistance = 0;
      }
    }
  }
Ejemplo n.º 25
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length < 2) {
      throw new WrongUsageException("commands.effect.usage", new Object[0]);
    } else {
      EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]);

      if (par2ArrayOfStr[1].equals("clear")) {
        if (entityplayermp.getActivePotionEffects().isEmpty()) {
          throw new CommandException(
              "commands.effect.failure.notActive.all",
              new Object[] {entityplayermp.getCommandSenderName()});
        }

        entityplayermp.clearActivePotions();
        notifyAdmins(
            par1ICommandSender,
            "commands.effect.success.removed.all",
            new Object[] {entityplayermp.getCommandSenderName()});
      } else {
        int i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 1);
        int j = 600;
        int k = 30;
        int l = 0;

        if (i < 0 || i >= Potion.potionTypes.length || Potion.potionTypes[i] == null) {
          throw new NumberInvalidException(
              "commands.effect.notFound", new Object[] {Integer.valueOf(i)});
        }

        if (par2ArrayOfStr.length >= 3) {
          k = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 0, 1000000);

          if (Potion.potionTypes[i].isInstant()) {
            j = k;
          } else {
            j = k * 20;
          }
        } else if (Potion.potionTypes[i].isInstant()) {
          j = 1;
        }

        if (par2ArrayOfStr.length >= 4) {
          l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[3], 0, 255);
        }

        if (k == 0) {
          if (!entityplayermp.isPotionActive(i)) {
            throw new CommandException(
                "commands.effect.failure.notActive",
                new Object[] {
                  new ChatComponentTranslation(Potion.potionTypes[i].getName(), new Object[0]),
                  entityplayermp.getCommandSenderName()
                });
          }

          entityplayermp.removePotionEffect(i);
          notifyAdmins(
              par1ICommandSender,
              "commands.effect.success.removed",
              new Object[] {
                new ChatComponentTranslation(Potion.potionTypes[i].getName(), new Object[0]),
                entityplayermp.getCommandSenderName()
              });
        } else {
          PotionEffect potioneffect = new PotionEffect(i, j, l);
          entityplayermp.addPotionEffect(potioneffect);
          notifyAdmins(
              par1ICommandSender,
              "commands.effect.success",
              new Object[] {
                new ChatComponentTranslation(potioneffect.getEffectName(), new Object[0]),
                Integer.valueOf(i),
                Integer.valueOf(l),
                entityplayermp.getCommandSenderName(),
                Integer.valueOf(k)
              });
        }
      }
    }
  }