fix robots not using the correct sides when accessing inventories/tanks
This commit is contained in:
parent
cbef35e6f2
commit
32f933e4a5
|
@ -8,9 +8,10 @@
|
|||
*/
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
|
@ -184,18 +185,34 @@ public abstract class DockingStation {
|
|||
return null;
|
||||
}
|
||||
|
||||
public IInventory getItemInput() {
|
||||
public ForgeDirection getItemOutputSide() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public ISidedInventory getItemInput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ForgeDirection getItemInputSide() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public IFluidHandler getFluidOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ForgeDirection getFluidOutputSide() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public IFluidHandler getFluidInput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ForgeDirection getFluidInputSide() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public boolean providesPower() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package buildcraft.robotics;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
@ -21,6 +22,7 @@ import buildcraft.api.statements.IStatement;
|
|||
import buildcraft.api.statements.StatementSlot;
|
||||
import buildcraft.api.transport.IInjectable;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.core.lib.inventory.InventoryWrapper;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
|
@ -98,7 +100,12 @@ public class DockingStationPipe extends DockingStation implements IRequestProvid
|
|||
}
|
||||
|
||||
@Override
|
||||
public IInventory getItemInput() {
|
||||
public ForgeDirection getItemOutputSide() {
|
||||
return side().getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISidedInventory getItemInput() {
|
||||
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
|
||||
return null;
|
||||
}
|
||||
|
@ -113,12 +120,26 @@ public class DockingStationPipe extends DockingStation implements IRequestProvid
|
|||
TileEntity connectedTile = getPipe().getWorld().getTileEntity(x() + dir.offsetX,
|
||||
y() + dir.offsetY, z() + dir.offsetZ);
|
||||
if (connectedTile instanceof IInventory) {
|
||||
return (IInventory) connectedTile;
|
||||
return InventoryWrapper.getWrappedInventory(connectedTile);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getItemInputSide() {
|
||||
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
if (!(getPipe().getPipe() instanceof PipeItemsWood)) {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
int meta = ((TileEntity) getPipe()).getBlockMetadata();
|
||||
return ForgeDirection.getOrientation(meta).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidHandler getFluidInput() {
|
||||
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
|
||||
|
@ -141,6 +162,20 @@ public class DockingStationPipe extends DockingStation implements IRequestProvid
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getFluidInputSide() {
|
||||
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
if (!(getPipe().getPipe() instanceof PipeFluidsWood)) {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
int meta = ((TileEntity) getPipe()).getBlockMetadata();
|
||||
return ForgeDirection.getOrientation(meta).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidHandler getFluidOutput() {
|
||||
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
|
||||
|
@ -150,6 +185,11 @@ public class DockingStationPipe extends DockingStation implements IRequestProvid
|
|||
return (IFluidHandler) ((Pipe) getPipe().getPipe()).transport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getFluidOutputSide() {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesPower() {
|
||||
return getPipe().getPipeType() == IPipeTile.PipeType.POWER;
|
||||
|
|
|
@ -11,8 +11,6 @@ package buildcraft.robotics.ai;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.lib.inventory.ITransactor;
|
||||
|
@ -83,7 +81,7 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
|
|||
|
||||
ITransactor trans = Transactor.getTransactorFor(tileInventory);
|
||||
|
||||
ItemStack itemFound = trans.remove(filter, ForgeDirection.UNKNOWN, true);
|
||||
ItemStack itemFound = trans.remove(filter, robot.getDockingStation().getItemInputSide(), true);
|
||||
|
||||
if (itemFound != null) {
|
||||
robot.setItemInUse(itemFound);
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
*/
|
||||
package buildcraft.robotics.ai;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.IInvSlot;
|
||||
|
@ -64,15 +65,16 @@ public class AIRobotLoad extends AIRobot {
|
|||
|
||||
int loaded = 0;
|
||||
|
||||
IInventory tileInventory = station.getItemInput();
|
||||
ISidedInventory tileInventory = station.getItemInput();
|
||||
if (tileInventory == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory)) {
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, station.getItemInputSide())) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
|
||||
if (stack == null
|
||||
|| !slot.canTakeStackFromSlot(stack)
|
||||
|| !filter.matches(stack)
|
||||
|| !ActionStationProvideItems.canExtractItem(station, stack)
|
||||
|| !ActionRobotFilter.canInteractWithItem(station, filter,
|
||||
|
|
|
@ -71,7 +71,9 @@ public class AIRobotLoadFluids extends AIRobot {
|
|||
return 0;
|
||||
}
|
||||
|
||||
FluidStack drainable = handler.drain(station.side, FluidContainerRegistry.BUCKET_VOLUME,
|
||||
ForgeDirection side = station.getFluidInputSide();
|
||||
|
||||
FluidStack drainable = handler.drain(side, FluidContainerRegistry.BUCKET_VOLUME,
|
||||
false);
|
||||
if (drainable == null || !filter.matches(drainable.getFluid())) {
|
||||
return 0;
|
||||
|
@ -82,7 +84,7 @@ public class AIRobotLoadFluids extends AIRobot {
|
|||
|
||||
if (filled > 0 && doLoad) {
|
||||
drainable.amount = filled;
|
||||
handler.drain(station.side, drainable, true);
|
||||
handler.drain(side, drainable, true);
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AIRobotUnload extends AIRobot {
|
|||
return false;
|
||||
}
|
||||
|
||||
ForgeDirection injectSide = station.side().getOpposite();
|
||||
ForgeDirection injectSide = station.getItemOutputSide();
|
||||
if (!output.canInjectItems(injectSide)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class AIRobotUnloadFluids extends AIRobot {
|
|||
}
|
||||
|
||||
drainable = drainable.copy();
|
||||
int filled = fluidHandler.fill(station.side, drainable, doUnload);
|
||||
int filled = fluidHandler.fill(station.getFluidOutputSide(), drainable, doUnload);
|
||||
|
||||
if (filled > 0 && doUnload) {
|
||||
drainable.amount = filled;
|
||||
|
|
Loading…
Reference in a new issue