alexiil.mc.lib.attributes.Simulation

Here are the examples of the java api alexiil.mc.lib.attributes.Simulation taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

103 Examples 7

19 Source : FluidUtils.java
with MIT License
from StellarHorizons

public static FluidVolume extractFluid(Reference<ItemStack> stackRef, FluidAmount maxAmount, FluidFilter filter, Simulation simulation) {
    return FluidAttributes.EXTRACTABLE.get(stackRef).attemptExtraction(filter, maxAmount, simulation);
}

19 Source : FluidUtils.java
with MIT License
from StellarHorizons

public static FluidVolume insertFluid(Reference<ItemStack> stackRef, FluidVolume volume, Simulation simulation) {
    return FluidAttributes.INSERTABLE.get(stackRef).attemptInsertion(volume, simulation);
}

19 Source : EnergyUtils.java
with MIT License
from StellarHorizons

/**
 * @param stack  The battery/energy item to extract energy from
 * @param amount The amount of energy, in Galacticraft Joules to extract from the battery
 * @param simulation Whether to actually change values or not.
 * @return The amount of energy that was extracted
 */
public static int extractEnergy(Reference<ItemStack> stack, int amount, Simulation simulation) {
    return getEnergyHandler(stack).extract(amount, simulation);
}

19 Source : EnergyUtils.java
with MIT License
from StellarHorizons

/**
 * @param stack  The battery/energy item to insert energy into
 * @param amount The amount of energy, in Galacticraft Joules, to inset into the battery
 * @param simulation Whether to actually change values or not
 * @return The amount of energy that could not be inserted
 */
public static int insert(Reference<ItemStack> stack, int amount, Simulation simulation) {
    return getEnergyHandler(stack).insert(amount, simulation);
}

19 Source : PipeFixedFluidInv.java
with MIT License
from StellarHorizons

@Override
public boolean setInvFluid(int i, FluidVolume fluidVolume, Simulation simulation) {
    if (this.insertFluid(i, fluidVolume, Simulation.SIMULATE).isEmpty()) {
        replacedert simulation != Simulation.ACTION || this.insertFluid(i, fluidVolume, Simulation.ACTION).isEmpty();
        return true;
    }
    return false;
}

19 Source : PipeFixedFluidInv.java
with MIT License
from StellarHorizons

@Override
public FluidVolume extractFluid(int tank, @Nullable FluidFilter filter, FluidVolume mergeWith, FluidAmount maxAmount, Simulation simulation) {
    if (mergeWith == null) {
        mergeWith = FluidVolumeUtil.EMPTY;
    }
    return mergeWith;
}

19 Source : PipeFixedFluidInv.java
with MIT License
from StellarHorizons

@Override
public FluidVolume insertFluid(int tank, FluidVolume volume, Simulation simulation) {
    if (pipe.getFluidData() == Pipe.FluidData.EMPTY) {
        Pipe.FluidData data = pipe.getNetwork().insertFluid(pipe.getPos(), null, volume.copy(), simulation);
        if (data != null && data != Pipe.FluidData.EMPTY) {
            if (simulation == Simulation.ACTION) {
                pipe.setFluidData(data);
            }
            return volume.getFluidKey().withAmount(volume.getAmount_F().sub(data.getFluid().getAmount_F()));
        }
    }
    return volume;
}

19 Source : WireNetworkImpl.java
with MIT License
from StellarHorizons

@Override
public int insert(@NotNull BlockPos fromWire, @Nullable BlockPos fromBlock, int amount, @NotNull Simulation simulate) {
    if (!graph.nodes().contains(fromWire))
        throw new RuntimeException("Inserted energy from non-existent wire?!");
    if (amount <= 0)
        return amount;
    Set<BlockPos> visitedNodes = new HashSet<>();
    Queue<BlockPos> queuedNodes = new LinkedList<>();
    visitedNodes.add(fromWire);
    queuedNodes.add(fromWire);
    while (!queuedNodes.isEmpty()) {
        BlockPos currentNode = queuedNodes.remove();
        for (BlockPos successor : graph.successors(currentNode)) {
            if (visitedNodes.add(successor)) {
                if (!(world.getBlockEnreplacedy(successor) instanceof Wire)) {
                    BlockPos vector = currentNode.subtract(successor);
                    Direction opposite = Direction.fromVector(vector.getX(), vector.getY(), vector.getZ());
                    EnergyInsertable handler = EnergyUtils.getEnergyInsertable(world, successor, opposite);
                    amount = handler.tryInsert(DefaultEnergyType.INSTANCE, amount, simulate);
                    if (amount == 0) {
                        return 0;
                    }
                }
                queuedNodes.add(successor);
            }
        }
    }
    return amount;
}

