public static boolean canInsertStackIntoInventory(
     IInventory inventory, ItemStack stack, int side) {
   if (stack == null || inventory == null) return false;
   if (inventory instanceof ISidedInventory) {
     ISidedInventory sidedInv = (ISidedInventory) inventory;
     int slots[] = sidedInv.getAccessibleSlotsFromSide(side);
     if (slots == null) return false;
     for (int i = 0; i < slots.length && stack != null; i++) {
       if (sidedInv.canInsertItem(slots[i], stack, side)
           && sidedInv.isItemValidForSlot(slots[i], stack)) {
         ItemStack existingStack = inventory.getStackInSlot(slots[i]);
         if (existingStack == null) return true;
         else if (OreDictionary.itemMatches(existingStack, stack, true)
             && ItemStack.areItemStackTagsEqual(stack, existingStack))
           if (existingStack.stackSize + stack.stackSize < inventory.getInventoryStackLimit()
               && existingStack.stackSize + stack.stackSize < existingStack.getMaxStackSize())
             return true;
       }
     }
   } else {
     int invSize = inventory.getSizeInventory();
     for (int i = 0; i < invSize && stack != null; i++)
       if (inventory.isItemValidForSlot(i, stack)) {
         ItemStack existingStack = inventory.getStackInSlot(i);
         if (existingStack == null) return true;
         else if (OreDictionary.itemMatches(existingStack, stack, true)
             && ItemStack.areItemStackTagsEqual(stack, existingStack))
           if (existingStack.stackSize + stack.stackSize < inventory.getInventoryStackLimit()
               && existingStack.stackSize + stack.stackSize < existingStack.getMaxStackSize())
             return true;
       }
   }
   return false;
 }
 @Override
 public void undo() {
   List<ItemStack> ores = OreDictionary.getOres(idTarget);
   for (ItemStack stack : OreDictionary.getOres(idSource)) {
     ores.remove(stack);
   }
 }
 @Override
 public String describeUndo() {
   return "Undoing mirror of "
       + OreDictionary.getOreName(idSource)
       + " to "
       + OreDictionary.getOreName(idTarget);
 }
 @Override
 public String describe() {
   return "Mirroring "
       + OreDictionary.getOreName(idSource)
       + " to "
       + OreDictionary.getOreName(idTarget);
 }
 public static ItemStack insertStackIntoInventory(
     IInventory inventory, ItemStack stack, int side) {
   if (stack == null || inventory == null) return null;
   int stackSize = stack.stackSize;
   if (inventory instanceof ISidedInventory) {
     ISidedInventory sidedInv = (ISidedInventory) inventory;
     int slots[] = sidedInv.getAccessibleSlotsFromSide(side);
     if (slots == null) return stack;
     for (int i = 0; i < slots.length && stack != null; i++) {
       if (sidedInv.canInsertItem(slots[i], stack, side)) {
         ItemStack existingStack = inventory.getStackInSlot(slots[i]);
         if (OreDictionary.itemMatches(existingStack, stack, true)
             && ItemStack.areItemStackTagsEqual(stack, existingStack))
           stack = addToOccupiedSlot(sidedInv, slots[i], stack, existingStack);
       }
     }
     for (int i = 0; i < slots.length && stack != null; i++)
       if (inventory.getStackInSlot(slots[i]) == null
           && sidedInv.canInsertItem(slots[i], stack, side))
         stack = addToEmptyInventorySlot(sidedInv, slots[i], stack);
   } else {
     int invSize = inventory.getSizeInventory();
     for (int i = 0; i < invSize && stack != null; i++) {
       ItemStack existingStack = inventory.getStackInSlot(i);
       if (OreDictionary.itemMatches(existingStack, stack, true)
           && ItemStack.areItemStackTagsEqual(stack, existingStack))
         stack = addToOccupiedSlot(inventory, i, stack, existingStack);
     }
     for (int i = 0; i < invSize && stack != null; i++)
       if (inventory.getStackInSlot(i) == null)
         stack = addToEmptyInventorySlot(inventory, i, stack);
   }
   if (stack == null || stack.stackSize != stackSize) inventory.markDirty();
   return stack;
 }
  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;
  }
 @Override
 public String describe() {
   return "Copying contents of ore dictionary entry "
       + OreDictionary.getOreName(idSource)
       + " to "
       + OreDictionary.getOreName(idTarget);
 }
 @Override
 public void apply() {
   List<ItemStack> ores = OreDictionary.getOres(idTarget);
   for (ItemStack stack : OreDictionary.getOres(idSource)) {
     ores.add(stack);
   }
 }
  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;
  }
 @Override
 public String describeUndo() {
   return "Removing contents of ore dictionary entry "
       + OreDictionary.getOreName(idSource)
       + " from "
       + OreDictionary.getOreName(idTarget);
 }
  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;
  }
