@Override public boolean matches(@Nonnull InventoryCrafting var1, @Nonnull World var2) { boolean foundInk = false; boolean foundItem = false; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); if(!stack.isEmpty()) { if(stack.getItem() == ModItems.phantomInk && !foundInk) foundInk = true; else if(!foundItem) { if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack).isEmpty()) foundItem = true; else return false; } else return false; } } return foundInk && foundItem; }
private static boolean consumeFromInventory(ItemStack stack, IItemHandler inv, EntityPlayer player) { for(int i = 0; i < inv.getSlots(); i++) { ItemStack stackAt = inv.getStackInSlot(i); if(!stackAt.isEmpty() && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { boolean consume = true; ItemStack container = stackAt.getItem().getContainerItem(stackAt); if(!container.isEmpty()) { if(container == stackAt) consume = false; else { if(player == null) ItemHandlerHelper.insertItem(inv, container, false); else ItemHandlerHelper.giveItemToPlayer(player, container); } } if(consume) inv.extractItem(i, 1, false); return true; } } return false; }
public static ItemStack getContainerItem( final ItemStack stackInSlot ) { if( stackInSlot == null ) { return ItemStack.EMPTY; } final Item i = stackInSlot.getItem(); if( i == null || !i.hasContainerItem( stackInSlot ) ) { if( stackInSlot.getCount() > 1 ) { stackInSlot.setCount( stackInSlot.getCount() - 1 ); return stackInSlot; } return ItemStack.EMPTY; } ItemStack ci = i.getContainerItem( stackInSlot.copy() ); if( !ci.isEmpty() && ci.isItemStackDamageable() && ci.getItemDamage() == ci.getMaxDamage() ) { ci = ItemStack.EMPTY; } return ci; }
/** * It works but we dont want to use it right now * * @param istack * @return */ @SuppressWarnings("unused") private boolean isRemovedSinceContainerItem(ItemStack istack) { boolean hasContainerItem = istack.getItem().getContainerItem(istack) != null; //EXAMPLE: milk_bucket has containerItem == milk return hasContainerItem; }
/** * Checks if the fuel works with Simple Stirling Generator */ private boolean simpleFuel(@Nonnull ItemStack fuel) { return Prep.isInvalid(fuel.getItem().getContainerItem(fuel)); }
@Override public boolean isMachineItemValidForSlot(int i, @Nonnull ItemStack itemstack) { return super.isMachineItemValidForSlot(i, itemstack) && Prep.isInvalid(itemstack.getItem().getContainerItem(itemstack)); }
@Nonnull public static ItemStack consumeItem(@Nonnull ItemStack stack) { if (stack.getCount() == 1) { final Item item = stack.getItem(); if (item.hasContainerItem(stack)) return item.getContainerItem(stack); return ItemStack.EMPTY; } stack.splitStack(1); return stack; }
public static void addOilRecipe(ItemStack output, Object... inputs) { List<Object> recipeInputs = new ArrayList<Object>(Arrays.asList(inputs)); recipeInputs.add(0, ContentHelper.oilPresserOreDict); if (output.getItem().hasContainerItem(output)) { recipeInputs.add(output.getItem().getContainerItem(output)); } GameRegistry.addRecipe(new ShapelessOreRecipe(output, recipeInputs.toArray(new Object[recipeInputs.size()]))); if (!oilPresser.getItem().hasContainerItem(oilPresser)) { Modifiers.crafting.addInputsToKeepForOutput(output, oilPresser); } }
this.inv.setStackInSlot( 0, fuelItem.getContainerItem( is ) );
public static ItemStack getContainer(ItemStack stack) { return stack.getItem().hasContainerItem(stack) ? stack.getItem().getContainerItem(stack) : ItemStack.EMPTY; }
/** * Helper method to remove stack size and return the stack. */ public static ItemStack shrinkForContainer(ItemStack s, int i) { ItemStack sc = s.copy(); s.shrink(i); if (s.isEmpty()) return sc.getItem().getContainerItem(sc); return s; }
ItemStack containerStack = stack.getItem().getContainerItem(stack); if(!containerStack.isEmpty()) tooltipContainerStack = containerStack;
protected ItemStack getContainerItem(ItemStack stack) { if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); if (copyStack.isEmpty()) { return ItemStack.EMPTY; } return copyStack; }
protected ItemStack getContainerItem(ItemStack stack) { if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); if (copyStack.isEmpty()) { return ItemStack.EMPTY; } return copyStack; } }
public void startWashing() { if(canWash()) { if(timeRemaining == 0) { superMode = inventory.get(6).getItem() == FurnitureItems.SUPER_SOAPY_WATER; inventory.set(6, new ItemStack(inventory.get(6).getItem().getContainerItem())); timeRemaining = 5000; } washing = true; world.updateComparatorOutputLevel(pos, blockType); } }
public void startWashing() { if(canWash()) { if(timeRemaining == 0) { superMode = getStackInSlot(4).getItem() == FurnitureItems.SUPER_SOAPY_WATER; setInventorySlotContents(4, new ItemStack(getStackInSlot(4).getItem().getContainerItem())); timeRemaining = 5000; } washing = true; world.updateComparatorOutputLevel(pos, blockType); } }
public void consumeInventory() { for (int i = 0; i < 4; i++) { ItemStack inputStack = getStackInSlot(i); if (!inputStack.isEmpty()) { if (inputStack.getItem().hasContainerItem(inputStack)) { setInventorySlotContents(i, inputStack.getItem().getContainerItem(inputStack)); continue; } inputStack.shrink(1); if (inputStack.isEmpty()) { setInventorySlotContents(i, ItemStack.EMPTY); } } } }
public void consumeInventory(IItemHandler inv) { for (int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.isEmpty()) { continue; } if (stack.getItem().hasContainerItem(stack)) { inv.extractItem(i, stack.getCount(), false); inv.insertItem(i, stack.getItem().getContainerItem(stack), false); } else { inv.extractItem(i, 1, false); } } }
@Nullable @Override public SourceItem findSourceAndMarkAsUsed(IngredientPredicate predicate, int maxAmount, List<IKitchenItemProvider> inventories, boolean requireBucket, boolean simulate) { if (getBaseFridge().hasIceUpgrade && predicate.test(snowStack, 64)) { return new SourceItem(this, -1, ItemHandlerHelper.copyStackWithSize(snowStack, maxAmount)); } if (getBaseFridge().hasIceUpgrade && predicate.test(iceStack, 64)) { return new SourceItem(this, -1, ItemHandlerHelper.copyStackWithSize(iceStack, maxAmount)); } IngredientPredicate modifiedPredicate = predicate; if (getBaseFridge().hasPreservationUpgrade) { modifiedPredicate = (it, count) -> (count > 1 || !it.getItem().getContainerItem(it).isEmpty() || CookingRegistry.isToolItem(it)) && predicate.test(it, count); } return super.findSourceAndMarkAsUsed(modifiedPredicate, maxAmount, inventories, requireBucket, simulate); } };
public static void saveCraftingComponents(ItemStack toolStack, IInventory ingredients) { NBTTagList componentList = new NBTTagList(); for(int slotIndex = 0; slotIndex < ingredients.getSizeInventory(); slotIndex++) { ItemStack stackInSlot = ingredients.getStackInSlot(slotIndex).copy(); stackInSlot.setCount(1); //only save items that are not tools and don't have container items (to avoid dupes) if(!stackInSlot.isEmpty() && !(stackInSlot.getItem() instanceof ToolMetaItem<?>) && stackInSlot.getItem().getContainerItem(stackInSlot).isEmpty()) { NBTTagCompound stackTag = new NBTTagCompound(); stackInSlot.writeToNBT(stackTag); componentList.appendTag(stackTag); } } toolStack.setTagInfo("CraftingComponents", componentList); }