@Override public boolean matches(@Nonnull InventoryCrafting var1, @Nonnull World var2) { boolean foundIvy = false; boolean foundItem = false; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); if(!stack.isEmpty()) { if(stack.getItem() == ModItems.keepIvy) foundIvy = true; else if(!foundItem && !(stack.hasTagCompound() && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) && !stack.getItem().hasContainerItem(stack)) foundItem = true; else return false; } } return foundIvy && foundItem; }
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; }
if( g.getItem().hasContainerItem( g ) )
if(item.age >= 59 + slowdown && !item.isDead) { ItemStack stack = item.getItem(); if(stack.isEmpty() || stack.getItem().hasContainerItem(stack)) continue;
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); } }
@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 boolean isCompostableFood(ItemStack itemStack) { // TODO: optionally use AppleCore's method? if (itemStack != null && itemStack.getItem() instanceof ItemFood && !itemStack.getItem().hasContainerItem(itemStack)) { for (FoodSpecifier uncompostableFood : uncompostableFoods) { if (uncompostableFood.matches(itemStack)) return false; } return true; } return false; }
public static ItemStack getContainer(ItemStack stack) { return stack.getItem().hasContainerItem(stack) ? stack.getItem().getContainerItem(stack) : ItemStack.EMPTY; }
public static void stowContainerItem(ItemStack itemstack, IInventory stowing, int slotIndex, @Nullable EntityPlayer player) { if (!itemstack.getItem().hasContainerItem(itemstack)) { return; } ItemStack container = ForgeHooks.getContainerItem(itemstack); if (!container.isEmpty()) { if (!tryAddStack(stowing, container, slotIndex, 1, true)) { if (!tryAddStack(stowing, container, true) && player != null) { player.dropItem(container, true); } } } }
public static int getFuelEnergy(ItemStack stack) { if (stack.isEmpty()) { return 0; } if (stack.getItem().hasContainerItem(stack)) { return 0; } int energy = fuelMap.get(new ComparableItemStack(stack)); if (energy > 0) { return energy; } energy = TileEntityFurnace.getItemBurnTime(stack) * CoreProps.RF_PER_MJ; if (energy >= 300 * CoreProps.RF_PER_MJ) { return energy; } return 0; }
public static @Nonnull ItemStack consumeItem(@Nonnull ItemStack stack) { if (stack.getItem() instanceof ItemPotion) { if (stack.getCount() == 1) { return new ItemStack(Items.GLASS_BOTTLE); } else { stack.splitStack(1); return stack; } } if (stack.getCount() == 1) { if (stack.getItem().hasContainerItem(stack)) { return stack.getItem().getContainerItem(stack); } else { return ItemStack.EMPTY; } } else { stack.splitStack(1); return stack; } }
/** * Safely consumes an item from an ItemStack. Respects container items. * * @param stack The stack to use. * @return The remaining/generated item. */ public static ItemStack consumeStack (ItemStack stack) { if (stack.getCount() == 1) { if (stack.getItem().hasContainerItem(stack)) { return stack.getItem().getContainerItem(stack); } else { return ItemStack.EMPTY; } } else { stack.splitStack(1); return stack; } }
private static ItemStack removeStack(IInventory inventory, ItemStack stackToRemove, @Nullable String oreDictOfStack, @Nullable EntityPlayer player, boolean stowContainer, boolean craftingTools) { for (int j = 0; j < inventory.getSizeInventory(); j++) { ItemStack stackInSlot = inventory.getStackInSlot(j); if (!stackInSlot.isEmpty()) { if (ItemStackUtil.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictOfStack, craftingTools)) { ItemStack removed = inventory.decrStackSize(j, stackToRemove.getCount()); stackToRemove.shrink(removed.getCount()); if (stowContainer && stackToRemove.getItem().hasContainerItem(stackToRemove)) { stowContainerItem(removed, inventory, j, player); } if (stackToRemove.isEmpty()) { return removed; } } } } return ItemStack.EMPTY; }
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 static ItemStack consumeItem(ItemStack stack) { Item item = stack.getItem(); boolean largerStack = stack.getCount() > 1; if (largerStack) { stack.shrink(1); } if (item.hasContainerItem(stack)) { ItemStack ret = item.getContainerItem(stack); if (ret.isEmpty()) { return ItemStack.EMPTY; } if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage()) { ret = ItemStack.EMPTY; } return ret; } return largerStack ? stack : ItemStack.EMPTY; }
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); } } }
public void clearIngredients() { for(int i = 0; i < ingredients.length; i++) { if(this.ingredients[i] != null) { if(ingredients[i].getItem().hasContainerItem()) { if(!world.isRemote) { EntityItem entityItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.6, pos.getZ() + 0.5, new ItemStack(ingredients[i].getItem().getContainerItem())); world.spawnEntity(entityItem); } } ingredients[i] = null; } } }
@Override protected ItemStack getContainerItem(ItemStack stack) { if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); if (copyStack.getItem() instanceof ICustomAlchemyConsumable) { return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack); } if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); if (copyStack.isEmpty()) { return ItemStack.EMPTY; } return copyStack; } }