Пример #1
0
  @Override
  public ItemStack getCraftingResult(InventoryCrafting var1) {
    ItemStack lens = null;
    int color = -1;

    for (int i = 0; i < var1.getSizeInventory(); i++) {
      ItemStack stack = var1.getStackInSlot(i);
      if (stack != null) {
        if (stack.getItem() instanceof ILens && lens == null) lens = stack;
        else
          color =
              getStackColor(
                  stack); // We can assume if its not a lens its a dye because we checked it in
                          // matches()
      }
    }

    if (lens.getItem() instanceof ILens) {
      lens.getItem();
      ItemStack lensCopy = lens.copy();
      ItemLens.setLensColor(lensCopy, color);

      return lensCopy;
    }

    return null;
  }
  /** Used to check if a recipe matches current crafting inventory */
  public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) {
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) {
      ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j);

      if (itemstack1 != null) {
        if (itemstack1.getItem() == Items.filled_map) {
          if (itemstack != null) {
            return false;
          }

          itemstack = itemstack1;
        } else {
          if (itemstack1.getItem() != Items.map) {
            return false;
          }

          ++i;
        }
      }
    }

    return itemstack != null && i > 0;
  }
 @Override
 public ItemStack getCraftingResult(InventoryCrafting inv) {
   ItemStack jerrycan = null;
   ItemStack container = null;
   FluidStack fs = null;
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack stackInSlot = inv.getStackInSlot(i);
     if (stackInSlot != null)
       if (jerrycan == null
           && IEContent.itemJerrycan.equals(stackInSlot.getItem())
           && FluidUtil.getFluidContained(stackInSlot) != null) {
         jerrycan = stackInSlot;
         fs = FluidUtil.getFluidContained(jerrycan);
       } else if (container == null && FluidUtil.getFluidHandler(stackInSlot) != null)
         container = stackInSlot;
   }
   if (fs != null && container != null) {
     ItemStack newContainer = Utils.copyStackWithAmount(container, 1);
     IFluidHandler handler = FluidUtil.getFluidHandler(newContainer);
     int accepted = handler.fill(fs, false);
     if (accepted > 0) {
       handler.fill(fs, true);
       //				FluidUtil.getFluidHandler(jerrycan).drain(accepted,true);
       ItemNBTHelper.setInt(jerrycan, "jerrycanDrain", accepted);
     }
     return newContainer;
   }
   return null;
 }
  @Override
  public boolean matches(InventoryCrafting inventoryCrafting, World world) {

    ItemStack itemStack = null;
    ArrayList<ItemStack> arrayList = new ArrayList<ItemStack>();

    for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) {

      ItemStack currentStack = inventoryCrafting.getStackInSlot(i);

      if (currentStack != null) {

        if (currentStack.getItem() instanceof ItemAlchemicalBag) {

          if (itemStack != null) return false;

          itemStack = currentStack;
        } else {

          if (currentStack.itemID != Item.dyePowder.itemID) return false;

          arrayList.add(currentStack);
        }
      }
    }

    return itemStack != null && !arrayList.isEmpty();
  }
Пример #5
0
  /** Used to check if a recipe matches current crafting inventory */
  public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) {
    int var3 = 0;
    ItemStack var4 = null;

    for (int var5 = 0; var5 < par1InventoryCrafting.getSizeInventory(); ++var5) {
      ItemStack var6 = par1InventoryCrafting.getStackInSlot(var5);

      if (var6 != null) {
        if (var6.getItem() == Items.written_book) {
          if (var4 != null) {
            return false;
          }

          var4 = var6;
        } else {
          if (var6.getItem() != Items.writable_book) {
            return false;
          }

          ++var3;
        }
      }
    }

    return var4 != null && var3 > 0;
  }
