Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
  }
 @Override
 public void setInventorySlotContents(int slotId, ItemStack itemstack) {
   super.setInventorySlotContents(slotId, itemstack);
   if (TileAdvancedCraftingTable.this.getWorldObj() == null
       || !TileAdvancedCraftingTable.this.getWorldObj().isRemote)
     oreIDs[slotId] = itemstack == null ? -1 : OreDictionary.getOreID(itemstack);
 }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
  boolean stackEqual(ItemStack toInsert, ItemStack existing) {
    if (toInsert == null || existing == null) {
      return false;
    }

    boolean matched = false;
    if (useOreDict) {
      int existingId = OreDictionary.getOreID(existing);
      matched = existingId != -1 && existingId == OreDictionary.getOreID(toInsert);
    }
    if (!matched) {
      matched = Item.getIdFromItem(toInsert.getItem()) == Item.getIdFromItem(existing.getItem());
      if (matched && matchMeta) {
        matched = toInsert.getItemDamage() == existing.getItemDamage();
      }
      if (matched && matchNBT) {
        matched = ItemStack.areItemStackTagsEqual(toInsert, existing);
      }
    }
    return matched;
  }
Ejemplo n.º 7
0
 /**
  * Returns the bonus item produced from a smelting operation in the infernal furnace
  *
  * @param in The input of the smelting operation. e.g. new ItemStack(oreGold)
  * @return the The bonus item that can be produced
  */
 public static ItemStack getSmeltingBonus(ItemStack in) {
   ItemStack out =
       smeltingBonus.get(Arrays.asList(Item.getIdFromItem(in.getItem()), in.getItemDamage()));
   if (out == null) {
     out =
         smeltingBonus.get(
             Arrays.asList(Item.getIdFromItem(in.getItem()), OreDictionary.WILDCARD_VALUE));
   }
   if (out == null) {
     String od = OreDictionary.getOreName(OreDictionary.getOreID(in));
     out = smeltingBonus.get(od);
   }
   return out;
 }
  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;
  }
Ejemplo n.º 9
0
 private boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy) {
   if (stack0 == null && stack1 != null) return false;
   if (stack0 != null && stack1 == null) return false;
   if (stack0 == null && stack1 == null) return true;
   boolean t1 = false;
   if (fuzzy) {
     t1 = true;
     int od = OreDictionary.getOreID(stack0);
     if (od != -1) {
       ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[] {});
       if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {stack1}, ores)) return true;
     }
   } else t1 = ItemStack.areItemStackTagsEqual(stack0, stack1);
   return stack0.itemID != stack1.itemID
       ? false
       : (stack0.getItemDamage() != stack1.getItemDamage()
           ? false
           : (stack0.stackSize > stack0.getMaxStackSize() ? false : t1));
 }
Ejemplo n.º 10
0
  @Override
  public boolean isItemValidForSlot(int i, ItemStack itemstack) {
    if (i == 0)
      return CompatibilityMgr.gregtechLoaded
          ? OreDictionary.getOreName(OreDictionary.getOreID(itemstack)).equals("lenseRuby")
          : Item.getItemFromBlock(Blocks.glass_pane) == itemstack.getItem() ? true : false;

    ForgeDirection front = RotatableBlock.getFront(this.getBlockMetadata());

    for (ForgeDirection f : VALID_INVENTORY_DIRECTIONS) {
      if (f == front) continue;

      TileEntity e =
          this.worldObj.getTileEntity(
              this.xCoord + f.offsetX, this.yCoord + f.offsetY, this.zCoord + f.offsetZ);

      // TODO: may cause inf loop
      if (e != null && e instanceof IInventory)
        if (i < ((IInventory) e).getSizeInventory())
          return ((IInventory) e).isItemValidForSlot(i, itemstack);
        else i -= ((IInventory) e).getSizeInventory();
    }
    return false;
  }