Beispiel #12
0
  public static ItemStack getDustForOre(ItemStack item) {
    String oreName = OreDictionary.getOreName(OreDictionary.getOreID(item));

    if (oreName.contains("ore")) {
      String lowercaseOre = oreName.toLowerCase();
      boolean isAllowed = false;

      for (String str : AlchemicalWizardry.allowedCrushedOresArray) {
        String testStr = str.toLowerCase();

        if (lowercaseOre.contains(testStr)) {
          isAllowed = true;
          break;
        }
      }

      if (!isAllowed) {
        return null;
      }

      String dustName = oreName.replace("ore", "dust");

      ArrayList<ItemStack> items = OreDictionary.getOres(dustName);

      if (items != null && items.size() >= 1) {
        return (items.get(0).copy());
      }
    }

    return null;
  }
 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));
 }
Beispiel #14
0
  private void registerOres() {
    OreDictionary.registerOre("orePlutonium", new ItemStack(orePlasma, 1, plutoniumMeta));
    OreDictionary.registerOre("oreUranium", new ItemStack(orePlasma, 1, uraniumMeta));

    OreDictionary.registerOre("ingotPlutonium", new ItemStack(ingotPlutonium, 1));
    OreDictionary.registerOre("ingotUranium", new ItemStack(ingotUranium, 1));
  }
Beispiel #15
0
 @Override
 public void generateOreDictEntries() {
   OreDictionary.registerOre("oreSalt", new ItemStack(saltOre));
   OreDictionary.registerOre("orePlatinum", new ItemStack(platinumOre));
   OreDictionary.registerOre("oreLead", new ItemStack(leadOre));
   OreDictionary.registerOre("oreCinnabar", new ItemStack(cinnabarOre));
   OreDictionary.registerOre("oreCarobbiite", new ItemStack(carobbiiteOre));
 }
Beispiel #16
0
 public static List<ItemStack> getAllDyeStacks() {
   List<ItemStack> stacks = new ArrayList<ItemStack>();
   for (int i = 0; i < ItemDye.dyeColors.length; i++) {
     stacks.addAll(
         OreDictionary.getOres(OreDictionary.getOreID(new ItemStack(Item.dyePowder, 1, i))));
   }
   return stacks;
 }
 @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;
 }
  private static void registerBlocks() {
    RegisterHelper.registerBlock(DeimosBlocks.deimos_block, ItemBlockDeimos.class);

    OreDictionary.registerOre("oreTin", new ItemStack(DeimosBlocks.deimos_block, 1, 4));
    OreDictionary.registerOre("oreCopper", new ItemStack(DeimosBlocks.deimos_block, 1, 5));
    OreDictionary.registerOre("oreIron", new ItemStack(DeimosBlocks.deimos_block, 1, 6));
    OreDictionary.registerOre("oreDesh", new ItemStack(DeimosBlocks.deimos_block, 1, 7));
  }
Beispiel #19
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;
  }
 public boolean matches(String oreDict) {
   ArrayList<ItemStack> stacks = OreDictionary.getOres(oreDict);
   for (ItemStack stack : stacks) {
     if (OreDictionary.itemMatches(stack, input, false)) {
       return true;
     }
   }
   return false;
 }
 private boolean matches(String oreDict) {
   ArrayList<ItemStack> stacks = OreDictionary.getOres(oreDict);
   for (ItemStack stack : stacks) {
     if (OreDictionary.itemMatches(stack, input, false)
         && ingredient.isItemEqual(this.ingredient)) {
       return true;
     }
   }
   return false;
 }
  public static InfuserRecipe addRecipe(String first, String second, ItemStack result) {
    List<ItemStack> firstOreList = OreDictionary.getOres(first);
    List<ItemStack> secondOreList = OreDictionary.getOres(second);

    if (firstOreList.size() > 0 && secondOreList.size() > 0) {
      return addRecipe(firstOreList.get(0), secondOreList.get(0), result);
    }

    return null;
  }
 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);
 }
