Fix remaining filtered item handler uses.
This commit is contained in:
@@ -33,6 +33,8 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.SingleItemSlot;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -57,8 +59,6 @@ import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
|
||||
@@ -196,35 +196,37 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorFixedInv(new WrapperCursorItemHandler(player.inventory));
|
||||
|
||||
final FixedItemInv theSlot = new WrapperFilteredItemHandler(inv.server.getSubInv(slot, slot + 1),
|
||||
new PatternSlotFilter());
|
||||
final InventoryAdaptor interfaceSlot = new AdaptorFixedInv(theSlot);
|
||||
// Create a wrapper around the targetted slot that will only allow insertions of
|
||||
// patterns
|
||||
LimitedFixedItemInv limitedSlotInv = inv.server.createLimitedFixedInv();
|
||||
limitedSlotInv.getAllRule().filterInserts(this::isValidPattern);
|
||||
SingleItemSlot theSlot = limitedSlotInv.getSlot(slot);
|
||||
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
|
||||
if (hasItemInHand) {
|
||||
ItemStack inSlot = theSlot.getInvStack(0);
|
||||
ItemStack inSlot = theSlot.get();
|
||||
if (inSlot.isEmpty()) {
|
||||
player.inventory.setCursorStack(interfaceSlot.addItems(player.inventory.getCursorStack()));
|
||||
player.inventory.setCursorStack(theSlot.insert(player.inventory.getCursorStack()));
|
||||
} else {
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getCursorStack().copy();
|
||||
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, ItemStack.EMPTY);
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
player.inventory.setCursorStack(ItemStack.EMPTY);
|
||||
|
||||
player.inventory.setCursorStack(interfaceSlot.addItems(inHand.copy()));
|
||||
player.inventory.setCursorStack(theSlot.insert(inHand.copy()));
|
||||
|
||||
if (player.inventory.getCursorStack().isEmpty()) {
|
||||
player.inventory.setCursorStack(inSlot);
|
||||
} else {
|
||||
player.inventory.setCursorStack(inHand);
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot);
|
||||
theSlot.set(inSlot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getInvStack(0)));
|
||||
theSlot.set(playerHand.addItems(theSlot.get()));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -233,18 +235,18 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
if (hasItemInHand) {
|
||||
ItemStack extra = playerHand.removeItems(1, ItemStack.EMPTY, null);
|
||||
if (!extra.isEmpty()) {
|
||||
extra = interfaceSlot.addItems(extra);
|
||||
extra = theSlot.insert(extra);
|
||||
}
|
||||
if (!extra.isEmpty()) {
|
||||
playerHand.addItems(extra);
|
||||
}
|
||||
} else if (!is.isEmpty()) {
|
||||
ItemStack extra = interfaceSlot.removeItems((is.getCount() + 1) / 2, ItemStack.EMPTY, null);
|
||||
ItemStack extra = theSlot.extract((is.getCount() + 1) / 2);
|
||||
if (!extra.isEmpty()) {
|
||||
extra = playerHand.addItems(extra);
|
||||
}
|
||||
if (!extra.isEmpty()) {
|
||||
interfaceSlot.addItems(extra);
|
||||
theSlot.insert(extra);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,8 +254,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
case SHIFT_CLICK:
|
||||
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player);
|
||||
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getInvStack(0)));
|
||||
theSlot.set(playerInv.addItems(theSlot.get()));
|
||||
|
||||
break;
|
||||
case MOVE_REGION:
|
||||
@@ -279,6 +280,10 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidPattern(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.getItem() instanceof EncodedPatternItem;
|
||||
}
|
||||
|
||||
private void regenList(final CompoundTag data) {
|
||||
this.byId.clear();
|
||||
this.diList.clear();
|
||||
@@ -369,15 +374,4 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatternSlotFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.getItem() instanceof EncodedPatternItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.integration.abstraction.IRei;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import me.shedaniel.rei.api.REIHelper;
|
||||
import me.shedaniel.rei.gui.widget.TextFieldWidget;
|
||||
|
||||
import appeng.integration.abstraction.IRei;
|
||||
|
||||
class ReiRuntimeAdapter implements IRei {
|
||||
|
||||
private final REIHelper runtime;
|
||||
|
||||
@@ -18,9 +18,30 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -61,23 +82,6 @@ import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState {
|
||||
@@ -115,11 +119,9 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
|
||||
gridInvExt = gridInv.createLimitedFixedInv();
|
||||
// Limit the input slots to 1 of the respective crafting ingredient
|
||||
for ( int i = 0; i < 9; i++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int slot = i;
|
||||
gridInvExt.getRule(slot)
|
||||
.disallowExtraction()
|
||||
.limitInsertionCount(1)
|
||||
gridInvExt.getRule(slot).disallowExtraction().limitInsertionCount(1)
|
||||
.filterInserts(stack -> isValidIngredientForSlot(slot, stack));
|
||||
}
|
||||
// Output slot
|
||||
@@ -127,10 +129,8 @@ public class MolecularAssemblerBlockEntity extends AENetworkInvBlockEntity
|
||||
}
|
||||
|
||||
private boolean isValidIngredientForSlot(int slot, ItemStack stack) {
|
||||
return this.myPlan != null
|
||||
&& !ItemHandlerUtil.isEmpty(this.patternInv)
|
||||
&& this.myPlan.isValidItemForSlot(slot, stack,
|
||||
MolecularAssemblerBlockEntity.this.getWorld());
|
||||
return this.myPlan != null && !ItemHandlerUtil.isEmpty(this.patternInv)
|
||||
&& this.myPlan.isValidItemForSlot(slot, stack, MolecularAssemblerBlockEntity.this.getWorld());
|
||||
}
|
||||
|
||||
private int getUpgradeSlots() {
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.tile.grindstone;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,6 +28,7 @@ import net.minecraft.util.math.Direction;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.recipes.handlers.GrinderOptionalResult;
|
||||
@@ -40,8 +40,6 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankable {
|
||||
private static final int SLOT_PROCESSING = 6;
|
||||
@@ -56,9 +54,7 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
invExt = inv.createLimitedFixedInv();
|
||||
invExt.getAllRule().disallowExtraction().disallowInsertion();
|
||||
invExt.getSubRule(3, 6).allowExtraction();
|
||||
invExt.getSubRule(0, 3)
|
||||
.filterInserts(stack -> GrinderRecipes.isValidIngredient(world, stack))
|
||||
.allowInsertion();
|
||||
invExt.getSubRule(0, 3).filterInserts(stack -> GrinderRecipes.isValidIngredient(world, stack)).allowInsertion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,23 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
@@ -36,17 +50,6 @@ import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity implements IGridTickable {
|
||||
public static final double POWER_PER_TICK = 5;
|
||||
@@ -69,8 +72,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
this.getProxy().setFlags();
|
||||
|
||||
invExt = inv.createLimitedFixedInv();
|
||||
invExt.getAllRule()
|
||||
.filterInserts(stack -> FuelRegistry.INSTANCE.get(stack.getItem()) != null)
|
||||
invExt.getAllRule().filterInserts(stack -> FuelRegistry.INSTANCE.get(stack.getItem()) != null)
|
||||
.filterExtracts(stack -> FuelRegistry.INSTANCE.get(stack.getItem()) == null);
|
||||
}
|
||||
|
||||
@@ -124,7 +126,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
if (this.canEatFuel()) {
|
||||
try {
|
||||
|
||||
@@ -20,7 +20,6 @@ package appeng.tile.spatial;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,6 +30,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
@@ -52,8 +52,6 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.IWorldCallable;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class SpatialIOPortBlockEntity extends AENetworkInvBlockEntity implements IWorldCallable<Void> {
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@@ -34,6 +33,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FullnessMode;
|
||||
@@ -75,8 +75,6 @@ import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
|
||||
public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
implements IUpgradeableHost, IConfigManagerHost, IGridTickable {
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.util.inv;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.ItemStackUtil;
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.filter.ItemFilter;
|
||||
import alexiil.mc.lib.attributes.item.impl.DelegatingFixedItemInv;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// FIXME: Needs to be double checked, LBA has better ways of doing this
|
||||
public class WrapperFilteredItemHandler extends DelegatingFixedItemInv {
|
||||
private final IAEItemFilter filter;
|
||||
|
||||
public WrapperFilteredItemHandler(@Nonnull FixedItemInv handler, @Nonnull IAEItemFilter filter) {
|
||||
super(handler);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public static LimitedFixedItemInv create(FixedItemInv base, IAEItemFilter filter) {
|
||||
LimitedFixedItemInv limited = base.createLimitedFixedInv();
|
||||
for (int i = 0; i < base.getSlotCount(); i++) {
|
||||
int slot = i;
|
||||
limited.getRule(i).filterInserts(stack -> filter.allowInsert(base, slot, stack))
|
||||
.filterExtracts(stack -> filter.allowExtract(base, slot, stack.getCount()));
|
||||
}
|
||||
return limited;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setInvStack(int slot, ItemStack to, Simulation simulation) {
|
||||
ItemStack current = this.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) {
|
||||
// We may be extracting by "exchanging" the current item for something else,
|
||||
// or we might be setting it to air
|
||||
int extractAmount = current.getCount();
|
||||
if (same && !to.isEmpty()) {
|
||||
extractAmount -= to.getCount();
|
||||
}
|
||||
|
||||
if (!filter.allowExtract(delegate, slot, extractAmount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isInserting) {
|
||||
if (!filter.allowInsert(delegate, slot, to)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.setInvStack(slot, to, simulation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return (stack.isEmpty() || this.getFilterForSlot(slot).matches(stack)) && super.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilterForSlot(int slot) {
|
||||
ItemFilter parentFilter = super.getFilterForSlot(slot);
|
||||
ItemFilter thisFilter = stack -> filter.allowInsert(delegate, slot, stack);
|
||||
return thisFilter.and(parentFilter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.util.inv.filter;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class AEItemFilters {
|
||||
public static final IAEItemFilter INSERT_ONLY = new InsertOnlyFilter();
|
||||
public static final IAEItemFilter EXTRACT_ONLY = new ExtractOnlyFilter();
|
||||
|
||||
private AEItemFilters() {
|
||||
}
|
||||
|
||||
private static class InsertOnlyFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExtractOnlyFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user