private static void addToolsetCrafting(
     Item ingot, Item sword, Item shovel, Item axe, Item hoe, Item pickaxe) {
   String ingotName = OreDictionary.getOreName(OreDictionary.getOreIDs(new ItemStack(ingot))[0]);
   String stickName =
       OreDictionary.getOreName(OreDictionary.getOreIDs(new ItemStack(Items.stick))[0]);
   // Sword recipe
   GameRegistry.addRecipe(
       new ShapedOreRecipe(sword, "i", "i", "s", 'i', ingotName, 's', stickName));
   // Shovel recipe
   GameRegistry.addRecipe(
       new ShapedOreRecipe(shovel, "i", "s", "s", 'i', ingotName, 's', stickName));
   // Axe recipes
   GameRegistry.addRecipe(
       new ShapedOreRecipe(axe, "ii", "is", " s", 'i', ingotName, 's', stickName));
   GameRegistry.addRecipe(
       new ShapedOreRecipe(axe, "ii", "si", "s ", 'i', ingotName, 's', stickName));
   // Hoe
   GameRegistry.addRecipe(
       new ShapedOreRecipe(hoe, "ii", " s", " s", 'i', ingotName, 's', stickName));
   GameRegistry.addRecipe(
       new ShapedOreRecipe(hoe, "ii", "s ", "s ", 'i', ingotName, 's', stickName));
   // Pickaxe
   GameRegistry.addRecipe(
       new ShapedOreRecipe(pickaxe, "iii", " s ", " s ", 'i', ingotName, 's', stickName));
 }
예제 #2
0
    private boolean oreMatch(ItemStack base, ItemStack matched) {
      int[] oreIds = OreDictionary.getOreIDs(base);
      int[] matchesIds = OreDictionary.getOreIDs(matched);

      for (int stackId : oreIds) {
        for (int matchId : matchesIds) {
          if (stackId == matchId) {
            return true;
          }
        }
      }

      return false;
    }
예제 #3
0
  public static boolean contains(ArrayList list, ItemStack stack) {
    if (stack == null || stack.getItem() == null) return false;

    Object object = stack.getItem();

    Material material = null;

    if (object instanceof ItemBlock) {
      object = Block.getBlockFromItem((Item) object);
      material = ((Block) object).getMaterial();
    }

    int[] ores = OreDictionary.getOreIDs(stack);

    for (int i = 0; i < list.size(); i++) {
      if (list.get(i) instanceof ItemStack
          && ItemStack.areItemStacksEqual(stack, (ItemStack) list.get(i))) return true;

      if (list.get(i) == object) return true;

      if (list.get(i) == material) return true;

      if (list.get(i) instanceof String)
        for (int j = 0; j < ores.length; j++) {
          if (OreDictionary.getOreName(ores[j]).contains((CharSequence) list.get(i))) return true;
        }
    }
    return false;
  }
예제 #4
0
  protected final String getMostCommonName(ArrayList<ItemStack> stacks) {
    HashMap<String, Integer> map = new HashMap();
    for (ItemStack stack : stacks) {
      int[] ids = OreDictionary.getOreIDs(stack);
      for (int i : ids) {
        String name = OreDictionary.getOreName(i);
        if (map.containsKey(name)) {
          int value = map.get(name) + 1;
          map.put(name, value);
        } else map.put(name, 1);
      }
    }

    String highest = "";
    int highest_value = 0;
    for (String string : map.keySet()) {
      int value = map.get(string);
      if (value > highest_value) {
        highest_value = value;
        highest = string;
      }
    }

    return highest;
  }
  public static ItemStack identifyQuality(ItemStack stack) {
    if (stack == null) return null;

    Item item = stack.getItem();
    if (item instanceof ItemGemstone) {
      if (((ItemGemstone) item).getQuality(stack) != null) return stack;
    }

    @SuppressWarnings("unchecked")
    List<Pair<ItemStack, String>> gems =
        Lists.newArrayList(
            Pair.of(ElementsOfPower.gemRuby, "gemRuby"),
            Pair.of(ElementsOfPower.gemSapphire, "gemSapphire"),
            Pair.of(ElementsOfPower.gemCitrine, "gemCitrine"),
            Pair.of(ElementsOfPower.gemAgate, "gemAgate"),
            Pair.of(ElementsOfPower.gemQuartz, "gemQuartz"),
            Pair.of(ElementsOfPower.gemSerendibite, "gemSerendibite"),
            Pair.of(ElementsOfPower.gemEmerald, "gemEmerald"),
            Pair.of(ElementsOfPower.gemAmethyst, "gemAmethyst"),
            Pair.of(ElementsOfPower.gemDiamond, "gemDiamond"));

    int[] ids = OreDictionary.getOreIDs(stack);
    Set<String> names = Sets.newHashSet();
    for (int i : ids) {
      names.add(OreDictionary.getOreName(i));
    }

    for (Pair<ItemStack, String> target : gems) {
      if (names.contains(target.getRight())) {
        return setRandomQualityVariant(target.getLeft().copy());
      }
    }

    return stack;
  }
  public static boolean ItemOreMatch(ItemStack item1, ItemStack item2) {
    if (item1.isItemEqual(item2)) {
      return true;
    }
    int[] ores1 = OreDictionary.getOreIDs(item1);
    if (ores1.length == 0) return false;
    int[] ores2 = OreDictionary.getOreIDs(item2);
    if (ores2.length == 0) return false;

    for (int i = 0; i < ores1.length; i++) {
      for (int j = 0; j < ores2.length; j++) {
        if (ores1[i] == ores2[j]) return true;
      }
    }
    return false;
  }