Пример #6
0
  @Override
  public ItemStack getCraftingResult(InventoryCrafting var1) {
    ItemStack lens = null;
    ItemStack secondLens = null;

    for (int i = 0; i < var1.getSizeInventory(); i++) {
      ItemStack stack = var1.getStackInSlot(i);
      if (stack != null) {
        if (stack.getItem() instanceof ILens)
          if (lens == null) lens = stack;
          else secondLens = stack;
      }
    }

    if (lens.getItem() instanceof ILens) {
      ILens lensItem = (ILens) lens.getItem();
      if (secondLens == null
          || !lensItem.canCombineLenses(lens, secondLens)
          || lensItem.getCompositeLens(lens) != null
          || lensItem.getCompositeLens(secondLens) != null) return null;

      ItemStack lensCopy = lens.copy();
      ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens);

      return lensCopy;
    }

    return null;
  }
  @Override
  public boolean pushPattern(
      final ICraftingPatternDetails patternDetails,
      final InventoryCrafting table,
      final ForgeDirection where) {
    if (this.myPattern == null) {
      boolean isEmpty = true;
      for (int x = 0; x < this.inv.getSizeInventory(); x++) {
        isEmpty = this.inv.getStackInSlot(x) == null && isEmpty;
      }

      if (isEmpty && patternDetails.isCraftable()) {
        this.forcePlan = true;
        this.myPlan = patternDetails;
        this.pushDirection = where;

        for (int x = 0; x < table.getSizeInventory(); x++) {
          this.inv.setInventorySlotContents(x, table.getStackInSlot(x));
        }

        this.updateSleepiness();
        this.markDirty();
        return true;
      }
    }
    return false;
  }
  /** Find recipes excluding one or more recipe types */
  public static ItemStack findMatchingRecipeExcluding(
      InventoryCrafting inv, World world, Class... excluding) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;
    List recipes = CraftingManager.getInstance().getRecipeList();

    for (j = 0; j < inv.getSizeInventory(); ++j) {
      ItemStack itemstack2 = inv.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamage(); // getItemDamageForDisplay
      int k = item.getMaxDamage() - itemstack1.getItemDamage();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) recipes.get(j);

        // 1.1.1 Botania fix (try catch)
        try {
          if ((!Arrays.asList(excluding).contains(irecipe.getClass()))
              && irecipe.matches(inv, world)) {
            return irecipe.getCraftingResult(inv);
          }
        } catch (Exception e) {
        }
      }

      return null;
    }
  }
Пример #9
0
 @Override
 public boolean matches(InventoryCrafting inv, World world) {
   if (Settings.SwordEffects) {
     for (int i = 0; i < inv.getSizeInventory(); i++) {
       ItemStack s = inv.getStackInSlot(i);
       if (s != null && s.getItem() instanceof ItemSword) {
         for (int j = 0; j < inv.getSizeInventory(); j++) {
           ItemStack s2 = inv.getStackInSlot(j);
           if (s2 != null && s2.getItem() instanceof MoleculeItem) {
             if (PharmacologyEffectRegistry.hasEffect(MoleculeEnum.getById(s2.getItemDamage()))) {
               return true;
             }
           }
         }
       }
     }
   }
   return false;
 }
Пример #10
0
  @Override
  public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
    ItemStack[] aitemstack = new ItemStack[inventoryCrafting.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i) {
      ItemStack itemstack = inventoryCrafting.getStackInSlot(i);
      aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
    }

    return aitemstack;
  }
  private ItemStack getAndUpdateOutput() {
    final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);

    for (int x = 0; x < ic.getSizeInventory(); x++) {
      ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
    }

    final ItemStack is =
        CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
    this.cOut.setInventorySlotContents(0, is);
    return is;
  }
Пример #12
0
  public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) {
    int var3 = 0;
    ItemStack var4 = null;
    ItemStack var5 = null;

    for (int var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6) {
      ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);

      if (var7 != null) {
        if (var3 == 0) {
          var4 = var7;
        }

        if (var3 == 1) {
          var5 = var7;
        }

        ++var3;
      }
    }

    if (var3 == 2
        && var4.itemID == var5.itemID
        && var4.stackSize == 1
        && var5.stackSize == 1
        && Item.itemsList[var4.itemID].isRepairable()) {
      Item var13 = Item.itemsList[var4.itemID];
      int var14 = var13.getMaxDamage() - var4.getItemDamageForDisplay();
      int var8 = var13.getMaxDamage() - var5.getItemDamageForDisplay();
      int var9 = var14 + var8 + var13.getMaxDamage() * 5 / 100;
      int var10 = var13.getMaxDamage() - var9;

      if (var10 < 0) {
        var10 = 0;
      }

      return new ItemStack(var4.itemID, 1, var10);
    } else {
      Iterator var11 = this.recipes.iterator();
      IRecipe var12;

      do {
        if (!var11.hasNext()) {
          return null;
        }

        var12 = (IRecipe) var11.next();
      } while (!var12.matches(par1InventoryCrafting, par2World));

      return var12.getCraftingResult(par1InventoryCrafting);
    }
  }
 @Override
 public ItemStack getCraftingResult(InventoryCrafting aGrid) {
   ItemStack rStack = super.getCraftingResult(aGrid);
   if (rStack != null) {
     for (int i = 0; i < aGrid.getSizeInventory(); i++) {
       if (aGrid.getStackInSlot(i) != null && aGrid.getStackInSlot(i).hasTagCompound()) {
         rStack.setTagCompound((NBTTagCompound) aGrid.getStackInSlot(i).getTagCompound().copy());
         break;
       }
     }
   }
   return rStack;
 }