19 Source : PipeNetworkImpl.java
with MIT License
from StellarHorizons

@Override
public Pipe.FluidData insertFluid(@NotNull BlockPos fromPipe, @Nullable BlockPos fromBlock, @NotNull FluidVolume amount, @NotNull Simulation simulation) {
    if (!graph.nodes().contains(fromPipe))
        throw new RuntimeException("Inserted energy from non-existent pipe?!");
    return successor(fromPipe, Util.make(new LinkedHashSet<>(), (l) -> l.add(fromPipe)), new LinkedList<>(), amount, simulation);
}

19 Source : PipeNetworkImpl.java
with MIT License
from StellarHorizons

public FluidPipeBlockEnreplacedy.FluidData successor(BlockPos pos, LinkedHashSet<BlockPos> visited, LinkedList<BlockPos> steps, FluidVolume volume, Simulation simulation) {
    steps.push(pos);
    List<BlockPos> other = new LinkedList<>();
    for (BlockPos successor : graph.successors(pos)) {
        if (visited.add(successor)) {
            BlockEnreplacedy enreplacedy = world.getBlockEnreplacedy(successor);
            if (!(enreplacedy instanceof Pipe)) {
                BlockPos vector = pos.subtract(successor);
                Direction dir = Direction.fromVector(vector.getX(), vector.getY(), vector.getZ());
                FluidInsertable insertable = FluidUtils.getInsertable(world, successor, dir);
                FluidVolume data = insertable.attemptInsertion(volume, simulation);
                if (!(data.getAmount_F().equals(volume.getAmount_F()))) {
                    steps.push(successor);
                    Direction direction = Direction.fromVector(pos.getX() - successor.getX(), pos.getY() - successor.getY(), pos.getZ() - successor.getZ()).getOpposite();
                    return new FluidPipeBlockEnreplacedy.FluidData(pos, steps, data, direction);
                }
            } else {
                other.add(successor);
            }
        }
    }
    for (BlockPos successor : other) {
        FluidPipeBlockEnreplacedy.FluidData data = successor(successor, visited, steps, volume, simulation);
        if (data != null)
            return data;
    }
    steps.pop();
    return null;
}

19 Source : SimulatableRef.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean set(T value, Simulation simulation) {
    return setter.offer(value, simulation);
}

19 Source : AbstractItemBasedAttribute.java
with Mozilla Public License 2.0
from AlexIIL

/**
 * Attempts to place the stacks in the reference and excess.
 *
 * @param oldStack A copied stack from {@link #stackRef}, but decreased by 1.
 * @param newStack The modified stack that was split off from {@link #stackRef}.
 */
public boolean setStacks(Simulation simulation, ItemStack oldStack, ItemStack newStack) {
    if (oldStack.isEmpty() && stackRef.set(newStack, simulation)) {
        return true;
    } else if (stackRef.isValid(oldStack) && excessStacks.offer(newStack, simulation)) {
        boolean did = stackRef.set(oldStack, simulation);
        if (!did) {
            throw new IllegalStateException(// 
            "Failed to set the stack! (Even though we just checked this up above...)" + "\n\tstackRef = " + stackRef + "\n\tstack = " + oldStack);
        }
        return true;
    } else {
        return false;
    }
}

19 Source : SingleItemSlot.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public final ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    return getBackingInv().insertStack(slot, stack, simulation);
}

19 Source : SingleItemSlot.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public final ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    return getBackingInv().extractStack(slot, filter, ItemStack.EMPTY, maxAmount, simulation);
}

19 Source : SingleItemSlot.java
with Mozilla Public License 2.0
from AlexIIL

/**
 * Sets the stack in this slot to the given stack.
 *
 * @return True if the modification was allowed, false otherwise. (For example if the given stack doesn't preplaced the
 *         FixedItemInvView.isItemValidForSlot(int, ItemStack) test).
 */
@Override
public final boolean set(ItemStack to, Simulation simulation) {
    return getBackingInv().setInvStack(slot, to, simulation);
}

19 Source : ItemInvUtil.java
with Mozilla Public License 2.0
from AlexIIL