예제 #7
0
 @Override
 public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) {
   int[] idsStack = OreDictionary.getOreIDs(stack);
   for (int id : idsStack) {
     if (OreDictionary.getOreName(id).equals(repairItem)) return true;
   }
   return false;
 }
 public static boolean testOre(int testOreID, ItemStack testItem) {
   if (testItem == null || testItem.getItem() == null) return false;
   int[] ordIDs = OreDictionary.getOreIDs(testItem);
   for (int oreID : ordIDs) {
     if (testOreID == oreID) return true;
   }
   return false;
 }
예제 #9
0
  int getStackColor(ItemStack stack) {
    int[] ids = OreDictionary.getOreIDs(stack);
    for (int i : ids) {
      int index = DYES.indexOf(OreDictionary.getOreName(i));
      if (index >= 0) return index;
    }

    return -1;
  }
예제 #10
0
 public boolean matches(ItemStack stack) {
   int[] ids = OreDictionary.getOreIDs(stack);
   for (int id : ids) {
     String name = OreDictionary.getOreName(id);
     if (matches(name)) {
       return true;
     }
   }
   return stack != null && OreDictionary.itemMatches(stack, input, false);
 }
예제 #11
0
 private static void addNuggetCrafting(Item nugget, Item ingot) {
   String nuggetName = OreDictionary.getOreName(OreDictionary.getOreIDs(new ItemStack(nugget))[0]);
   String ingotName = OreDictionary.getOreName(OreDictionary.getOreIDs(new ItemStack(ingot))[0]);
   GameRegistry.addRecipe(
       new ShapelessOreRecipe(new ItemStack(nugget, 9), new Object[] {ingotName}));
   GameRegistry.addRecipe(
       new ShapelessOreRecipe(
           new ItemStack(ingot, 1),
           new Object[] {
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName,
             nuggetName
           }));
 }
 public BookPageDip(String string, CrucibleLiquid ifluid, int am, ItemStack ip, ItemStack res) {
   super(string);
   input = ifluid;
   ArrayList<ItemStack> ores =
       OreDictionary.getOres(
           OreDictionary.getOreName(OreDictionary.getOreIDs(this.input.nugget)[0]));
   item1 = ores.toArray(new ItemStack[ores.size()]);
   inputItem = ip;
   resultItem = res;
   amount = am;
 }
