Example #1
0
  @Override
  public void putStack(ItemStack stack) {
    if (stack == null) {
      return;
    }

    super.putStack(stack);

    if (stack.getItem() == ObjHandler.kleinStars) {
      int remainingEmc =
          EMCHelper.getKleinStarMaxEmc(stack) - (int) Math.ceil(ItemPE.getEmc(stack));

      if (inv.emc >= remainingEmc) {
        ItemPE.addEmc(stack, remainingEmc);
        inv.removeEmc(remainingEmc);
      } else {
        ItemPE.addEmc(stack, inv.emc);
        inv.emc = 0;
      }
    }

    if (stack.getItem() != ObjHandler.tome) {
      inv.handleKnowledge(stack.copy());
    } else {
      inv.updateOutputs();
    }
  }
Example #2
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    if (slotIndex == 0) {
      return null;
    }

    Slot slot = this.getSlot(slotIndex);

    if (slot == null || !slot.getHasStack()) {
      return null;
    }

    ItemStack stack = slot.getStack();
    ItemStack newStack = stack.copy();

    if (slotIndex <= 91) {
      if (!this.mergeItemStack(stack, 92, 127, false)) {
        return null;
      }
    } else if (!EMCHelper.doesItemHaveEmc(stack) || !this.mergeItemStack(stack, 1, 91, false)) {
      return null;
    }

    if (stack.stackSize == 0) {
      slot.putStack(null);
    } else slot.onSlotChanged();
    slot.onPickupFromSlot(player, stack);
    return newStack;
  }
        @Override
        public int compare(IAEItemStack o1, IAEItemStack o2) {
          // Logger.info("Comparing by EMC");
          int itememc1 = EMCHelper.getEmcValue(o1.getItemStack());
          BigInteger stack1 =
              BigInteger.valueOf(itememc1).multiply(BigInteger.valueOf(o1.getStackSize()));
          // Logger.info(o1.getItemStack().getDisplayName() +
          // stack1.toString());
          int stackemc1;
          if (stack1.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
            // Logger.info("Value is bigger than Integer.MAX_VALUE");
            stackemc1 = Integer.MAX_VALUE;
            // Logger.info(String.valueOf(stackemc1));
          } else {
            stackemc1 = stack1.intValue();
          }
          int itememc2 = EMCHelper.getEmcValue(o2.getItemStack());
          BigInteger stack2 =
              BigInteger.valueOf(itememc2).multiply(BigInteger.valueOf(o2.getStackSize()));
          int stackemc2;
          if (stack2.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
            stackemc2 = Integer.MAX_VALUE;
          } else {
            stackemc2 = stack2.intValue();
          }

          // Logger.info("FirstStack:" + String.valueOf(stackemc1));
          // Logger.info("SecondStack:" + String.valueOf(stackemc2));

          if (Direction == SortDir.ASCENDING) {
            // Logger.info(String.valueOf(compareInt(stackemc2,
            // stackemc1)));
            // return compareInt(stackemc2, stackemc1);
            return this.secondarySort(compareInt(stackemc2, stackemc1), o1, o2);
          }
          // Logger.info(String.valueOf(compareInt(stackemc1, stackemc2)));
          // return compareInt(stackemc1, stackemc2);
          return this.secondarySort(compareInt(stackemc1, stackemc2), o2, o1);
        }
  @SubscribeEvent
  public void tTipEvent(ItemTooltipEvent event) {
    ItemStack current = event.itemStack;
    Item currentItem = current.getItem();
    Block currentBlock = Block.getBlockFromItem(currentItem);

    if (current == null) {
      return;
    }

    if (currentBlock == ObjHandler.dmPedestal) {
      event.toolTip.add(StatCollector.translateToLocal("pe.pedestal.tooltip1"));
      event.toolTip.add(StatCollector.translateToLocal("pe.pedestal.tooltip2"));
    }

    if (currentItem == ObjHandler.manual) {
      event.toolTip.add(StatCollector.translateToLocal("pe.manual.tooltip1"));
    }

    if (ProjectEConfig.showPedestalTooltip && currentItem instanceof IPedestalItem) {
      if (ProjectEConfig.showPedestalTooltipInGUI) {
        if (Minecraft.getMinecraft().currentScreen instanceof GUIPedestal) {
          event.toolTip.add(
              EnumChatFormatting.DARK_PURPLE
                  + StatCollector.translateToLocal("pe.pedestal.on_pedestal")
                  + " ");
          List<String> description = ((IPedestalItem) currentItem).getPedestalDescription();
          if (description.isEmpty()) {
            event.toolTip.add(IPedestalItem.TOOLTIPDISABLED);
          } else {
            event.toolTip.addAll(((IPedestalItem) currentItem).getPedestalDescription());
          }
        }
      } else {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + StatCollector.translateToLocal("pe.pedestal.on_pedestal")
                + " ");
        List<String> description = ((IPedestalItem) currentItem).getPedestalDescription();
        if (description.isEmpty()) {
          event.toolTip.add(IPedestalItem.TOOLTIPDISABLED);
        } else {
          event.toolTip.addAll(((IPedestalItem) currentItem).getPedestalDescription());
        }
      }
    }

    if (ProjectEConfig.showUnlocalizedNames) {
      event.toolTip.add("UN: " + Item.itemRegistry.getNameForObject(current.getItem()));
    }

    if (ProjectEConfig.showODNames) {
      for (int id : OreDictionary.getOreIDs(current)) {
        event.toolTip.add("OD: " + OreDictionary.getOreName(id));
      }
    }

    if (ProjectEConfig.showEMCTooltip) {
      if (EMCHelper.doesItemHaveEmc(current)) {
        int value = EMCHelper.getEmcValue(current);

        event.toolTip.add(
            EnumChatFormatting.YELLOW
                + StatCollector.translateToLocal("pe.emc.emc_tooltip_prefix")
                + " "
                + EnumChatFormatting.WHITE
                + String.format("%,d", value));

        if (current.stackSize > 1) {
          long total = value * current.stackSize;

          if (total < 0 || total <= value || total > Integer.MAX_VALUE) {
            event.toolTip.add(
                EnumChatFormatting.YELLOW
                    + StatCollector.translateToLocal("pe.emc.stackemc_tooltip_prefix")
                    + " "
                    + EnumChatFormatting.OBFUSCATED
                    + StatCollector.translateToLocal("pe.emc.too_much"));
          } else {
            event.toolTip.add(
                EnumChatFormatting.YELLOW
                    + StatCollector.translateToLocal("pe.emc.stackemc_tooltip_prefix")
                    + " "
                    + EnumChatFormatting.WHITE
                    + String.format("%,d", value * current.stackSize));
          }
        }
      }
    }

    if (ProjectEConfig.showStatTooltip) {
      /** Collector ToolTips */
      String unit = StatCollector.translateToLocal("pe.emc.name");
      String rate = StatCollector.translateToLocal("pe.emc.rate");

      if (currentBlock == ObjHandler.energyCollector) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxgenrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.COLLECTOR_MK1_GEN));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.COLLECTOR_MK1_MAX));
      }

      if (currentBlock == ObjHandler.collectorMK2) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxgenrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.COLLECTOR_MK2_GEN));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.COLLECTOR_MK2_MAX));
      }

      if (currentBlock == ObjHandler.collectorMK3) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxgenrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.COLLECTOR_MK3_GEN));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.COLLECTOR_MK3_MAX));
      }

      /** Relay ToolTips */
      if (currentBlock == ObjHandler.relay) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxoutrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.RELAY_MK1_OUTPUT));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.RELAY_MK1_MAX));
      }

      if (currentBlock == ObjHandler.relayMK2) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxoutrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.RELAY_MK2_OUTPUT));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.RELAY_MK2_MAX));
      }

      if (currentBlock == ObjHandler.relayMK3) {
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxoutrate_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + rate,
                    Constants.RELAY_MK3_OUTPUT));
        event.toolTip.add(
            EnumChatFormatting.DARK_PURPLE
                + String.format(
                    StatCollector.translateToLocal("pe.emc.maxstorage_tooltip")
                        + EnumChatFormatting.BLUE
                        + " %d "
                        + unit,
                    Constants.RELAY_MK3_MAX));
      }
    }

    if (current.hasTagCompound()) {
      if (current.stackTagCompound.getBoolean("ProjectEBlock")) {
        event.toolTip.add(
            EnumChatFormatting.GREEN + StatCollector.translateToLocal("pe.misc.wrenched_block"));

        if (current.stackTagCompound.getDouble("EMC") > 0) {
          event.toolTip.add(
              EnumChatFormatting.YELLOW
                  + String.format(
                      StatCollector.translateToLocal("pe.emc.storedemc_tooltip")
                          + " "
                          + EnumChatFormatting.RESET
                          + "%,d",
                      (int) current.stackTagCompound.getDouble("EMC")));
        }
      }

      if (current.stackTagCompound.hasKey("StoredEMC")) {
        event.toolTip.add(
            EnumChatFormatting.YELLOW
                + String.format(
                    StatCollector.translateToLocal("pe.emc.storedemc_tooltip")
                        + " "
                        + EnumChatFormatting.RESET
                        + "%,d",
                    (int) current.stackTagCompound.getDouble("StoredEMC")));
      } else if (current.stackTagCompound.hasKey("StoredXP")) {
        event.toolTip.add(
            String.format(
                EnumChatFormatting.DARK_GREEN
                    + StatCollector.translateToLocal("pe.misc.storedxp_tooltip")
                    + " "
                    + EnumChatFormatting.GREEN
                    + "%,d",
                current.stackTagCompound.getInteger("StoredXP")));
      }
    }
  }
Example #5
0
 @Override
 public boolean isItemValid(ItemStack stack) {
   return !this.getHasStack() && EMCHelper.doesItemHaveEmc(stack);
 }