// #######################
// Implementation helpers
// #######################
/**
 * Inserts a single ItemStack into a {@link FixedItemInv}, using only
 * {@link FixedItemInv#setInvStack(int, ItemStack, Simulation)}. As such this is useful for implementations of
 * {@link ItemInsertable} (or others) for the base implementation.
 *
 * @param toInsert The stack to insert. This won't be modified.
 * @return The excess {@link ItemStack} that wasn't inserted.
 * @deprecated Because this has been moved to {@link FixedItemInv#insertStack(int, ItemStack, Simulation)}.
 */
// (since = "0.8.0", forRemoval = true)
@Deprecated
public static ItemStack insertSingle(FixedItemInv inv, int slot, ItemStack toInsert, Simulation simulation) {
    return inv.insertStack(slot, toInsert, simulation);
}

19 Source : ItemInvUtil.java
with Mozilla Public License 2.0
from AlexIIL

/**
 * Extracts a single ItemStack from a {@link FixedItemInv}, using only
 * {@link FixedItemInv#setInvStack(int, ItemStack, Simulation)}. As such this is useful for implementations of
 * {@link ItemInsertable} (or others) for the base implementation.
 *
 * @param filter The filter to match on. If this is null then it will match any {@link ItemStack}.
 * @param toAddWith An optional {@link ItemStack} that the extracted item will be added to.
 * @param maxAmount The maximum number of items to extract. Note that the returned {@link ItemStack} may have a
 *            higher amount than this if the given {@link ItemStack} isn't empty.
 * @return The extracted ItemStack, plus the parameter "toAddWith".
 * @deprecated Because this has been moved to
 *             {@link FixedItemInv#extractStack(int, ItemFilter, ItemStack, int, Simulation)}.
 */
// (since = "0.8.0", forRemoval = true)
@Deprecated
public static ItemStack extractSingle(FixedItemInv inv, int slot, @Nullable ItemFilter filter, ItemStack toAddWith, int maxAmount, Simulation simulation) {
    return inv.extractStack(slot, filter, toAddWith, maxAmount, simulation);
}

19 Source : ItemInvUtil.java
with Mozilla Public License 2.0
from AlexIIL

/**
 * Attempts to move up to the given maximum number of items from the {@link ItemExtractable} to the
 * {@link ItemInsertable}, provided they match the given {@link ItemFilter}. Note that this only ever moves a single
 * stack, unlike {@link #moveMultiple(ItemExtractable, ItemInsertable, ItemFilter, int, int)}.
 *
 * @return The number of items moved.
 */
public static int move(ItemExtractable from, ItemInsertable to, ItemFilter filter, int maximum, Simulation simulation) {
    if (maximum <= 0) {
        return 0;
    }
    ItemFilter insertionFilter = to.getInsertionFilter();
    if (filter != null && filter != ConstanreplacedemFilter.ANYTHING) {
        insertionFilter = AggregateItemFilter.and(insertionFilter, filter);
    }
    ItemStack extracted = from.attemptExtraction(insertionFilter, maximum, Simulation.SIMULATE);
    if (extracted.isEmpty()) {
        return 0;
    }
    ItemStack leftover = to.attemptInsertion(extracted, simulation);
    int insertedAmount = extracted.getCount() - (leftover.isEmpty() ? 0 : leftover.getCount());
    if (insertedAmount == 0) {
        // Nothing was accepted by the target
        return 0;
    }
    ItemStack reallyExtracted = from.attemptExtraction(new ExacreplacedemStackFilter(extracted), insertedAmount, simulation);
    if (reallyExtracted.isEmpty()) {
        throw throwBadImplException("Tried to extract the filter (C) from A but it returned an empty item stack " + "after we have already inserted the expected stack into B!\nThe inventory is now in an invalid (duped) state!", new String[] { "from A", "to B", "filter C" }, new Object[] { from, to, filter });
    }
    if (reallyExtracted.getCount() != insertedAmount) {
        throw throwBadImplException("Tried to extract " + insertedAmount + " but we actually extracted " + reallyExtracted.getCount() + "!\nThe inventory is now in an invalid (duped) state!", new String[] { "from A", "to B", "filter C", "originally extracted", "really extracted" }, new Object[] { from, to, insertionFilter, extracted, reallyExtracted });
    }
    return insertedAmount;
}

19 Source : SubFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    return inv().setInvStack(getInternalSlot(slot), to, simulation);
}

19 Source : SimpleLimitedGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