Ejemplo n.º 11
0
  public static void addOreDictionaryRecipes() {
    int oreId = OreDictionary.getOreID("ingotCopper");
    ArrayList<ItemStack> ingots = OreDictionary.getOres(oreId);
    if (!ingots.isEmpty()) {
      FurnaceRecipes.smelting()
          .addSmelting(
              ModObject.itemPowderIngot.actualId,
              PowderIngot.POWDER_COPPER.ordinal(),
              ingots.get(0),
              0);
    }
    oreId = OreDictionary.getOreID("ingotTin");
    ingots = OreDictionary.getOres(oreId);
    if (!ingots.isEmpty()) {
      FurnaceRecipes.smelting()
          .addSmelting(
              ModObject.itemPowderIngot.actualId,
              PowderIngot.POWDER_TIN.ordinal(),
              ingots.get(0),
              0);
    }

    ItemStack capacitor = new ItemStack(itemBasicCapacitor.actualId, 1, 0);
    ArrayList<ItemStack> copperIngots = OreDictionary.getOres("ingotCopper");
    Item gold;
    if (Config.useHardRecipes) {
      gold = Item.ingotGold;
    } else {
      gold = Item.goldNugget;
    }
    if (copperIngots != null && !copperIngots.isEmpty()) {
      GameRegistry.addRecipe(
          new ShapedOreRecipe(
              capacitor, " gr", "gcg", "rg ", 'r', Item.redstone, 'g', gold, 'c', "ingotCopper"));
    } else {
      GameRegistry.addShapedRecipe(
          capacitor, " gr", "gig", "rg ", 'r', Item.redstone, 'g', gold, 'i', Item.ingotIron);
    }

    int dustCoal = OreDictionary.getOreID("dustCoal");
    ItemStack activatedCapacitor = new ItemStack(itemBasicCapacitor.actualId, 1, 1);
    ItemStack electricalSteel =
        new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal());
    if (Config.useHardRecipes) {
      GameRegistry.addRecipe(
          new ShapedOreRecipe(
              activatedCapacitor,
              "eee",
              "cCc",
              "eee",
              'e',
              electricalSteel,
              'c',
              capacitor,
              'C',
              "dustCoal"));
    } else {
      GameRegistry.addRecipe(
          new ShapedOreRecipe(
              activatedCapacitor,
              " e ",
              "cCc",
              " e ",
              'e',
              electricalSteel,
              'c',
              capacitor,
              'C',
              "dustCoal"));
    }
  }
Ejemplo n.º 12
0
 public MCOreDictEntry(String id) {
   this.id = OreDictionary.getOreID(id);
 }
Ejemplo n.º 13
0
  public int getOreID() {

    return OreDictionary.getOreID(oreName);
  }
Ejemplo n.º 14
0
  public OreStack(ItemStack itemStack) {

    this(OreDictionary.getOreID(itemStack), itemStack.stackSize);
  }
 static {
   colorToOre[0] = OreDictionary.getOreID("dyeBlack");
   colorToOre[1] = OreDictionary.getOreID("dyeRed");
   colorToOre[2] = OreDictionary.getOreID("dyeGreen");
   colorToOre[3] = OreDictionary.getOreID("dyeBrown");
   colorToOre[4] = OreDictionary.getOreID("dyeBlue");
   colorToOre[5] = OreDictionary.getOreID("dyePurple");
   colorToOre[6] = OreDictionary.getOreID("dyeCyan");
   colorToOre[7] = OreDictionary.getOreID("dyeLightGray");
   colorToOre[8] = OreDictionary.getOreID("dyeGray");
   colorToOre[9] = OreDictionary.getOreID("dyePink");
   colorToOre[10] = OreDictionary.getOreID("dyeLime");
   colorToOre[11] = OreDictionary.getOreID("dyeYellow");
   colorToOre[12] = OreDictionary.getOreID("dyeLightBlue");
   colorToOre[13] = OreDictionary.getOreID("dyeMagenta");
   colorToOre[14] = OreDictionary.getOreID("dyeOrange");
   colorToOre[15] = OreDictionary.getOreID("dyeWhite");
 }
Ejemplo n.º 16
0
 public static boolean stackMatchesOre(ItemStack stack, String name) {
   int id = OreDictionary.getOreID(stack);
   return id == OreDictionary.getOreID(name);
 }
Ejemplo n.º 17
0
 public static boolean testOreBlock(String testOre, BlockPos testPos, IBlockAccess worldObj) {
   return testOreBlock(OreDictionary.getOreID(testOre), testPos, worldObj);
 }
Ejemplo n.º 18
0
 public static boolean testOre(String testOre, ItemStack testItem) {
   return testOre(OreDictionary.getOreID(testOre), testItem);
 }