Esempio n. 1
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 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)});
        }
      }
    }
  }
Esempio n. 3
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)
              });
        }
      }
    }
  }