// Overrides
@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    if (filter == ConstanreplacedemFilter.NOTHING || filter == ConstanreplacedemFilter.ONLY_EMPTY) {
        return ItemStack.EMPTY;
    }
    if (extractionRules.isEmpty()) {
        return delegate.attemptExtraction(filter, maxAmount, simulation);
    }
    Set<ItemStack> stacks = delegate.getStoredStacks();
    if (stacks.isEmpty()) {
        return ItemStack.EMPTY;
    }
    if (filter instanceof ExacreplacedemStackFilter) {
        ItemStack stack = ((ExacreplacedemStackFilter) filter).stack;
        if (!stacks.contains(stack)) {
            return ItemStack.EMPTY;
        }
        stacks = Collections.singleton(stack);
    }
    fluids: for (ItemStack stack : stacks) {
        if (!filter.matches(stack)) {
            continue;
        }
        int current = delegate.getAmount(stack);
        if (current <= 0) {
            continue;
        }
        int minLeft = 0;
        for (ExtractionRule rule : extractionRules) {
            if (!rule.filter.matches(stack)) {
                continue;
            }
            if (rule.minimumAmount > 0) {
                minLeft = Math.max(minLeft, rule.minimumAmount);
                if (current <= minLeft) /* !current.isGreaterThan(minLeft)*/
                {
                    continue fluids;
                }
            }
        }
        int allowed = current - minLeft;
        return delegate.attemptExtraction(new ExacreplacedemStackFilter(stack), Math.min(maxAmount, allowed), simulation);
    }
    return ItemStack.EMPTY;
}

19 Source : SimpleLimitedGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    if (stack.isEmpty()) {
        return stack;
    }
    int current = delegate.getAmount(stack);
    int maxCount = Integer.MAX_VALUE;
    for (InsertionRule rule : insertionRules) {
        if (rule.filter.matches(stack)) {
            maxCount = Math.min(maxCount, rule.maximumInsertion);
            if (maxCount <= current) {
                return stack;
            }
        }
    }
    int allowed = maxCount - current;
    replacedert allowed >= 1;
    if (allowed < stack.getCount()) {
        ItemStack original = stack;
        ItemStack offered = original.copy();
        ItemStack leftover = delegate.attemptInsertion(offered.split(allowed), simulation);
        if (leftover.getCount() == maxCount) {
            return original;
        }
        offered.increment(leftover.getCount());
        return offered;
    } else {
        return super.attemptInsertion(stack, simulation);
    }
}

19 Source : SimpleLimitedFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    ItemStack current = getInvStack(slot);
    boolean same = ItemStackUtil.areEqualIgnoreAmounts(current, to);
    boolean isExtracting = !current.isEmpty() && (!same || to.getCount() < current.getCount());
    boolean isInserting = !to.isEmpty() && (!same || to.getCount() > current.getCount());
    if (isExtracting) {
        if (same) {
            if (to.getCount() < minimumAmounts[slot]) {
                return false;
            }
        } else {
            if (minimumAmounts[slot] > 0) {
                return false;
            }
        }
        if (extractionFilters[slot] != null && !extractionFilters[slot].matches(current)) {
            return false;
        }
    }
    if (isInserting) {
        if (to.getCount() > maxInsertionAmounts[slot]) {
            return false;
        }
        if (!isItemValidForSlot(slot, to)) {
            return false;
        }
    }
    return super.setInvStack(slot, to, simulation);
}

19 Source : SimpleLimitedFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack extractStack(int slot, @Nullable ItemFilter filter, ItemStack mergeWith, int maxCount, Simulation simulation) {
    ItemStack current = getInvStack(slot);
    if (current.isEmpty()) {
        return mergeWith;
    }
    maxCount = Math.min(maxCount, current.getCount() - minimumAmounts[slot]);
    if (maxCount <= 0) {
        return mergeWith;
    }
    if (extractionFilters[slot] != null && !extractionFilters[slot].matches(current)) {
        return mergeWith;
    }
    return super.extractStack(slot, filter, mergeWith, maxCount, simulation);
}