예제 #13
0
  public int dyeColor(ItemStack stack) {
    int[] ids = OreDictionary.getOreIDs(stack);
    for (int id : ids) {
      for (int i = 0; i < dyes.length; i++) {
        if (OreDictionary.getOreName(id).equals(dyes[i])) {
          return i;
        }
      }
    }

    return -1;
  }
  public static CentrifugeRecipe getRecipe(Object input) {
    if (input instanceof ItemStack) {
      int[] oreIDs = OreDictionary.getOreIDs((ItemStack) input);
      for (CentrifugeRecipe r : recipes) {
        int[] otherIDs = null;

        if (r.getInput() instanceof ItemStack) {
          otherIDs = OreDictionary.getOreIDs((ItemStack) r.getInput());
        } else if (r.getInput() instanceof String) {
          otherIDs = new int[] {OreDictionary.getOreID((String) r.getInput())};
        }

        if (Util.checkArrays(oreIDs, otherIDs)
            || (r.getInput() instanceof ItemStack
                && ((ItemStack) input).isItemEqual((ItemStack) r.getInput()))) {
          if (r.getOutput() != null) return r;
        }
      }
    } else if (input instanceof String) {
      int[] oreIDs = new int[] {OreDictionary.getOreID((String) input)};
      for (CentrifugeRecipe r : recipes) {
        int[] otherIDs = null;

        if (r.getInput() instanceof ItemStack) {
          otherIDs = OreDictionary.getOreIDs((ItemStack) r.getInput());
        } else if (r.getInput() instanceof String) {
          otherIDs = new int[] {OreDictionary.getOreID((String) r.getInput())};
        }

        if (Util.checkArrays(oreIDs, otherIDs)) {
          if (r.getOutput() != null) return r;
        }
      }
    }

    return null;
  }
 public static ItemStack getItemStack(InventoryCrafting inventory) {
   ItemStack ret = null;
   boolean overflow = false;
   ItemStack mailbox = null;
   int color = -1;
   for (int i = 0; i < inventory.getSizeInventory(); ++i) {
     ItemStack stack = inventory.getStackInSlot(i);
     if (stack != null) {
       if (mailbox == null
           && stack.getItem() == Item.getItemFromBlock(MakersMark.getBlocks().mailBox)) {
         mailbox = stack;
       } else if (color == -1) {
         int[] ores = OreDictionary.getOreIDs(stack);
         for (int o = 0; o < ores.length && color == -1; ++o) {
           for (int c = 0; c < colorToOre.length && color == -1; ++c) {
             if (colorToOre[c] == ores[o]) {
               color = c;
             }
           }
         }
         if (color == -1) {
           overflow = true;
           break;
         }
       } else {
         overflow = true;
         break;
       }
     }
   }
   if (!overflow && mailbox != null && color != -1) {
     ret = mailbox.copy();
     NBTTagCompound tag = ret.getTagCompound();
     if (tag == null) {
       tag = new NBTTagCompound();
     }
     tag.setInteger(BlockMailbox.TAG_MAILBOX_COLOR, color);
     ret.setTagCompound(tag);
   }
   return ret;
 }
예제 #16
0
    public void setStack(int slot, ItemStack stack) {
      stacks[slot] = stack;

      if (stack != null) {
        stacks[slot] = stacks[slot].copy();
        stacks[slot].stackSize = 1;
      }

      if (slot == 0) {
        relatedItems.clear();
        ores.clear();

        if (stack == null) {
          isOre = false;
        } else {
          if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
            setClientPreviewLists();
          } else {
            isOre = OreDictionary.getOreIDs(stacks[0]).length > 0;
          }
        }
      }
    }
예제 #17
0
    private void setClientPreviewLists() {
      Item baseItem = stacks[0].getItem();

      int[] oreIds = OreDictionary.getOreIDs(stacks[0]);

      isOre = oreIds.length > 0;

      for (Object o : Item.itemRegistry) {
        Item item = (Item) o;
        boolean classMatch = classMatch(baseItem, item);

        List list = new LinkedList();

        for (CreativeTabs tab : item.getCreativeTabs()) {
          item.getSubItems(item, tab, list);
        }

        if (list.size() > 0) {
          for (Object ol : list) {
            ItemStack stack = (ItemStack) ol;

            if (classMatch
                && relatedItems.size() <= 7
                && !StackHelper.isMatchingItemOrList(stacks[0], stack)) {
              relatedItems.add(stack);
            }

            if (isOre
                && ores.size() <= 7
                && !StackHelper.isMatchingItemOrList(stacks[0], stack)
                && oreMatch(stacks[0], stack)) {
              ores.add(stack);
            }
          }
        }
      }
    }
예제 #18
0
  @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")));
      }
    }
  }
예제 #19
0
 public static boolean compareToOreName(ItemStack stack, String oreName) {
   for (int oid : OreDictionary.getOreIDs(stack))
     if (OreDictionary.getOreName(oid).equals(oreName)) return true;
   return false;
 }