Пример #14
0
  @Override
  public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) {
    ItemStack itemstack = this.getRecipeOutput().copy();

    for (int i = 0; i < p_77572_1_.getSizeInventory(); ++i) {
      ItemStack itemstack1 = p_77572_1_.getStackInSlot(i);

      if (itemstack1 != null && itemstack1.hasTagCompound()) {
        itemstack.setTagCompound((NBTTagCompound) itemstack1.getTagCompound().copy());
      }
    }

    return itemstack;
  }
  public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;

    for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) {
      ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
      int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < this.recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) this.recipes.get(j);

        if (irecipe.matches(par1InventoryCrafting, par2World)) {
          return irecipe.getCraftingResult(par1InventoryCrafting);
        }
      }

      return null;
    }
  }
  /** Returns an Item that is the result of this recipe */
  public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) {
    ItemStack itemstack = this.getRecipeOutput().copy();

    if (this.field_92101_f) {
      for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) {
        ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i);

        if (itemstack1 != null && itemstack1.hasTagCompound()) {
          itemstack.setTagCompound((NBTTagCompound) itemstack1.stackTagCompound.copy());
        }
      }
    }

    return itemstack;
  }
Пример #17
0
 @Override
 public ItemStack getCraftingResult(InventoryCrafting inv) {
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack s = inv.getStackInSlot(i);
     if (s != null && s.getItem() instanceof ItemSword) {
       for (int j = 0; j < inv.getSizeInventory(); j++) {
         ItemStack s2 = inv.getStackInSlot(j);
         if (s2 != null
             && s2.getItem() instanceof MoleculeItem
             && PharmacologyEffectRegistry.hasEffect(MoleculeEnum.getById(s2.getItemDamage()))) {
           NBTTagList l = s2.getEnchantmentTagList();
           int level = 0;
           if (l != null) {
             for (int k = 0; k < l.tagCount(); k++) {
               NBTTagCompound tag = l.getCompoundTagAt(k);
               if (tag.getShort("id")
                   == PotionEnchantmentCoated.chemLookup.get(
                           MoleculeEnum.getById(s2.getItemDamage()))
                       .effectId) {
                 level = tag.getShort("lvl");
                 ItemStack result = s.copy();
                 result.getEnchantmentTagList().getCompoundTagAt(k).setInteger("lvl", level + 1);
               }
             }
           }
           ItemStack result = s.copy();
           result.addEnchantment(
               PotionEnchantmentCoated.chemLookup.get(MoleculeEnum.getById(s2.getItemDamage())),
               1);
           return result;
         }
       }
     }
   }
   return null;
 }
 @Override
 public boolean matches(InventoryCrafting var1, World var2) {
   this.newStack = null;
   for (int j = 0; j < var1.getSizeInventory(); j++) {
     if (var1.getStackInSlot(j) == null && recipeItems[j] != null) {
       return false;
     }
     if (var1.getStackInSlot(j) != null && var1.getStackInSlot(j).getItem() != recipeItems[j]) {
       return false;
     }
   }
   this.newStack = new ItemStack(UniversalCoinsServer.proxy.itemEnderCard);
   this.newStack.setTagCompound(var1.getStackInSlot(4).getTagCompound());
   return true;
 }
 @Override
 public boolean matches(InventoryCrafting aGrid, World aWorld) {
   ItemStack tStack = null;
   for (int i = 0; i < aGrid.getSizeInventory(); i++) {
     if (aGrid.getStackInSlot(i) != null) {
       if (tStack != null) {
         if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound())
             || (tStack.hasTagCompound()
                 && !tStack.getTagCompound().equals(aGrid.getStackInSlot(i).getTagCompound())))
           return false;
       }
       tStack = aGrid.getStackInSlot(i);
     }
   }
   return super.matches(aGrid, aWorld);
 }
  @Override
  public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) {

    ItemStack item = null;
    ItemStack icon = null;

    for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) {
      ItemStack stack = inventorycrafting.getStackInSlot(i);

      if (stack != null) {
        if (stack.getItem() == BattlegearConfig.heradricItem) {
          icon = stack;
        } else if (stack.getItem() == heraldricWeapon) {
          item = stack;
        } else if (stack.getItem() == Items.water_bucket) {
          icon = stack;
        }
      }
    }
    if (item == null) return null;

    item = item.copy();

    if (heraldricWeapon instanceof IHeraldryItem) {
      byte[] code = SigilHelper.getDefault();
      if (icon.getItem() == BattlegearConfig.heradricItem) {
        code = ((IHeraldryItem) icon.getItem()).getHeraldry(icon);
      }
      ((IHeraldryItem) heraldricWeapon).setHeraldry(item, code);
    } else {

      NBTTagCompound compound = item.getTagCompound();
      if (compound == null) {
        compound = new NBTTagCompound();
      }
      if (icon.getItem() == BattlegearConfig.heradricItem) {
        byte[] code = ((IHeraldryItem) icon.getItem()).getHeraldry(icon);
        compound.setByteArray("hc2", code);
        item.setTagCompound(compound);
      } else { // should be a bucket
        if (compound.hasKey("hc2")) {
          compound.removeTag("hc2");
        }
      }
    }
    return item;
  }