19 Source : SimpleLimitedFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack insertStack(int slot, ItemStack stack, Simulation simulation) {
    if (stack.isEmpty()) {
        return ItemStack.EMPTY;
    }
    // Calculate the final amount after the insert operation, ignoring stacking and other rules here
    // since these will be handled by the delegate
    ItemStack current = getInvStack(slot);
    int currentCount = current.isEmpty() ? 0 : current.getCount();
    if (currentCount >= maxInsertionAmounts[slot]) {
        // Avoid a copy for the simple case
        return stack;
    }
    // Test the insertion filter before potentially copying
    if (insertionFilters[slot] != null && !insertionFilters[slot].matches(stack)) {
        return stack;
    }
    // If current count + added count exceed the maximum, we need to try and insert
    // a partial amount and adjust the excess
    int cannotAddAmount = Math.max(0, currentCount + stack.getCount() - maxInsertionAmounts[slot]);
    ItemStack cannotAdd = null;
    if (cannotAddAmount > 0) {
        stack = stack.copy();
        cannotAdd = stack.split(cannotAddAmount);
    }
    ItemStack excess = super.insertStack(slot, stack, simulation);
    // Now adjust the excess for what we held back due to the max-amount
    if (cannotAdd != null) {
        if (!excess.isEmpty()) {
            // The underlying inventory could _still_ reject some part of our insert attempt
            // Also note that we're not checking that excess is actually the same item here
            cannotAdd.increment(excess.getCount());
        }
        return cannotAdd;
    }
    return excess;
}

19 Source : SimpleGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    for (Object2IntMap.Entry<ItemStack> entry : stacks.object2IntEntrySet()) {
        ItemStack stack = entry.getKey();
        if (filter.matches(stack)) {
            int current = entry.getIntValue();
            int extracted = Math.min(current, maxAmount);
            if (simulation == Simulation.ACTION) {
                if (extracted == current) {
                    stacks.removeInt(stack);
                } else {
                    entry.setValue(current - extracted);
                }
                cachedItemCount -= extracted;
                fireAmountChange(stack, current, current - extracted);
            }
            stack = stack.copy();
            stack.setCount(extracted);
            return stack;
        }
    }
    return ItemStack.EMPTY;
}

19 Source : SimpleGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    int current = stacks.getInt(stack);
    if (current < 0 && stacks.size() >= maxItemTypes) {
        return stack;
    }
    int insertable = Math.min(stack.getCount(), maxItems - cachedItemCount);
    if (insertable <= 0) {
        return stack;
    }
    stack = stack.copy();
    ItemStack insStack = stack.split(insertable);
    replacedert insStack.getCount() == insertable;
    if (simulation == Simulation.ACTION) {
        stacks.put(insStack, insertable + (current < 0 ? 0 : current));
        cachedItemCount += insertable;
        fireAmountChange(stack, current, current + insertable);
    }
    return stack;
}

19 Source : SimpleFixedItemInvInsertable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    return wrapper.attemptInsertion(stack, simulation);
}

19 Source : SimpleFixedItemInvExtractable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxCount, Simulation simulation) {
    return wrapper.attemptExtraction(filter, maxCount, simulation);
}

19 Source : MappedFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    return ((FixedItemInv) inv).setInvStack(getInternalSlot(slot), to, simulation);
}

19 Source : GroupedItemInvFixedWrapper.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxCount, Simulation simulation) {
    if (maxCount < 0) {
        throw new IllegalArgumentException("maxAmount cannot be negative! (was " + maxCount + ")");
    }
    ItemStack stack = ItemStack.EMPTY;
    if (maxCount == 0) {
        return stack;
    }
    for (int s = 0; s < inv.getSlotCount(); s++) {
        stack = inv().extractStack(s, filter, stack, maxCount - stack.getCount(), simulation);
        if (stack.getCount() >= maxCount) {
            return stack;
        }
    }
    return stack;
}

19 Source : GroupedItemInvFixedWrapper.java
with Mozilla Public License 2.0
from AlexIIL

private ItemStack simpleDumbBadInsertionToBeRemoved(ItemStack stack, Simulation simulation) {
    for (int s = 0; s < inv.getSlotCount(); s++) {
        stack = inv().insertStack(s, stack, simulation);
        if (stack.isEmpty()) {
            return ItemStack.EMPTY;
        }
    }
    return stack;
}

19 Source : GroupedItemInvFixedWrapper.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    /* Even though there is a giant warning at the top of this clreplaced it should still be possible to optimise this
         * implementation a bit more than this very basic version. */
    return simpleDumbBadInsertionToBeRemoved(stack, simulation);
}

