Esempio n. 1
0
  /** @author wasliebob */
  public static TargetInformation getTargetInfo(EntityPlayer player) {
    Block block = Utils.getTargetBlock(player);
    int meta = Utils.getTargetBlockMeta(player);
    int x = Utils.getTargetX(player);
    int y = Utils.getTargetY(player);
    int z = Utils.getTargetZ(player);

    TargetInformation info = new TargetInformation(block, meta, x, y, z);

    return info;
  }
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      EnergyItems.checkAndSetItemOwner(stack, player);
      NBTTagCompound itemTag = stack.stackTagCompound;

      if (itemTag == null || itemTag.getString("ownerName").equals("")) return stack;

      String ownerName = itemTag.getString("ownerName");

      int currentEssence = EnergyItems.getCurrentEssence(ownerName);

      TileEntity te = Utils.getTargetTile(player);
      if (te != null && te instanceof TEAltar) {
        TEAltar altar = (TEAltar) te;
        float selfSacrifiseMultiplier = altar.getSelfSacrificeMultiplier() * 10;
        float sacrifiseMultiplier = altar.getSacrificeMultiplier() * 10;

        int sacrifise = (int) (500 + ((500 / 100) * sacrifiseMultiplier));
        int selfSacrifise = (int) (200 + ((200 / 100) * selfSacrifiseMultiplier));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Stored: "
                    + EnumChatFormatting.GRAY
                    + altar.getCurrentBlood()
                    + "/"
                    + altar.getCapacity()));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED + "Tier: " + EnumChatFormatting.GRAY + altar.getTier()));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Self-Sacrifice: "
                    + EnumChatFormatting.GRAY
                    + selfSacrifise
                    + " LP"));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Sacrifice: "
                    + EnumChatFormatting.GRAY
                    + sacrifise
                    + " LP"));

        if (altar.getStackInSlot(0) != null) {
          AltarRecipe recipe =
              AltarRecipeRegistry.getAltarRecipeForItemAndTier(
                  altar.getStackInSlot(0), altar.getTier());
          if (recipe != null && recipe.getResult() != null) {
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Progress: "
                        + EnumChatFormatting.GRAY
                        + altar.getProgress()
                        + "/"
                        + recipe.getLiquidRequired()));
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Output: "
                        + EnumChatFormatting.GRAY
                        + recipe.getResult().getDisplayName()));
          }

          if (altar.getStackInSlot(0).getItem() instanceof IBloodOrb) {
            IBloodOrb orb = (IBloodOrb) altar.getStackInSlot(0).getItem();
            float orbMultiplier = altar.getOrbMultiplier() * 2;
            int orbStorage =
                (int) (orb.getMaxEssence() + ((orb.getMaxEssence() / 100) * orbMultiplier));
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Orb Storage: "
                        + EnumChatFormatting.GRAY
                        + orbStorage
                        + " LP"));
          }
        }
      } else {
        World worldSave = MinecraftServer.getServer().worldServers[0];
        if (worldSave != null) {
          LifeEssenceNetwork data = EssenceHelper.getLifeEssenceNetwork(ownerName, worldSave);
          if (data != null)
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Network Essence: "
                        + EnumChatFormatting.GRAY
                        + currentEssence
                        + " LP"));
        }
      }
    }
    return stack;
  }