Пример #21
0
 @Override
 public boolean matches(InventoryCrafting crafting, World world) {
   boolean hasArmor = false;
   boolean hasDyes = false;
   for (int i = 0; i < crafting.getSizeInventory(); i++) {
     ItemStack stack = crafting.getStackInSlot(i);
     if (stack == null) continue;
     IDyeableItem dyeable =
         ((stack.getItem() instanceof IDyeableItem) ? (IDyeableItem) stack.getItem() : null);
     if ((dyeable != null) && dyeable.canDye(stack)) {
       if (hasArmor) return false;
       hasArmor = true;
     } else if (DyeUtils.isDye(stack)) hasDyes = true;
     else return false;
   }
   return (hasArmor && hasDyes);
 }
Пример #22
0
  public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) {
    boolean record = false;
    boolean eye = false;

    for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) {
      ItemStack itemStack = par1InventoryCrafting.getStackInSlot(i);
      if (itemStack == null) continue;
      else if (itemStack.getItem() instanceof ItemRecord)
        if (record) return false;
        else record = true;
      else if (itemStack.getItem() == Items.ender_eye)
        if (eye) return false;
        else eye = true;
    }

    return record && eye;
  }
Пример #23
0
  @Override
  public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) {
    ItemStack bowStack = null;
    ItemStack flintStack = null;
    ItemStack boneStack = null;
    for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) {
      ItemStack stack = inventorycrafting.getStackInSlot(i);
      if (stack != null) {
        if (stack.getItem() == Item.bow && bowStack == null) {
          bowStack = stack;
          continue;
        } else if (stack.getItem() == Item.flint && flintStack == null) {
          flintStack = stack;
          continue;
        } else if (stack.getItem() == Item.bone && boneStack == null) {
          boneStack = stack;
          continue;
        }
        return null;
      }
    }

    if (bowStack != null) {
      ItemStack clone = bowStack.copy();
      NBTTagCompound tag = clone.getTagCompound();
      if (tag == null) {
        tag = new NBTTagCompound();
      }
      if (flintStack == null && boneStack == null) {
        return null;
      }
      if (flintStack == null) {
        // System.out.println("clear torch mode");
        tag.setBoolean("openblocks_torchmode", false);
        clone.setTagCompound(tag);
        return clone;
      } else if (boneStack == null) {
        // System.out.println("torch mode");
        tag.setBoolean("openblocks_torchmode", true);
        clone.setTagCompound(tag);
        return clone;
      }
    }
    return null;
  }
Пример #24
0
  @Override
  public boolean matches(InventoryCrafting var1, World var2) {
    boolean foundLens = false;
    boolean foundSecondLens = false;
    boolean foundSlimeball = false;

    for (int i = 0; i < var1.getSizeInventory(); i++) {
      ItemStack stack = var1.getStackInSlot(i);
      if (stack != null) {
        if (stack.getItem() instanceof ILens && !foundSecondLens) {
          if (foundLens) foundSecondLens = true;
          else foundLens = true;
        } else if (stack.getItem() == Items.slime_ball) foundSlimeball = true;
        else return false; // Found an invalid item, breaking the recipe
      }
    }

    return foundSecondLens && foundSlimeball;
  }
