/** 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; }
@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; }
@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(); }
@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 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 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; }
/** 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; }
/** 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; } }
@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; }
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; }
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; } }
@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; }
@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; }
/** 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; }
/** Used to check if a recipe matches current crafting inventory */ @Override public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { this.enchantedBook = null; this.tool = null; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); if (itemstack != null) { if (Item.getIdFromItem(itemstack.getItem()) == Item.getIdFromItem(Items.enchanted_book)) { if (this.enchantedBook != null) return false; this.enchantedBook = itemstack; } if (itemstack.getItem() instanceof ToolBase) { if (this.tool != null) return false; this.tool = ((ToolBase) itemstack.getItem()).getToolProperties(itemstack); } } } } return this.enchantedBook != null && this.tool != null; }
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { ItemStack dye = null; ItemStack token = null; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = p_77569_1_.getStackInRowAndColumn(j, i); if (itemstack == null) continue; if (!(itemstack.getItem() instanceof IToken) && !isDye(itemstack)) { return false; } if (isDye(itemstack)) { if (dye == null) dye = itemstack; else return false; } else if (itemstack.getItem() instanceof IToken) { if (token == null) token = itemstack; else if (token.getItem() != itemstack.getItem() || !token.stackTagCompound.equals(itemstack.stackTagCompound)) return false; } } } int color = dye == null ? 0 : dyeColor(dye) + 1; return token != null && token.getItemDamage() != color; }
/** Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { ArrayList arraylist = new ArrayList(this.recipeItems); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = p_77569_1_.getStackInRowAndColumn(j, i); if (itemstack != null) { boolean flag = false; Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == 32767 || itemstack.getItemDamage() == itemstack1.getItemDamage())) { flag = true; arraylist.remove(itemstack1); break; } } if (!flag) { return false; } } } } return arraylist.isEmpty(); }
@Override public boolean matches(InventoryCrafting inventoryCrafting, World world) { ItemStack biomeRadar = null; ItemStack biomeEssence = null; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = inventoryCrafting.getStackInRowAndColumn(j, i); if (itemstack != null) { if (itemstack.getItem() == BOPItemHelper.get("biomeFinder")) biomeRadar = itemstack.copy(); else if (itemstack.getItem() == BOPItemHelper.get("biomeEssence")) biomeEssence = itemstack.copy(); } } } if (biomeRadar != null && biomeEssence != null) { if (!biomeEssence.hasTagCompound() || !biomeEssence.getTagCompound().hasKey("biomeID")) return false; int biomeID = biomeEssence.getTagCompound().getInteger("biomeID"); if (!biomeRadar.hasTagCompound()) biomeRadar.setTagCompound(new NBTTagCompound()); biomeRadar.getTagCompound().setInteger("biomeIDToFind", biomeID); biomeRadar.getTagCompound().setBoolean("foundBiome", false); recipeOutput = biomeRadar; return true; } else return false; }
@Override protected boolean checkMatch(InventoryCrafting ic, int x, int y, boolean mirror) { for (int k = 0; k < 3; ++k) { for (int l = 0; l < 3; ++l) { int i1 = k - x; int j1 = l - y; ItemStack itemstack = null; if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight) { if (mirror) itemstack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth]; else itemstack = recipeItems[i1 + j1 * recipeWidth]; } ItemStack itemstack1 = ic.getStackInRowAndColumn(k, l); if (itemstack1 != null || itemstack != null) { if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) return false; if (itemstack.getItem() != itemstack1.getItem()) return false; if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage()) return false; if (!ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) return false; } } } return true; }
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { int width = recipeWidth; int height = recipeHeight; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { int subX = x - startX; int subY = y - startY; ItemStack target = null; if (subX >= 0 && subY >= 0 && subX < width && subY < height) { if (mirror) { target = recipeItems[width - subX - 1 + subY * width]; } else { target = recipeItems[subX + subY * width]; } } ItemStack slot = inv.getStackInRowAndColumn(x, y); if (target != null) { if (!OreDictionary.itemMatches(target, slot, false)) { return false; } } else if (slot != null) { return false; } } } return true; }
/** Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { ArrayList var3 = new ArrayList(this.recipeItems); for (int var4 = 0; var4 < 3; ++var4) { for (int var5 = 0; var5 < 3; ++var5) { ItemStack var6 = p_77569_1_.getStackInRowAndColumn(var5, var4); if (var6 != null) { boolean var7 = false; Iterator var8 = var3.iterator(); while (var8.hasNext()) { ItemStack var9 = (ItemStack) var8.next(); if (var6.getItem() == var9.getItem() && (var9.getItemDamage() == 32767 || var6.getItemDamage() == var9.getItemDamage())) { var7 = true; var3.remove(var9); break; } } if (!var7) { return false; } } } } return var3.isEmpty(); }
@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); }
public ItemStack func_82787_a(InventoryCrafting p_82787_1_, World p_82787_2_) { int var3 = 0; ItemStack var4 = null; ItemStack var5 = null; int var6; for (var6 = 0; var6 < p_82787_1_.func_70302_i_(); ++var6) { ItemStack var7 = p_82787_1_.func_70301_a(var6); if (var7 != null) { if (var3 == 0) { var4 = var7; } if (var3 == 1) { var5 = var7; } ++var3; } } if (var3 == 2 && var4.field_77993_c == var5.field_77993_c && var4.field_77994_a == 1 && var5.field_77994_a == 1 && Item.field_77698_e[var4.field_77993_c].func_77645_m()) { Item var11 = Item.field_77698_e[var4.field_77993_c]; int var13 = var11.func_77612_l() - var4.func_77952_i(); int var8 = var11.func_77612_l() - var5.func_77952_i(); int var9 = var13 + var8 + var11.func_77612_l() * 5 / 100; int var10 = var11.func_77612_l() - var9; if (var10 < 0) { var10 = 0; } return new ItemStack(var4.field_77993_c, 1, var10); } else { for (var6 = 0; var6 < this.field_77597_b.size(); ++var6) { IRecipe var12 = (IRecipe) this.field_77597_b.get(var6); if (var12.func_77569_a(p_82787_1_, p_82787_2_)) { return var12.func_77572_b(p_82787_1_); } } return null; } }
@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; }
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; }
@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); }
@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; }
@Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); if (!worldObj.isRemote) { for (int var2 = 0; var2 < 9; ++var2) { ItemStack var3 = craftMatrix.getStackInSlotOnClosing(var2); if (var3 != null) par1EntityPlayer.dropPlayerItem(var3); } } }