Beispiel #24
0
  @Override
  public boolean addRecipe(Recipe recipe) {
    //	GameRegistry.addRecipe((IRecipe) recipe);
    if (recipe instanceof ShapedRecipe) {
      ShapedRecipe r = (ShapedRecipe) recipe;
      boolean useOreDict = false;
      // Map<Character,net.minecraft.item.ItemStack> nmsRecipe = Maps.newHashMap();
      List<Object> objRecipe = new ArrayList<Object>();
      objRecipe.addAll(Arrays.asList(r.getShape()));
      for (Character j : r.getIngredientMap().keySet()) {
        ItemStack x = r.getIngredientMap().get(j);
        net.minecraft.item.ItemStack nms = CraftItemStack.createNMSItemStack(x);
        if (OreDictionary.getOreID(nms) != -1) {
          useOreDict = true;
        }
        if (LiquidContainerRegistry.isContainer(nms)) {
          useOreDict = true;
        }
        objRecipe.add(j);
        objRecipe.add(nms);
      }

      if (useOreDict) {
        ShapedOreRecipe rec =
            new ShapedOreRecipe(CraftItemStack.createNMSItemStack(recipe.getResult()), objRecipe);
        GameRegistry.addRecipe(rec);
      } else {
        GameRegistry.addRecipe(CraftItemStack.createNMSItemStack(recipe.getResult()), objRecipe);
      }
    } else if (recipe instanceof ShapelessRecipe) {
      ShapelessRecipe r = (ShapelessRecipe) recipe;
      List<net.minecraft.item.ItemStack> items = new ArrayList<net.minecraft.item.ItemStack>();
      boolean useOreDict = false;
      for (ItemStack i : r.getIngredientList()) {
        net.minecraft.item.ItemStack nms = CraftItemStack.createNMSItemStack(i);
        if (OreDictionary.getOreID(nms) != -1) {
          useOreDict = true;
        }
        if (LiquidContainerRegistry.isContainer(nms)) {
          useOreDict = true;
        }
        items.add(nms);
      }
      if (useOreDict) {
        // TODO: Check if the new Class is even required
        // ShapelessOreRecipe nmsRec =
        new ShapelessOreRecipe(CraftItemStack.createNMSItemStack(recipe.getResult()), items);
      } else {
        ShapelessRecipes nmsRec =
            new ShapelessRecipes(CraftItemStack.createNMSItemStack(recipe.getResult()), items);
        GameRegistry.addRecipe(nmsRec);
      }
    }
    return true;
  }
 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;
 }
Beispiel #26
0
  /** Takes an ItemStack of OreDictionary dye and returns the vanilla Dye Id for that color */
  public static int getVanillaColorId(ItemStack mOre) {
    if (mOre == null) return -1;

    for (int i = 0; i < 16; i++) {
      if (OreDictionary.getOreID(new ItemStack(Item.dyePowder, 1, i))
          == OreDictionary.getOreID(mOre)) {
        return i;
      }
    }
    return -1;
  }
  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 boolean stackMatchesObject(ItemStack stack, Object o) {
   if (o instanceof ItemStack) return OreDictionary.itemMatches((ItemStack) o, stack, false);
   else if (o instanceof ArrayList) {
     for (Object io : (ArrayList) o)
       if (io instanceof ItemStack && OreDictionary.itemMatches((ItemStack) io, stack, false))
         return true;
   } else if (o instanceof ItemStack[]) {
     for (ItemStack io : (ItemStack[]) o)
       if (OreDictionary.itemMatches((ItemStack) io, stack, false)) return true;
   } else if (o instanceof String) return compareToOreName(stack, (String) o);
   return false;
 }
Beispiel #29
0
 public static void OreRegistry() {
   OreDictionary.registerOre("ingotCopper", new ItemStack(MTCore.copperIngot));
   OreDictionary.registerOre("ingotAluminium", new ItemStack(MTCore.aluminiumIngot));
   OreDictionary.registerOre("ingotSteel", new ItemStack(MTCore.steelIngot));
   OreDictionary.registerOre("ingotCarbonSteel", new ItemStack(MTCore.carbonsteelIngot));
   OreDictionary.registerOre("ingotTitanium", new ItemStack(MTCore.titaniumIngot));
   OreDictionary.registerOre("oreCopper", MTCore.copperOre);
   OreDictionary.registerOre("oreAluminium", MTCore.bauxiteOre);
   OreDictionary.registerOre("oreMagnesium", MTCore.dolomite);
   OreDictionary.registerOre("oreTitanium", MTCore.titaniumOre);
   OreDictionary.registerOre("oreUranium", MTCore.uraninite);
 }
 @Override
 public boolean canExtractItem(int slot, ItemStack stack, int side) {
   if (!formed || pos != 4 || slot != 1 || stack == null) return false;
   TileEntitySilo master = master();
   if (master != null)
     return master.outputStack != null
         && OreDictionary.itemMatches(master.identStack, stack, true)
         && ItemStack.areItemStackTagsEqual(stack, master.identStack);
   else
     return this.outputStack != null
         && OreDictionary.itemMatches(identStack, stack, true)
         && ItemStack.areItemStackTagsEqual(stack, identStack);
 }