Пример #25
0
  @Override
  public ItemStack getCraftingResult(InventoryCrafting crafting) {
    ItemStack stack = this.getRecipeOutput().copy();
    int level = 0;
    boolean flag = false;
    Tuple<String, AttributeModifier>[] tuples = new Tuple[5];

    for (int i = 0; i < crafting.getSizeInventory(); i++) {
      ItemStack stack2 = crafting.getStackInSlot(i);

      if (stack2 != null && stack2.getItem() instanceof ItemAmulet) {
        if (stack2.hasTagCompound() && stack2.getTagCompound().hasKey("amuletLevel")) {
          int level2 = stack2.getTagCompound().getInteger("amuletLevel");
          if (level2 < 1) level2 = 1;

          if (!flag) {
            level = level2;
            flag = true;
          } else {
            level += 1;
            break;
          }
        }

        Multimap mmap = stack2.getAttributeModifiers();
        Iterator ite = mmap.entries().iterator();
        int j = 0;

        while (ite.hasNext()) {
          Entry entry = (Entry) ite.next();
          AttributeModifier mod = (AttributeModifier) entry.getValue();
          if (j < 5) tuples[j++] = new Tuple(entry.getKey(), mod);
        }
      }
    }

    if (level > 3) level = 3;
    if (!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound();
    applyModifiersToItemStack(stack, tuples);
    stack.stackTagCompound.setInteger("amuletLevel", level);

    return stack;
  }
Пример #26
0
  @Override
  public boolean matches(InventoryCrafting inventoryCrafting, World world) {
    boolean record = false;
    boolean eye = false;

    for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) {
      ItemStack itemStack = inventoryCrafting.getStackInSlot(i);
      if (itemStack == null) continue;

      if (itemStack.getItem() instanceof ItemRecord)
        if (record) return false;
        else record = true;
      else if (itemStack.getItem() == Items.ENDER_EYE)
        if (eye) return false;
        else eye = true;
    }

    return record && eye;
  }
Пример #27
0
 /** クラフティングインベントリがレシピに適合しているか。 */
 @SuppressWarnings("unchecked")
 @Override
 public boolean matches(InventoryCrafting inv, World world) {
   ArrayList<ItemStack> required = new ArrayList<>(input);
   for (int x = 0; x < inv.getSizeInventory(); x++) {
     ItemStack slot = inv.getStackInSlot(x);
     if (slot == null) continue;
     boolean inRecipe = false;
     for (ItemStack aRequired : required) {
       if (!OreDictionary.itemMatches(aRequired, slot, false)) continue;
       inRecipe = true;
       required.remove(aRequired);
       break;
     }
     if (!inRecipe) {
       return false;
     }
   }
   return required.isEmpty();
 }
 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;
 }
Пример #29
0
 @Override
 public ItemStack getCraftingResult(InventoryCrafting crafting) {
   ItemStack armor = null;
   IDyeableItem dyeable = null;
   List<ItemStack> dyes = new ArrayList<ItemStack>();
   for (int i = 0; i < crafting.getSizeInventory(); i++) {
     ItemStack stack = crafting.getStackInSlot(i);
     if (stack == null) continue;
     dyeable = ((stack.getItem() instanceof IDyeableItem) ? (IDyeableItem) stack.getItem() : null);
     if ((dyeable != null) && dyeable.canDye(stack)) {
       if (armor != null) return null;
       armor = stack.copy();
     } else if (DyeUtils.isDye(stack)) dyes.add(stack);
     else return null;
   }
   if (dyes.isEmpty()) return null;
   int oldColor = StackUtils.get(armor, -1, "display", "color");
   int newColor = DyeUtils.getColorFromDyes(oldColor, dyes);
   StackUtils.set(armor, newColor, "display", "color");
   return armor;
 }
Пример #30
0
  @Override
  public boolean matches(InventoryCrafting var1, World var2) {
    boolean foundLens = false;
    boolean foundDye = false;

    for (int i = 0; i < var1.getSizeInventory(); i++) {
      ItemStack stack = var1.getStackInSlot(i);
      if (stack != null) {
        if (stack.getItem() instanceof ILens && !foundLens) foundLens = true;
        else if (!foundDye) {
          int color = getStackColor(stack);
          if (color > -1) foundDye = true;
          else return false;
        } else
          return false; // This means we have an additional item in the recipe after the lens and
                        // dye
      }
    }

    return foundLens && foundDye;
  }