// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java
// public class ArrayStackFilter implements IStackFilter {
// 
// 	private final ItemStack[] stacks;
// 
// 	public ArrayStackFilter(ItemStack... stacks) {
// 		this.stacks = stacks;
// 	}
// 
// 	@Override
// 	public boolean matches(ItemStack stack) {
// 		if (stacks.length == 0 || !hasFilter()) {
// 			return true;
// 		}
// 		return InvTools.isItemEqual(stack, stacks);
// 	}
// 
// 	public ItemStack[] getStacks() {
// 		return stacks;
// 	}
// 
// 	public boolean hasFilter() {
// 		for (ItemStack filter : stacks) {
// 			if (filter != null) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// }


import cpw.mods.fml.common.Optional;
import mods.railcraft.api.carts.CartTools;
import mods.railcraft.api.carts.IItemTransfer;
import mods.railcraft.api.carts.ILinkageManager;
import mods.railcraft.api.core.items.IStackFilter;
import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters.ArrayStackFilter;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityMinecartContainer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
	public ItemStack offerItem(Object source, ItemStack offer) {
		if (!passThrough && getSizeInventory() > 0) {
			offer = moveItemStack(offer, this);
			if (offer == null)
				return null;
		}

		ILinkageManager lm = CartTools.getLinkageManager(worldObj);

		EntityMinecart linkedCart = lm.getLinkedCartA(this);
		if (linkedCart != source && linkedCart instanceof IItemTransfer)
			offer = ((IItemTransfer) linkedCart).offerItem(this, offer);

		if (offer == null)
			return null;

		linkedCart = lm.getLinkedCartB(this);
		if (linkedCart != source && linkedCart instanceof IItemTransfer)
			offer = ((IItemTransfer) linkedCart).offerItem(this, offer);

		return offer;
	}

	@Optional.Method(modid = "RailcraftAPI|carts")
	public ItemStack requestItem(Object source) {
		return requestItem(this, IStackFilter.filters.get("ALL"));
	}

	@Optional.Method(modid = "RailcraftAPI|carts")
	public ItemStack requestItem(Object source, ItemStack request) {
// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java
// public class ArrayStackFilter implements IStackFilter {
// 
// 	private final ItemStack[] stacks;
// 
// 	public ArrayStackFilter(ItemStack... stacks) {
// 		this.stacks = stacks;
// 	}
// 
// 	@Override
// 	public boolean matches(ItemStack stack) {
// 		if (stacks.length == 0 || !hasFilter()) {
// 			return true;
// 		}
// 		return InvTools.isItemEqual(stack, stacks);
// 	}
// 
// 	public ItemStack[] getStacks() {
// 		return stacks;
// 	}
// 
// 	public boolean hasFilter() {
// 		for (ItemStack filter : stacks) {
// 			if (filter != null) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// }


// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/carts/CartTransferBase.java
import cpw.mods.fml.common.Optional;
import mods.railcraft.api.carts.CartTools;
import mods.railcraft.api.carts.IItemTransfer;
import mods.railcraft.api.carts.ILinkageManager;
import mods.railcraft.api.core.items.IStackFilter;
import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters.ArrayStackFilter;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityMinecartContainer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

	public ItemStack offerItem(Object source, ItemStack offer) {
		if (!passThrough && getSizeInventory() > 0) {
			offer = moveItemStack(offer, this);
			if (offer == null)
				return null;
		}

		ILinkageManager lm = CartTools.getLinkageManager(worldObj);

		EntityMinecart linkedCart = lm.getLinkedCartA(this);
		if (linkedCart != source && linkedCart instanceof IItemTransfer)
			offer = ((IItemTransfer) linkedCart).offerItem(this, offer);

		if (offer == null)
			return null;

		linkedCart = lm.getLinkedCartB(this);
		if (linkedCart != source && linkedCart instanceof IItemTransfer)
			offer = ((IItemTransfer) linkedCart).offerItem(this, offer);

		return offer;
	}

	@Optional.Method(modid = "RailcraftAPI|carts")
	public ItemStack requestItem(Object source) {
		return requestItem(this, IStackFilter.filters.get("ALL"));
	}

	@Optional.Method(modid = "RailcraftAPI|carts")
	public ItemStack requestItem(Object source, ItemStack request) {
		return requestItem(this, new ArrayStackFilter(request));