19 Source : FullFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    boolean allowed = false;
    if (to.isEmpty()) {
        allowed = true;
    } else {
        ItemStack current = getInvStack(slot);
        if (!current.isEmpty() && current.getCount() > to.getCount() && ItemStackUtil.areEqualIgnoreAmounts(to, current)) {
            allowed = true;
        } else if (isItemValidForSlot(slot, to) && to.getCount() <= getMaxAmount(slot, to)) {
            allowed = true;
        }
    }
    if (allowed) {
        if (simulation == Simulation.ACTION) {
            ItemStack before = slots.get(slot);
            ItemInvModificationTracker.trackNeverChanging(before);
            ItemInvModificationTracker.trackNeverChanging(to);
            slots.set(slot, to);
            fireSlotChange(slot, before, to);
            ItemInvModificationTracker.trackNeverChanging(before);
            ItemInvModificationTracker.trackNeverChanging(to);
        }
        return true;
    }
    return false;
}

19 Source : FullFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

// ItemInsertable
@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    return groupedVersion.attemptInsertion(stack, simulation);
}

19 Source : FullFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptAnyExtraction(int maxAmount, Simulation simulation) {
    return groupedVersion.attemptAnyExtraction(maxAmount, simulation);
}

19 Source : FullFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

// ItemExtractable
@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    return groupedVersion.attemptExtraction(filter, maxAmount, simulation);
}

19 Source : FilteredItemTransferable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptAnyExtraction(int maxAmount, Simulation simulation) {
    return real.attemptExtraction(filter, maxAmount, simulation);
}

19 Source : FilteredItemTransferable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    if (stack.isEmpty() || !filter.matches(stack)) {
        return stack;
    }
    return real.attemptInsertion(stack, simulation);
}

19 Source : FilteredItemTransferable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    return real.attemptExtraction(filter.and(this.filter), maxAmount, simulation);
}

19 Source : DirectFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    validateSlotIndex(slot);
    if (to != slots.get(slot) && !isItemValidForSlot(slot, to)) {
        return false;
    }
    if (simulation.isAction()) {
        slots.set(slot, to);
        markDirty();
    }
    return true;
}

19 Source : DirectFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    return groupedVersion.attemptInsertion(stack, simulation);
}

19 Source : DirectFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    return groupedVersion.attemptExtraction(filter, maxAmount, simulation);
}

19 Source : DelegatingGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptAnyExtraction(int maxAmount, Simulation simulation) {
    return delegate.attemptAnyExtraction(maxAmount, simulation);
}

19 Source : DelegatingGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    return delegate.attemptExtraction(filter, maxAmount, simulation);
}

19 Source : DelegatingGroupedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    return delegate.attemptInsertion(stack, simulation);
}

19 Source : DelegatingFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack insertStack(int slot, ItemStack stack, Simulation simulation) {
    return delegate.insertStack(slot, stack, simulation);
}

19 Source : DelegatingFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack extractStack(int slot, ItemFilter filter, ItemStack mergeWith, int maxCount, Simulation simulation) {
    return delegate.extractStack(slot, filter, mergeWith, maxCount, simulation);
}

19 Source : DelegatingFixedItemInv.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
    return delegate.setInvStack(slot, to, simulation);
}

19 Source : CombinedItemInsertable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptInsertion(ItemStack stack, Simulation simulation) {
    for (ItemInsertable insertable : list) {
        stack = insertable.attemptInsertion(stack, simulation);
        if (stack.isEmpty()) {
            return ItemStack.EMPTY;
        }
    }
    return stack;
}

19 Source : CombinedItemExtractable.java
with Mozilla Public License 2.0
from AlexIIL

@Override
public ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation) {
    if (maxAmount < 0) {
        throw new IllegalArgumentException("maxCount cannot be negative! (was " + maxAmount + ")");
    }
    ItemStack extracted = ItemStack.EMPTY;
    for (ItemExtractable extractable : list) {
        if (extracted.isEmpty()) {
            extracted = extractable.attemptExtraction(filter, maxAmount, simulation);
            if (extracted.isEmpty()) {
                continue;
            }
            if (extracted.getCount() >= maxAmount) {
                return extracted;
            }
            filter = new ExacreplacedemStackFilter(extracted);
        } else {
            int newMaxCount = maxAmount - extracted.getCount();
            ItemStack additional = extractable.attemptExtraction(filter, newMaxCount, simulation);
            if (additional.isEmpty()) {
                continue;
            }
            if (!ItemStackUtil.areEqualIgnoreAmounts(additional, extracted)) {
                throw new IllegalStateException("bad ItemExtractable " + extractable.getClreplaced().getName());
            }
            extracted.increment(additional.getCount());
            if (extracted.getCount() >= maxAmount) {
                return extracted;
            }
        }
    }
    return extracted;
}

See More Examples