コード例 #1
0
ファイル: ItemXRPotion.java プロジェクト: adudney/Reliquary
 @Override
 @SideOnly(Side.CLIENT)
 public int getColorFromItemStack(ItemStack ist, int renderPass) {
   PotionEssence essence = new PotionEssence(ist.getTagCompound());
   boolean hasEffect = essence.getEffects().size() > 0;
   if (renderPass == 1 && hasEffect) return getColor(ist);
   else return Integer.parseInt(Colors.PURE, 16);
 }
コード例 #2
0
ファイル: ItemXRPotion.java プロジェクト: adudney/Reliquary
  @Override
  public IIcon getIcon(ItemStack ist, int renderPass) {
    PotionEssence essence = new PotionEssence(ist.getTagCompound());
    boolean hasEffect = essence.getEffects().size() > 0;

    if (!getSplash(ist)) {
      if (renderPass == 1 && hasEffect) return iconBaseOverlay;
      else return this.itemIcon;
    } else {
      if (renderPass == 1) return iconSplashOverlay;
      else return iconSplash;
    }
  }
コード例 #3
0
ファイル: ItemXRPotion.java プロジェクト: adudney/Reliquary
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  @Override
  public ItemStack onItemRightClick(ItemStack ist, World world, EntityPlayer player) {
    PotionEssence essence = new PotionEssence(ist.getTagCompound());
    if (!getSplash(ist)) {
      if (essence.getEffects().size() > 0) {
        player.setItemInUse(ist, this.getMaxItemUseDuration(ist));
        return ist;
      } else {
        MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, true);

        if (mop == null) return ist;
        else {
          if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            int blockX = mop.blockX;
            int blockY = mop.blockY;
            int blockZ = mop.blockZ;
            if (world.getBlock(blockX, blockY, blockZ) instanceof BlockApothecaryCauldron) {
              TileEntityCauldron cauldronTile =
                  (TileEntityCauldron) world.getTileEntity(blockX, blockY, blockZ);
              NBTTagCompound potionTag = cauldronTile.removeContainedPotion();
              ItemStack newPotion = new ItemStack(this, 1, 0);
              newPotion.setTagCompound(potionTag);

              if (--ist.stackSize <= 0) {
                return newPotion;
              }

              if (!player.inventory.addItemStackToInventory(newPotion)) {
                player.entityDropItem(newPotion, 0.1F);
              }
            }
          }
        }
      }
    } else {
      if (world.isRemote) return ist;
      Entity e = new EntityThrownXRPotion(world, player, ist);
      if (e == null) return ist;
      if (!player.capabilities.isCreativeMode) {
        --ist.stackSize;
      }
      world.playSoundAtEntity(
          player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
      world.spawnEntityInWorld(e);
    }
    return ist;
  }
コード例 #4
0
ファイル: ItemXRPotion.java プロジェクト: adudney/Reliquary
  @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())
                        }));
          }
        }
      }
    }
  }
コード例 #5
0
ファイル: ItemXRPotion.java プロジェクト: adudney/Reliquary
 // returns an empty vial when used in crafting recipes, unless it's one of
 // the base potion types.
 @Override
 public boolean hasContainerItem(ItemStack ist) {
   PotionEssence essence = new PotionEssence(ist.getTagCompound());
   return essence.getEffects().size() > 0;
 }