Merge pull request #2635 from hea3ven/robot-fixes

Robot fixes
This commit is contained in:
Adrian Siekierka 2015-04-15 13:12:12 +02:00
commit 875c8e47ee
36 changed files with 588 additions and 530 deletions

View file

@ -8,14 +8,16 @@
*/
package buildcraft.api.robots;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IInjectable;
public class DockingStation {
public abstract class DockingStation {
public ForgeDirection side;
public World world;
@ -25,20 +27,12 @@ public class DockingStation {
private boolean linkIsMain = false;
private BlockIndex index;
private IPipeTile pipe;
public DockingStation(BlockIndex iIndex, ForgeDirection iSide) {
index = iIndex;
side = iSide;
}
public DockingStation(IPipeTile iPipe, ForgeDirection iSide) {
index = new BlockIndex(iPipe.x(), iPipe.y(), iPipe.z());
pipe = iPipe;
side = iSide;
world = iPipe.getWorld();
}
public DockingStation() {
}
@ -46,20 +40,6 @@ public class DockingStation {
return linkIsMain;
}
public IPipeTile getPipe() {
if (pipe == null) {
pipe = (IPipeTile) world.getTileEntity(index.x, index.y, index.z);
}
if (pipe == null || ((TileEntity) pipe).isInvalid()) {
// Inconsistency - remove this pipe from the registry.
RobotManager.registryProvider.getRegistry(world).removeStation(this);
pipe = null;
}
return pipe;
}
public int x() {
return index.x;
}
@ -80,7 +60,8 @@ public class DockingStation {
if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) {
return null;
} else if (robotTaking == null) {
robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(robotTakingId);
robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(
robotTakingId);
}
return robotTaking;
@ -100,7 +81,6 @@ public class DockingStation {
linkIsMain = true;
robotTaking = robot;
robotTakingId = robot.getRobotId();
getPipe().scheduleRenderUpdate();
registry.registryMarkDirty();
robot.setMainStation(this);
registry.take(this, robot.getRobotId());
@ -117,7 +97,6 @@ public class DockingStation {
linkIsMain = false;
robotTaking = robot;
robotTakingId = robot.getRobotId();
getPipe().scheduleRenderUpdate();
registry.registryMarkDirty();
registry.take(this, robot.getRobotId());
@ -145,7 +124,6 @@ public class DockingStation {
linkIsMain = false;
robotTaking = null;
robotTakingId = EntityRobotBase.NULL_ROBOT_ID;
getPipe().scheduleRenderUpdate();
}
}
@ -159,7 +137,7 @@ public class DockingStation {
}
public void readFromNBT(NBTTagCompound nbt) {
index = new BlockIndex (nbt.getCompoundTag("index"));
index = new BlockIndex(nbt.getCompoundTag("index"));
side = ForgeDirection.values()[nbt.getByte("side")];
linkIsMain = nbt.getBoolean("isMain");
robotTakingId = nbt.getLong("robotId");
@ -179,7 +157,8 @@ public class DockingStation {
@Override
public String toString() {
return "{" + index.x + ", " + index.y + ", " + index.z + ", " + side + " :" + robotTakingId + "}";
return "{" + index.x + ", " + index.y + ", " + index.z + ", " + side + " :" + robotTakingId
+ "}";
}
public boolean linkIsDocked() {
@ -193,5 +172,35 @@ public class DockingStation {
public boolean canRelease() {
return !isMainStation() && !linkIsDocked();
}
}
public boolean isInitialized() {
return true;
}
public abstract Iterable<StatementSlot> getActiveActions();
public IInjectable getItemOutput() {
return null;
}
public IInventory getItemInput() {
return null;
}
public IFluidHandler getFluidOutput() {
return null;
}
public IFluidHandler getFluidInput() {
return null;
}
public boolean providesPower() {
return false;
}
public IRequestProvider getRequestProvider() {
return null;
}
}

View file

@ -24,6 +24,8 @@ public abstract class RobotManager {
resourceIdNames = new HashMap<Class<? extends ResourceId>, String>();
resourceIdByNames = new HashMap<String, Class<? extends ResourceId>>();
resourceIdLegacyClassNames = new HashMap<String, Class<? extends ResourceId>>();
dockingStationNames = new HashMap<Class<? extends DockingStation>, String>();
dockingStationByNames = new HashMap<String, Class<? extends DockingStation>>();
registerResourceId(ResourceIdBlock.class, "resourceIdBlock", "buildcraft.core.robots.ResourceIdBlock");
registerResourceId(ResourceIdRequest.class, "resourceIdRequest", "buildcraft.core.robots.ResourceIdRequest");
@ -37,6 +39,9 @@ public abstract class RobotManager {
private static Map<String, Class<? extends ResourceId>> resourceIdByNames;
private static Map<String, Class<? extends ResourceId>> resourceIdLegacyClassNames;
private static Map<Class<? extends DockingStation>, String> dockingStationNames;
private static Map<String, Class<? extends DockingStation>> dockingStationByNames;
public static void registerAIRobot(Class<? extends AIRobot> aiRobot, String name) {
registerAIRobot(aiRobot, name, null);
}
@ -88,4 +93,17 @@ public abstract class RobotManager {
public static Class<?> getResourceIdByLegacyClassName(String resourceIdLegacyClassName) {
return resourceIdLegacyClassNames.get(resourceIdLegacyClassName);
}
public static void registerDockingStation(Class<? extends DockingStation> dockingStation, String name) {
dockingStationByNames.put(name, dockingStation);
dockingStationNames.put(dockingStation, name);
}
public static Class<? extends DockingStation> getDockingStationByName(String dockingStationTypeName) {
return dockingStationByNames.get(dockingStationTypeName);
}
public static String getDockingStationName(Class<? extends DockingStation> dockingStation) {
return dockingStationNames.get(dockingStation);
}
}

View file

@ -141,7 +141,8 @@ gate.action.station.povide_fluids=Provide Fluids
gate.action.robot.work_in_area=Work in Area
gate.action.robot.load_unload_area=Load/Unload in Area
gate.action.robot.wakeup=Wake Up
gate.action.station.forbid_robot=Robot Forbidden
gate.action.station.forbid_robot=Forbid Robot
gate.action.station.forbid_robot=Force Robot
gate.action.robot.filter=Filter
gate.action.robot.filter_tool=Filter Tool
@ -196,6 +197,9 @@ gate.trigger.pipe.wire.active=%s Pipe Signal On
gate.trigger.pipe.wire.inactive=%s Pipe Signal Off
gate.trigger.timer=%s Sec Timer
gate.trigger.robot.sleep=Sleep
gate.trigger.robot.in.station=Robot In Station
gate.trigger.robot.linked=Station Linked
gate.trigger.robot.reserved=Station Reserved
gate.trigger.machine.energyStored.high=High Energy Stored
gate.trigger.machine.energyStored.low=Low Energy Stored
gate.trigger.machine.energyStored.below25=Energy < 25%

View file

@ -49,6 +49,7 @@ import buildcraft.core.proxy.CoreProxy;
import buildcraft.robotics.BlockRequester;
import buildcraft.robotics.BlockZonePlan;
import buildcraft.robotics.BoardProgrammingRecipe;
import buildcraft.robotics.DockingStationPipe;
import buildcraft.robotics.EntityRobot;
import buildcraft.robotics.ImplRedstoneBoardRegistry;
import buildcraft.robotics.ItemRedstoneBoard;
@ -142,6 +143,7 @@ import buildcraft.robotics.statements.ActionRobotFilterTool;
import buildcraft.robotics.statements.ActionRobotGotoStation;
import buildcraft.robotics.statements.ActionRobotWakeUp;
import buildcraft.robotics.statements.ActionRobotWorkInArea;
import buildcraft.robotics.statements.ActionRobotWorkInArea.AreaType;
import buildcraft.robotics.statements.ActionStationAcceptFluids;
import buildcraft.robotics.statements.ActionStationAcceptItems;
import buildcraft.robotics.statements.ActionStationAllowCraft;
@ -155,7 +157,6 @@ import buildcraft.robotics.statements.RobotsTriggerProvider;
import buildcraft.robotics.statements.TriggerRobotInStation;
import buildcraft.robotics.statements.TriggerRobotLinked;
import buildcraft.robotics.statements.TriggerRobotSleep;
import buildcraft.robotics.statements.ActionRobotWorkInArea.AreaType;
import buildcraft.silicon.ItemRedstoneChipset;
@Mod(name = "BuildCraft Robotics", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Robotics", dependencies = DefaultProps.DEPENDENCY_CORE)
@ -343,6 +344,8 @@ public class BuildCraftRobotics extends BuildCraftMod {
RobotManager.registerAIRobot(AIRobotUnloadFluids.class, "aiRobotUnloadFluids", "buildcraft.core.robots.AIRobotUnloadFluids");
RobotManager.registerAIRobot(AIRobotUseToolOnBlock.class, "aiRobotUseToolOnBlock", "buildcraft.core.robots.AIRobotUseToolOnBlock");
RobotManager.registerDockingStation(DockingStationPipe.class, "dockingStationPipe");
RoboticsProxy.proxy.registerRenderers();
}

View file

@ -0,0 +1,188 @@
package buildcraft.robotics;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.EnumColor;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TravelingItem;
import buildcraft.transport.gates.ActionIterator;
import buildcraft.transport.pipes.PipeFluidsWood;
import buildcraft.transport.pipes.PipeItemsWood;
public class DockingStationPipe extends DockingStation {
private IInjectable injectablePipe = new IInjectable() {
@Override
public boolean canInjectItems(ForgeDirection from) {
return true;
}
@Override
public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color) {
if (doAdd) {
float cx = x() + 0.5F + 0.2F * side().offsetX;
float cy = y() + 0.5F + 0.2F * side().offsetY;
float cz = z() + 0.5F + 0.2F * side().offsetZ;
TravelingItem item = TravelingItem.make(cx, cy, cz, stack);
((PipeTransportItems) ((Pipe) getPipe().getPipe()).transport)
.injectItem(item, from);
}
return stack.stackSize;
}
};
private IPipeTile pipe;
public DockingStationPipe() {
// Loading later from NBT
}
public DockingStationPipe(IPipeTile iPipe, ForgeDirection side) {
super(new BlockIndex(iPipe.x(), iPipe.y(), iPipe.z()), side);
pipe = iPipe;
world = iPipe.getWorld();
}
public IPipeTile getPipe() {
if (pipe == null) {
pipe = (IPipeTile) world.getTileEntity(x(), y(), z());
}
if (pipe == null || ((TileEntity) pipe).isInvalid()) {
// Inconsistency - remove this pipe from the registry.
RobotManager.registryProvider.getRegistry(world).removeStation(this);
pipe = null;
}
return pipe;
}
@Override
public Iterable<StatementSlot> getActiveActions() {
return new ActionIterator(getPipe().getPipe());
}
@Override
public IInjectable getItemOutput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
return null;
}
return injectablePipe;
}
@Override
public IInventory getItemInput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
return null;
}
if (!(getPipe().getPipe() instanceof PipeItemsWood)) {
return null;
}
int meta = ((TileEntity) getPipe()).getBlockMetadata();
ForgeDirection dir = ForgeDirection.getOrientation(meta);
TileEntity connectedTile = getPipe().getWorld().getTileEntity(x() + dir.offsetX,
y() + dir.offsetY, z() + dir.offsetZ);
if (connectedTile instanceof IInventory) {
return (IInventory) connectedTile;
}
return null;
}
@Override
public IFluidHandler getFluidInput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
return null;
}
if (!(getPipe().getPipe() instanceof PipeFluidsWood)) {
return null;
}
int meta = ((TileEntity) getPipe()).getBlockMetadata();
ForgeDirection dir = ForgeDirection.getOrientation(meta);
TileEntity connectedTile = getPipe().getWorld().getTileEntity(x() + dir.offsetX,
y() + dir.offsetY, z() + dir.offsetZ);
if (connectedTile instanceof IFluidHandler) {
return (IFluidHandler) connectedTile;
}
return null;
}
@Override
public IFluidHandler getFluidOutput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
return null;
}
return (IFluidHandler) ((Pipe) getPipe().getPipe()).transport;
}
@Override
public boolean providesPower() {
return getPipe().getPipeType() == IPipeTile.PipeType.POWER;
}
@Override
public IRequestProvider getRequestProvider() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = getPipe().getWorld().getTileEntity(x() + dir.offsetX,
y() + dir.offsetY, z() + dir.offsetZ);
if (nearbyTile instanceof IRequestProvider) {
return (IRequestProvider) nearbyTile;
}
}
return null;
}
@Override
public boolean isInitialized() {
return ((Pipe) getPipe().getPipe()).isInitialized();
}
@Override
public boolean take(EntityRobotBase robot) {
boolean result = super.take(robot);
if (result) {
getPipe().scheduleRenderUpdate();
}
return result;
}
@Override
public boolean takeAsMain(EntityRobotBase robot) {
boolean result = super.takeAsMain(robot);
if (result) {
getPipe().scheduleRenderUpdate();
}
return result;
}
@Override
public void unsafeRelease(EntityRobotBase robot) {
super.unsafeRelease(robot);
if (robotTaking() == null) {
getPipe().scheduleRenderUpdate();
}
}
}

View file

@ -53,7 +53,6 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.tiles.IDebuggable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.DefaultProps;
import buildcraft.core.ItemWrench;
import buildcraft.core.LaserData;
@ -68,8 +67,6 @@ import buildcraft.robotics.ai.AIRobotShutdown;
import buildcraft.robotics.ai.AIRobotSleep;
import buildcraft.robotics.statements.ActionRobotWorkInArea;
import buildcraft.robotics.statements.ActionRobotWorkInArea.AreaType;
import buildcraft.transport.Pipe;
import buildcraft.transport.gates.ActionIterator;
public class EntityRobot extends EntityRobotBase implements
IEntityAdditionalSpawnData, IInventory, IFluidHandler, ICommandReceiver, IDebuggable {
@ -315,8 +312,7 @@ public class EntityRobot extends EntityRobotBase implements
currentDockingStationSide);
}
if (linkedDockingStation == null ||
((Pipe) linkedDockingStation.getPipe().getPipe()).isInitialized()) {
if (linkedDockingStation == null || linkedDockingStation.isInitialized()) {
this.worldObj.theProfiler.startSection("bcRobotAIMainCycle");
mainAI.cycle();
this.worldObj.theProfiler.endSection();
@ -332,16 +328,6 @@ public class EntityRobot extends EntityRobotBase implements
this.worldObj.theProfiler.endSection();
}
private boolean linkedToChargeStation() {
if (currentDockingStation == null) {
return false;
}
if (currentDockingStation.getPipe().getPipeType() != IPipeTile.PipeType.POWER) {
return false;
}
return true;
}
@SideOnly(Side.CLIENT)
private void updateEnergyFX() {
energyFX += energySpendPerCycle;
@ -358,7 +344,7 @@ public class EntityRobot extends EntityRobotBase implements
worldObj,
posX + steamDx * 0.25, posY + steamDy * 0.25, posZ + steamDz * 0.25,
steamDx * 0.05, steamDy * 0.05, steamDz * 0.05,
energySpendPerCycle * 0.075F < 1 ? 1 : energySpendPerCycle * 0.075F));
energySpendPerCycle * 0.075F < 1 ? 1 : energySpendPerCycle * 0.075F));
}
public void setRegularBoundingBox() {
@ -586,7 +572,7 @@ public class EntityRobot extends EntityRobotBase implements
@Override
public void dock(DockingStation station) {
currentDockingStation = (DockingStation) station;
currentDockingStation = station;
setSteamDirection(
currentDockingStation.side.offsetX,
@ -901,8 +887,6 @@ public class EntityRobot extends EntityRobotBase implements
}
public void attackTargetEntityWithCurrentItem(Entity par1Entity) {
ItemStack stack = itemInUse;
if (par1Entity.canAttackWithItem()) {
if (!par1Entity.hitByEntity(this)) {
this.setLastAttacker(par1Entity);
@ -915,7 +899,6 @@ public class EntityRobot extends EntityRobotBase implements
if (itemstack != null && object instanceof EntityLivingBase) {
itemstack.getItem().hitEntity(itemstack, (EntityLivingBase) object, this);
}
}
}
}
@ -935,7 +918,7 @@ public class EntityRobot extends EntityRobotBase implements
}
private IZone getZone(AreaType areaType) {
for (StatementSlot s : new ActionIterator(linkedDockingStation.getPipe().getPipe())) {
for (StatementSlot s : linkedDockingStation.getActiveActions()) {
if (s.statement instanceof ActionRobotWorkInArea
&& ((ActionRobotWorkInArea) s.statement).getAreaType() == areaType) {
IZone zone = ActionRobotWorkInArea.getArea(s);

View file

@ -27,6 +27,7 @@ import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRobotRegistry;
import buildcraft.api.robots.ResourceId;
import buildcraft.api.robots.RobotManager;
public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
@ -204,7 +205,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
.clone();
for (StationIndex s : stationSet) {
DockingStation d = (DockingStation) stations.get(s);
DockingStation d = stations.get(s);
if (d != null) {
if (!d.canRelease()) {
@ -316,6 +317,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
for (Map.Entry<StationIndex, DockingStation> e : stations.entrySet()) {
NBTTagCompound cpt = new NBTTagCompound();
e.getValue().writeToNBT(cpt);
cpt.setString("stationType", RobotManager.getDockingStationName(e.getValue().getClass()));
stationList.appendTag(cpt);
}
@ -340,13 +342,31 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
for (int i = 0; i < stationList.tagCount(); ++i) {
NBTTagCompound cpt = stationList.getCompoundTagAt(i);
DockingStation station = new DockingStation();
station.readFromNBT(cpt);
registerStation(station);
Class<? extends DockingStation> cls = null;
if (station.linkedId() != EntityRobotBase.NULL_ROBOT_ID) {
take(station, station.linkedId());
if (!cpt.hasKey("stationType")) {
cls = DockingStationPipe.class;
} else {
cls = RobotManager.getDockingStationByName(cpt.getString("stationType"));
if (cls == null) {
BCLog.logger.error("Could not load docking station of type "
+ nbt.getString("stationType"));
continue;
}
}
try {
DockingStation station = cls.newInstance();
station.readFromNBT(cpt);
registerStation(station);
if (station.linkedId() != EntityRobotBase.NULL_ROBOT_ID) {
take(station, station.linkedId());
}
} catch (Exception e) {
BCLog.logger.error("Could not load docking station", e);
}
}
}

View file

@ -24,7 +24,7 @@ public class RobotRegistryProvider implements IRobotRegistryProvider {
newRegistry.world = world;
for (DockingStation d : newRegistry.stations.values()) {
((DockingStation) d).world = world;
d.world = world;
}
MinecraftForge.EVENT_BUS.register(newRegistry);

View file

@ -153,7 +153,7 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
}
private RobotStationState renderState;
private DockingStation station;
private DockingStationPipe station;
private boolean isValid = false;
public RobotStationPluggable() {
@ -199,7 +199,7 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
public void validate(IPipeTile pipe, ForgeDirection direction) {
TileGenericPipe gPipe = (TileGenericPipe) pipe;
if (!isValid && !gPipe.getWorld().isRemote) {
station = (DockingStation)
station = (DockingStationPipe)
RobotManager.registryProvider.getRegistry(gPipe.getWorld()).getStation(
gPipe.xCoord,
gPipe.yCoord,
@ -207,7 +207,7 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
direction);
if (station == null) {
station = new DockingStation(gPipe, direction);
station = new DockingStationPipe(gPipe, direction);
RobotManager.registryProvider.getRegistry(gPipe.getWorld()).registerStation(station);
}

View file

@ -105,7 +105,7 @@ public class AIRobotCraftWorkbench extends AIRobotCraftGeneric {
terminate();
}
} else if (ai instanceof AIRobotSearchAndGotoStation) {
if (new StationWorkbenchFilter().matches((DockingStation) robot.getDockingStation())) {
if (new StationWorkbenchFilter().matches(robot.getDockingStation())) {
craftingTimer = 40;
} else {
terminate();

View file

@ -9,20 +9,13 @@
package buildcraft.robotics.ai;
import net.minecraft.item.ItemStack;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.StackRequest;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IPipe;
import buildcraft.core.lib.inventory.InvUtils;
import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionStationRequestItemsMachine;
import buildcraft.transport.gates.ActionIterator;
public class AIRobotDeliverRequested extends AIRobot {
@ -85,30 +78,4 @@ public class AIRobotDeliverRequested extends AIRobot {
public boolean success() {
return delivered;
}
private class StationProviderFilter implements IStationFilter {
@Override
public boolean matches(DockingStation station) {
boolean actionFound = false;
IPipe pipe = station.getPipe().getPipe();
if (!station.index().nextTo(new BlockIndex(requested.requester))) {
return false;
}
for (StatementSlot s : new ActionIterator(pipe)) {
if (s.statement instanceof ActionStationRequestItemsMachine) {
actionFound = true;
}
}
if (!actionFound) {
return false;
}
return true;
}
}
}

View file

@ -37,7 +37,7 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
@Override
public void update() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter));
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
}
@Override
@ -61,14 +61,13 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
private void equipItemStack() {
if (robot.getDockingStation() != null) {
DockingStation station = (DockingStation) robot.getDockingStation();
DockingStation station = robot.getDockingStation();
ItemStack itemFound = null;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
station.y()
+ dir.offsetY, station.z() + dir.offsetZ);
station.y() + dir.offsetY, station.z() + dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IInventory) {
ITransactor trans = Transactor.getTransactorFor(nearbyTile);

View file

@ -34,11 +34,13 @@ public class AIRobotGotoStation extends AIRobot {
@Override
public void start() {
DockingStation station = (DockingStation)
robot.getRegistry().getStation(stationIndex.x, stationIndex.y, stationIndex.z,
stationSide);
DockingStation station = robot.getRegistry().getStation(stationIndex.x, stationIndex.y,
stationIndex.z, stationSide);
if (station == null || station == robot.getDockingStation()) {
if (station == null) {
terminate();
} else if (station == robot.getDockingStation()) {
setSuccess(true);
terminate();
} else {
if (station.take(robot)) {
@ -54,9 +56,8 @@ public class AIRobotGotoStation extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
DockingStation station = (DockingStation)
robot.getRegistry().getStation(stationIndex.x, stationIndex.y, stationIndex.z,
stationSide);
DockingStation station = robot.getRegistry().getStation(stationIndex.x, stationIndex.y,
stationIndex.z, stationSide);
if (station == null) {
terminate();

View file

@ -30,7 +30,7 @@ public class AIRobotGotoStationAndLoad extends AIRobot {
@Override
public void start() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter));
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, quantity));
}
@Override
@ -42,6 +42,9 @@ public class AIRobotGotoStationAndLoad extends AIRobot {
setSuccess(false);
terminate();
}
} else if (ai instanceof AIRobotGotoStationToLoad) {
setSuccess(ai.success());
terminate();
}
}
}

View file

@ -8,31 +8,26 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.ITransactor;
import buildcraft.core.lib.inventory.Transactor;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationProvideItems;
public class AIRobotGotoStationToLoad extends AIRobot {
private IStackFilter filter;
private int quantity;
public AIRobotGotoStationToLoad(EntityRobotBase iRobot) {
super(iRobot);
}
public AIRobotGotoStationToLoad(EntityRobotBase iRobot, IStackFilter iFilter) {
public AIRobotGotoStationToLoad(EntityRobotBase iRobot, IStackFilter iFilter, int iQuantity) {
this(iRobot);
filter = iFilter;
quantity = iQuantity;
}
@Override
@ -52,25 +47,7 @@ public class AIRobotGotoStationToLoad extends AIRobot {
@Override
public boolean matches(DockingStation station) {
if (!ActionRobotFilter.canInteractWithItem(station, filter, ActionStationProvideItems.class)) {
return false;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
+ dir.offsetY, station.z()
+ dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IInventory) {
ITransactor trans = Transactor.getTransactorFor(nearbyTile);
if (trans.remove(filter, dir.getOpposite(), false) != null) {
return true;
}
}
}
return false;
return AIRobotLoad.load(robot, station, filter, quantity, false);
}
}

View file

@ -8,22 +8,14 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.IFluidFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationProvideFluids;
public class AIRobotGotoStationToLoadFluids extends AIRobot {
private IZone zone;
private IFluidFilter filter;
public AIRobotGotoStationToLoadFluids(EntityRobotBase iRobot) {
@ -38,7 +30,8 @@ public class AIRobotGotoStationToLoadFluids extends AIRobot {
@Override
public void update() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), robot.getZoneToLoadUnload()));
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(),
robot.getZoneToLoadUnload()));
}
@Override
@ -53,31 +46,7 @@ public class AIRobotGotoStationToLoadFluids extends AIRobot {
@Override
public boolean matches(DockingStation station) {
if (!ActionRobotFilter.canInteractWithFluid(station, filter, ActionStationProvideFluids.class)) {
return false;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
+ dir.offsetY, station.z()
+ dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IFluidHandler) {
IFluidHandler handler = (IFluidHandler) nearbyTile;
FluidStack drainable = handler.drain(station.side, 1, false);
// TODO: there is no account taken for the filter on the
// gate here. See LoadFluid, GotoStationToLoad and Load for
// items as well.
if (drainable != null
&& filter.matches(drainable.getFluid())
&& robot.canFill(ForgeDirection.UNKNOWN, drainable.getFluid())) {
return true;
}
}
}
return false;
return AIRobotLoadFluids.load(robot, station, filter, false) > 0;
}
}

View file

@ -8,18 +8,10 @@
*/
package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IPipe;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.robotics.EntityRobot;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionStationInputItems;
import buildcraft.transport.gates.ActionIterator;
public class AIRobotGotoStationToUnload extends AIRobot {
@ -43,23 +35,7 @@ public class AIRobotGotoStationToUnload extends AIRobot {
private class StationInventory implements IStationFilter {
@Override
public boolean matches(DockingStation station) {
IPipe pipe = station.getPipe().getPipe();
for (IInvSlot robotSlot : InventoryIterator.getIterable(robot, ForgeDirection.UNKNOWN)) {
if (robotSlot.getStackInSlot() == null) {
continue;
}
for (StatementSlot s : new ActionIterator(pipe)) {
if (s.statement instanceof ActionStationInputItems) {
if (((ActionStationInputItems) s.statement).insert(station, (EntityRobot) robot, s, robotSlot, false)) {
return true;
}
}
}
}
return false;
return AIRobotUnload.unload(robot, station, false);
}
}

View file

@ -8,17 +8,10 @@
*/
package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.SimpleFluidFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationAcceptFluids;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportFluids;
public class AIRobotGotoStationToUnloadFluids extends AIRobot {
@ -28,7 +21,8 @@ public class AIRobotGotoStationToUnloadFluids extends AIRobot {
@Override
public void update() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), robot.getZoneToLoadUnload()));
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(),
robot.getZoneToLoadUnload()));
}
@Override
@ -43,24 +37,7 @@ public class AIRobotGotoStationToUnloadFluids extends AIRobot {
@Override
public boolean matches(DockingStation station) {
if (!ActionRobotFilter.canInteractWithFluid(station,
new SimpleFluidFilter(robot.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid),
ActionStationAcceptFluids.class)) {
return false;
}
if (((Pipe) station.getPipe().getPipe()).transport instanceof PipeTransportFluids) {
PipeTransportFluids transport = (PipeTransportFluids) ((Pipe) station.getPipe().getPipe()).transport;
FluidStack drainable = robot.drain(ForgeDirection.UNKNOWN, 1, false);
int filledAmount = transport.fill(station.side, drainable, false);
if (filledAmount > 0) {
return true;
}
}
return false;
return AIRobotUnloadFluids.unload(robot, station, false) > 0;
}
}

View file

@ -10,7 +10,6 @@ package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.AIRobot;
@ -52,59 +51,62 @@ public class AIRobotLoad extends AIRobot {
waitedCycles++;
if (waitedCycles > 40) {
doLoad();
setSuccess(load(robot, robot.getDockingStation(), filter, quantity, true));
terminate();
}
}
private void doLoad() {
if (robot.getDockingStation() != null) {
DockingStation station = (DockingStation) robot.getDockingStation();
public static boolean load(EntityRobotBase robot, DockingStation station, IStackFilter filter,
int quantity, boolean doLoad) {
if (station == null) {
return false;
}
int loaded = 0;
int loaded = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
station.y()
+ dir.offsetY, station.z() + dir.offsetZ);
IInventory tileInventory = station.getItemInput();
if (tileInventory == null) {
return false;
}
if (nearbyTile != null && nearbyTile instanceof IInventory) {
IInventory tileInventory = (IInventory) nearbyTile;
ITransactor robotTransactor = Transactor.getTransactorFor(robot);
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory)) {
ItemStack stack = slot.getStackInSlot();
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, dir.getOpposite())) {
ItemStack stack = slot.getStackInSlot();
if (stack == null
|| !filter.matches(stack)
|| !ActionRobotFilter.canInteractWithItem(station, filter,
ActionStationProvideItems.class)) {
continue;
}
if (stack != null) {
if (ActionRobotFilter.canInteractWithItem(station, filter, ActionStationProvideItems.class)
&& filter.matches(stack)) {
ITransactor robotTransactor = Transactor.getTransactorFor(robot);
ITransactor t = Transactor.getTransactorFor(robot);
if (quantity == ANY_QUANTITY) {
ItemStack added = robotTransactor.add(slot.getStackInSlot(),
ForgeDirection.UNKNOWN, doLoad);
if (doLoad) {
slot.decreaseStackInSlot(added.stackSize);
}
return added.stackSize > 0;
} else {
ItemStack toAdd = slot.getStackInSlot().copy();
if (quantity == ANY_QUANTITY) {
ItemStack added = t.add(slot.getStackInSlot(), ForgeDirection.UNKNOWN, true);
slot.decreaseStackInSlot(added.stackSize);
} else {
ItemStack toAdd = slot.getStackInSlot().copy();
if (toAdd.stackSize > quantity - loaded) {
toAdd.stackSize = quantity - loaded;
}
if (toAdd.stackSize > quantity - loaded) {
toAdd.stackSize = quantity - loaded;
}
ItemStack added = robotTransactor.add(toAdd, ForgeDirection.UNKNOWN, doLoad);
if (doLoad) {
slot.decreaseStackInSlot(added.stackSize);
}
loaded += added.stackSize;
ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true);
slot.decreaseStackInSlot(added.stackSize);
loaded += added.stackSize;
if (quantity - loaded <= 0) {
return;
}
}
}
}
}
if (quantity - loaded <= 0) {
return true;
}
}
}
return false;
}
@Override

View file

@ -8,7 +8,6 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@ -22,7 +21,6 @@ import buildcraft.robotics.statements.ActionStationProvideFluids;
public class AIRobotLoadFluids extends AIRobot {
private int loaded = 0;
private int waitedCycles = 0;
private IFluidFilter filter;
@ -34,6 +32,7 @@ public class AIRobotLoadFluids extends AIRobot {
this(iRobot);
filter = iFilter;
setSuccess(false);
}
@Override
@ -41,51 +40,45 @@ public class AIRobotLoadFluids extends AIRobot {
waitedCycles++;
if (waitedCycles > 40) {
int previousLoaded = loaded;
doLoad();
if (loaded == previousLoaded) {
if (load(robot, robot.getDockingStation(), filter, true) == 0) {
terminate();
} else {
setSuccess(true);
waitedCycles = 0;
}
}
}
private void doLoad() {
if (robot.getDockingStation() != null) {
DockingStation station = (DockingStation) robot.getDockingStation();
if (!ActionRobotFilter.canInteractWithFluid(station, filter, ActionStationProvideFluids.class)) {
return;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
+ dir.offsetY, station.z()
+ dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IFluidHandler) {
IFluidHandler handler = (IFluidHandler) nearbyTile;
FluidStack drainable = handler.drain(station.side, FluidContainerRegistry.BUCKET_VOLUME, false);
if (drainable != null
&& filter.matches(drainable.getFluid())) {
drainable = drainable.copy();
int filled = robot.fill(ForgeDirection.UNKNOWN, drainable, true);
if (filled > 0) {
drainable.amount = filled;
handler.drain(station.side, drainable, true);
loaded += filled;
return;
}
}
}
}
public static int load(EntityRobotBase robot, DockingStation station, IFluidFilter filter,
boolean doLoad) {
if (station == null) {
return 0;
}
if (!ActionRobotFilter.canInteractWithFluid(station, filter,
ActionStationProvideFluids.class)) {
return 0;
}
IFluidHandler handler = station.getFluidInput();
if (handler == null) {
return 0;
}
FluidStack drainable = handler.drain(station.side, FluidContainerRegistry.BUCKET_VOLUME,
false);
if (drainable == null || !filter.matches(drainable.getFluid())) {
return 0;
}
drainable = drainable.copy();
int filled = robot.fill(ForgeDirection.UNKNOWN, drainable, doLoad);
if (filled > 0 && doLoad) {
drainable.amount = filled;
handler.drain(station.side, drainable, true);
}
return filled;
}
@Override
@ -93,8 +86,4 @@ public class AIRobotLoadFluids extends AIRobot {
return 8;
}
@Override
public boolean success() {
return loaded > 0;
}
}

View file

@ -28,7 +28,8 @@ public class AIRobotMain extends AIRobot {
@Override
public void preempt(AIRobot ai) {
if (robot.getEnergy() <= EntityRobotBase.SHUTDOWN_ENERGY) {
if (robot.getEnergy() <= EntityRobotBase.SHUTDOWN_ENERGY
&& (robot.getDockingStation() == null || !robot.getDockingStation().providesPower())) {
if (!(ai instanceof AIRobotShutdown)) {
startDelegateAI(new AIRobotShutdown(robot));
}

View file

@ -11,7 +11,6 @@ package buildcraft.robotics.ai;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.transport.IPipeTile;
import buildcraft.robotics.IStationFilter;
public class AIRobotRecharge extends AIRobot {
@ -33,7 +32,7 @@ public class AIRobotRecharge extends AIRobot {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new IStationFilter() {
@Override
public boolean matches(DockingStation station) {
return station.getPipe().getPipeType() == IPipeTile.PipeType.POWER;
return station.providesPower();
}
}, null));
}

View file

@ -10,8 +10,6 @@ package buildcraft.robotics.ai;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
@ -20,14 +18,12 @@ import buildcraft.api.robots.StackRequest;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IPipe;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationRequestItems;
import buildcraft.robotics.statements.ActionStationRequestItemsMachine;
import buildcraft.transport.gates.ActionIterator;
public class AIRobotSearchStackRequest extends AIRobot {
@ -90,30 +86,25 @@ public class AIRobotSearchStackRequest extends AIRobot {
return null;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
+ dir.offsetY, station.z()
+ dir.offsetZ);
IRequestProvider provider = station.getRequestProvider();
if (provider == null) {
return null;
}
if (nearbyTile instanceof IRequestProvider) {
IRequestProvider provider = (IRequestProvider) nearbyTile;
for (int i = 0; i < provider.getNumberOfRequests(); ++i) {
StackRequest requestFound = provider.getAvailableRequest(i);
for (int i = 0; i < provider.getNumberOfRequests(); ++i) {
StackRequest requestFound = provider.getAvailableRequest(i);
if (requestFound != null
&& !isBlacklisted(requestFound.stack)
&& filter.matches(requestFound.stack)) {
requestFound.station = station;
if (requestFound != null
&& !isBlacklisted(requestFound.stack)
&& filter.matches(requestFound.stack)) {
requestFound.station = station;
if (take) {
if (provider.takeRequest(i, robot)) {
return requestFound;
}
} else {
return requestFound;
}
if (take) {
if (provider.takeRequest(i, robot)) {
return requestFound;
}
} else {
return requestFound;
}
}
}
@ -122,10 +113,7 @@ public class AIRobotSearchStackRequest extends AIRobot {
}
private StackRequest getOrderFromRequestingAction(DockingStation station) {
boolean actionFound = false;
IPipe pipe = station.getPipe().getPipe();
for (StatementSlot s : new ActionIterator(pipe)) {
for (StatementSlot s : station.getActiveActions()) {
if (s.statement instanceof ActionStationRequestItems) {
for (IStatementParameter p : s.parameters) {
StatementParameterItemStack param = (StatementParameterItemStack) p;

View file

@ -35,8 +35,8 @@ public class AIRobotSearchStation extends AIRobot {
@Override
public void start() {
if (robot.getDockingStation() != null
&& filter.matches((DockingStation) robot.getDockingStation())) {
targetStation = (DockingStation) robot.getDockingStation();
&& filter.matches(robot.getDockingStation())) {
targetStation = robot.getDockingStation();
terminate();
return;
}
@ -44,14 +44,13 @@ public class AIRobotSearchStation extends AIRobot {
double potentialStationDistance = Float.MAX_VALUE;
DockingStation potentialStation = null;
for (DockingStation d : robot.getRegistry().getStations()) {
DockingStation station = (DockingStation) d;
for (DockingStation station : robot.getRegistry().getStations()) {
if (d.isTaken() && d.robotIdTaking() != robot.getRobotId()) {
if (station.isTaken() && station.robotIdTaking() != robot.getRobotId()) {
continue;
}
if (zone != null && !zone.contains(d.x(), d.y(), d.z())) {
if (zone != null && !zone.contains(station.x(), station.y(), station.z())) {
continue;
}
@ -60,9 +59,9 @@ public class AIRobotSearchStation extends AIRobot {
continue;
}
double dx = robot.posX - d.x();
double dy = robot.posY - d.y();
double dz = robot.posZ - d.z();
double dx = robot.posX - station.x();
double dy = robot.posY - station.y();
double dz = robot.posZ - station.z();
double distance = dx * dx + dy * dy + dz * dz;
if (potentialStation == null || distance < potentialStationDistance) {

View file

@ -9,11 +9,9 @@
package buildcraft.robotics.ai;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.statements.StatementSlot;
import buildcraft.robotics.statements.ActionRobotWakeUp;
import buildcraft.transport.gates.ActionIterator;
public class AIRobotSleep extends AIRobot {
@ -26,7 +24,7 @@ public class AIRobotSleep extends AIRobot {
@Override
public void preempt(AIRobot ai) {
for (StatementSlot s : new ActionIterator(((DockingStation) robot.getLinkedStation()).getPipe().getPipe())) {
for (StatementSlot s :robot.getLinkedStation().getActiveActions()) {
if (s.statement instanceof ActionRobotWakeUp) {
terminate();
}

View file

@ -8,17 +8,17 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IInjectable;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.robotics.EntityRobot;
import buildcraft.core.lib.inventory.filters.ArrayStackFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationInputItems;
import buildcraft.transport.gates.ActionIterator;
public class AIRobotUnload extends AIRobot {
@ -33,36 +33,50 @@ public class AIRobotUnload extends AIRobot {
waitedCycles++;
if (waitedCycles > 40) {
if (!doUnload()) {
terminate();
} else {
if (unload(robot, robot.getDockingStation(), true)) {
waitedCycles = 0;
} else {
setSuccess(!robot.containsItems());
terminate();
}
}
}
private boolean doUnload() {
DockingStation station = (DockingStation) robot.getDockingStation();
public static boolean unload(EntityRobotBase robot, DockingStation station, boolean doUnload) {
if (station == null) {
setSuccess(false);
return false;
}
IPipe pipe = station.getPipe().getPipe();
IInjectable output = station.getItemOutput();
if (output == null) {
return false;
}
for (IInvSlot robotSlot : InventoryIterator.getIterable(robot, ForgeDirection.UNKNOWN)) {
if (robotSlot.getStackInSlot() == null) {
continue;
}
for (StatementSlot s : new ActionIterator(pipe)) {
if (s.statement instanceof ActionStationInputItems) {
if (((ActionStationInputItems) s.statement)
.insert(station, (EntityRobot) robot, s, robotSlot, true)) {
return true;
if (!ActionRobotFilter
.canInteractWithItem(station, new ArrayStackFilter(robotSlot.getStackInSlot()),
ActionStationInputItems.class)) {
return false;
}
ForgeDirection injectSide = station.side().getOpposite();
ItemStack stack = robotSlot.getStackInSlot();
int used = output.injectItem(stack, doUnload, injectSide, null);
if (used > 0) {
if (doUnload) {
stack.stackSize -= used;
if (stack.stackSize > 0) {
robotSlot.setStackInSlot(stack);
} else {
robotSlot.setStackInSlot(null);
}
}
return true;
}
}

View file

@ -11,71 +11,69 @@ package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.SimpleFluidFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationAcceptFluids;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportFluids;
public class AIRobotUnloadFluids extends AIRobot {
private int unloaded = 0;
private int waitedCycles = 0;
public AIRobotUnloadFluids(EntityRobotBase iRobot) {
super(iRobot);
setSuccess(false);
}
@Override
public void update() {
int previousUnloaded = unloaded;
doLoad();
waitedCycles++;
if (unloaded == previousUnloaded) {
terminate();
if (waitedCycles > 40) {
if (unload(robot, robot.getDockingStation(), true) == 0) {
terminate();
} else {
setSuccess(true);
}
}
}
private void doLoad() {
if (robot.getDockingStation() != null) {
DockingStation station = (DockingStation) robot.getDockingStation();
if (!ActionRobotFilter.canInteractWithFluid(station,
new SimpleFluidFilter(robot.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid),
ActionStationAcceptFluids.class)) {
return;
}
if (((Pipe) station.getPipe().getPipe()).transport instanceof PipeTransportFluids) {
PipeTransportFluids transport = (PipeTransportFluids) ((Pipe) station.getPipe().getPipe()).transport;
FluidStack drainable = robot.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.BUCKET_VOLUME,
false);
if (drainable != null) {
drainable = drainable.copy();
int filled = transport.fill(station.side, drainable, true);
if (filled > 0) {
drainable.amount = filled;
robot.drain(ForgeDirection.UNKNOWN, drainable, true);
unloaded += filled;
return;
}
}
}
public static int unload(EntityRobotBase robot, DockingStation station, boolean doUnload) {
if (station == null) {
return 0;
}
if (!ActionRobotFilter.canInteractWithFluid(station,
new SimpleFluidFilter(robot.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid),
ActionStationAcceptFluids.class)) {
return 0;
}
IFluidHandler fluidHandler = station.getFluidOutput();
if (fluidHandler == null) {
return 0;
}
FluidStack drainable = robot.drain(ForgeDirection.UNKNOWN,
FluidContainerRegistry.BUCKET_VOLUME, false);
if (drainable == null) {
return 0;
}
drainable = drainable.copy();
int filled = fluidHandler.fill(station.side, drainable, doUnload);
if (filled > 0 && doUnload) {
drainable.amount = filled;
robot.drain(ForgeDirection.UNKNOWN, drainable, true);
}
return filled;
}
@Override
public int getEnergyCost() {
return 10;
}
@Override
public boolean success() {
return unloaded > 0;
}
}

View file

@ -17,7 +17,6 @@ import net.minecraft.world.World;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.ResourceIdBlock;
import buildcraft.api.statements.IStatementParameter;
@ -30,7 +29,6 @@ import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robotics.ai.AIRobotGotoSleep;
import buildcraft.robotics.ai.AIRobotSearchAndGotoBlock;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.transport.gates.ActionIterator;
public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
@ -112,9 +110,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
blockFilter.clear();
metaFilter.clear();
DockingStation station = (DockingStation) robot.getLinkedStation();
for (StatementSlot slot : new ActionIterator(station.getPipe().getPipe())) {
for (StatementSlot slot : robot.getLinkedStation().getActiveActions()) {
if (slot.statement instanceof ActionRobotFilter) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {

View file

@ -8,13 +8,10 @@
*/
package buildcraft.robotics.boards;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.boards.RedstoneBoardRobot;
@ -23,24 +20,21 @@ import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.IWorldProperty;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.ResourceIdBlock;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.inventory.filters.IFluidFilter;
import buildcraft.core.lib.inventory.filters.PassThroughFluidFilter;
import buildcraft.core.lib.utils.IBlockFilter;
import buildcraft.robotics.ai.AIRobotGotoSleep;
import buildcraft.robotics.ai.AIRobotGotoStationAndUnloadFluids;
import buildcraft.robotics.ai.AIRobotPumpBlock;
import buildcraft.robotics.ai.AIRobotSearchAndGotoBlock;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.transport.gates.ActionIterator;
public class BoardRobotPump extends RedstoneBoardRobot {
private BlockIndex blockFound;
private ArrayList<Fluid> fluidFilter = new ArrayList<Fluid>();
private IFluidFilter fluidFilter = null;
public BoardRobotPump(EntityRobotBase iRobot) {
super(iRobot);
@ -102,32 +96,14 @@ public class BoardRobotPump extends RedstoneBoardRobot {
}
public void updateFilter() {
fluidFilter.clear();
DockingStation station = (DockingStation) robot.getLinkedStation();
for (StatementSlot slot : new ActionIterator(station.getPipe().getPipe())) {
if (slot.statement instanceof ActionRobotFilter) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {
StatementParameterItemStack param = (StatementParameterItemStack) p;
ItemStack stack = param.getItemStack();
if (stack != null) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluid != null) {
fluidFilter.add(fluid.getFluid());
}
}
}
}
}
fluidFilter = ActionRobotFilter.getGateFluidFilter(robot.getLinkedStation());
if (fluidFilter instanceof PassThroughFluidFilter) {
fluidFilter = null;
}
}
private boolean matchesGateFilter(World world, int x, int y, int z) {
if (fluidFilter.size() == 0) {
if (fluidFilter == null) {
return true;
}
@ -138,13 +114,7 @@ public class BoardRobotPump extends RedstoneBoardRobot {
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
for (Fluid f : fluidFilter) {
if (f.getID() == fluid.getID()) {
return true;
}
}
return false;
return fluidFilter.matches(fluid);
}
}

View file

@ -20,7 +20,6 @@ import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IPipe;
import buildcraft.core.lib.inventory.filters.ArrayFluidFilter;
import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter;
import buildcraft.core.lib.inventory.filters.IFluidFilter;
@ -30,7 +29,6 @@ import buildcraft.core.lib.inventory.filters.PassThroughStackFilter;
import buildcraft.core.lib.inventory.filters.StatementParameterStackFilter;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
import buildcraft.transport.gates.ActionIterator;
public class ActionRobotFilter extends BCStatement implements IActionInternal {
@ -66,7 +64,7 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal {
public static Collection<ItemStack> getGateFilterStacks(DockingStation station) {
ArrayList<ItemStack> result = new ArrayList<ItemStack>();
for (StatementSlot slot : new ActionIterator(((DockingStation) station).getPipe().getPipe())) {
for (StatementSlot slot : station.getActiveActions()) {
if (slot.statement instanceof ActionRobotFilter) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {
@ -107,9 +105,7 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal {
public static boolean canInteractWithItem(DockingStation station, IStackFilter filter, Class<?> actionClass) {
boolean actionFound = false;
IPipe pipe = station.getPipe().getPipe();
for (StatementSlot s : new ActionIterator(pipe)) {
for (StatementSlot s : station.getActiveActions()) {
if (actionClass.isAssignableFrom(s.statement.getClass())) {
StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);
@ -125,9 +121,8 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal {
public static boolean canInteractWithFluid(DockingStation station, IFluidFilter filter, Class<?> actionClass) {
boolean actionFound = false;
IPipe pipe = station.getPipe().getPipe();
for (StatementSlot s : new ActionIterator(pipe)) {
for (StatementSlot s : station.getActiveActions()) {
if (actionClass.isAssignableFrom(s.statement.getClass())) {
StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);

View file

@ -23,7 +23,6 @@ import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.core.lib.inventory.filters.PassThroughStackFilter;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
import buildcraft.transport.gates.ActionIterator;
public class ActionRobotFilterTool extends BCStatement implements IActionInternal {
@ -59,7 +58,7 @@ public class ActionRobotFilterTool extends BCStatement implements IActionInterna
public static Collection<ItemStack> getGateFilterStacks(DockingStation station) {
ArrayList<ItemStack> result = new ArrayList<ItemStack>();
for (StatementSlot slot : new ActionIterator(((DockingStation) station).getPipe().getPipe())) {
for (StatementSlot slot : station.getActiveActions()) {
if (slot.statement instanceof ActionRobotFilterTool) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {

View file

@ -8,8 +8,6 @@
*/
package buildcraft.robotics.statements;
import javax.print.Doc;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
@ -18,16 +16,15 @@ import buildcraft.api.core.BlockIndex;
import buildcraft.api.items.IMapLocation;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.IRobotRegistry;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
import buildcraft.robotics.EntityRobot;
import buildcraft.robotics.RobotRegistry;
import buildcraft.robotics.RobotUtils;
import buildcraft.robotics.ai.AIRobotGoAndLinkToDock;
@ -49,14 +46,10 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
@Override
public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) {
if (!(container.getTile() instanceof IPipeTile)) {
return;
}
IRobotRegistry registry = RobotManager.registryProvider.getRegistry(container.getTile()
.getWorldObj());
IPipeTile tile = (IPipeTile) container.getTile();
RobotRegistry registry = (RobotRegistry) RobotManager.registryProvider.getRegistry(tile.getWorld());
List<DockingStation> stations = RobotUtils.getStations(tile);
List<DockingStation> stations = RobotUtils.getStations(container.getTile());
for (DockingStation station : stations) {
if (station.robotTaking() != null) {
@ -70,24 +63,7 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
DockingStation newStation = station;
if (parameters[0] != null) {
StatementParameterItemStack stackParam = (StatementParameterItemStack) parameters[0];
ItemStack item = stackParam.getItemStack();
if (item != null && item.getItem() instanceof IMapLocation) {
IMapLocation map = (IMapLocation) item.getItem();
BlockIndex index = map.getPoint(item);
if (index != null) {
ForgeDirection side = map.getPointSide(item);
DockingStation paramStation = (DockingStation)
registry.getStation(index.x,
index.y, index.z, side);
if (paramStation != null) {
newStation = paramStation;
}
}
}
newStation = getStation((StatementParameterItemStack) parameters[0], registry);
}
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
@ -95,6 +71,26 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
}
}
private DockingStation getStation(StatementParameterItemStack stackParam,
IRobotRegistry registry) {
ItemStack item = stackParam.getItemStack();
if (item != null && item.getItem() instanceof IMapLocation) {
IMapLocation map = (IMapLocation) item.getItem();
BlockIndex index = map.getPoint(item);
if (index != null) {
ForgeDirection side = map.getPointSide(item);
DockingStation paramStation = registry.getStation(index.x, index.y, index.z, side);
if (paramStation != null) {
return paramStation;
}
}
}
return null;
}
@Override
public int maxParameters() {
return 1;

View file

@ -9,17 +9,17 @@
package buildcraft.robotics.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementManager;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IInjectable;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.robotics.EntityRobot;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TravelingItem;
public class ActionStationAcceptItems extends ActionStationInputItems {
@ -55,21 +55,31 @@ public class ActionStationAcceptItems extends ActionStationInputItems {
return false;
}
IInjectable injectable = station.getItemOutput();
if (injectable == null) {
return false;
}
ForgeDirection injectSide = station.side().getOpposite();
if (!injectable.canInjectItems(injectSide)) {
return false;
}
if (!doInsert) {
return true;
}
if (((Pipe) station.getPipe().getPipe()).transport instanceof PipeTransportItems) {
float cx = station.x() + 0.5F + 0.2F * station.side().offsetX;
float cy = station.y() + 0.5F + 0.2F * station.side().offsetY;
float cz = station.z() + 0.5F + 0.2F * station.side().offsetZ;
TravelingItem item = TravelingItem.make(cx, cy, cz, invSlot.getStackInSlot());
((PipeTransportItems) ((Pipe) station.getPipe().getPipe()).transport).injectItem(item, station.side().getOpposite());
invSlot.setStackInSlot(null);
ItemStack stack = invSlot.getStackInSlot();
int used = injectable.injectItem(stack, doInsert, injectSide, null);
if (used > 0) {
stack.stackSize -= used;
if (stack.stackSize > 0) {
invSlot.setStackInSlot(stack);
} else {
invSlot.setStackInSlot(null);
}
return true;
}

View file

@ -20,7 +20,6 @@ import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
import buildcraft.robotics.ItemRobot;
import buildcraft.transport.gates.ActionIterator;
public class ActionStationForbidRobot extends BCStatement implements IActionInternal {
private final boolean invert;
@ -56,7 +55,7 @@ public class ActionStationForbidRobot extends BCStatement implements IActionInte
}
public static boolean isForbidden(DockingStation station, EntityRobotBase robot) {
for (StatementSlot s : new ActionIterator(station.getPipe().getPipe())) {
for (StatementSlot s : station.getActiveActions()) {
if (s.statement instanceof ActionStationForbidRobot) {
if (((ActionStationForbidRobot) s.statement).invert ^ ActionStationForbidRobot.isForbidden(s, robot)) {
return true;
@ -70,7 +69,6 @@ public class ActionStationForbidRobot extends BCStatement implements IActionInte
public static boolean isForbidden(StatementSlot slot, EntityRobotBase robot) {
for (IStatementParameter p : slot.parameters) {
if (p != null) {
StatementParameterItemStack actionStack = (StatementParameterItemStack) p;
ItemStack stack = p.getItemStack();
if (stack != null && stack.getItem() instanceof ItemRobot) {

View file

@ -9,16 +9,16 @@
package buildcraft.robotics.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IInjectable;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.robotics.EntityRobot;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TravelingItem;
public class ActionStationRequestItems extends ActionStationInputItems {
@ -58,17 +58,31 @@ public class ActionStationRequestItems extends ActionStationInputItems {
return false;
}
if (((Pipe) station.getPipe().getPipe()).transport instanceof PipeTransportItems) {
float cx = station.x() + 0.5F + 0.2F * station.side().offsetX;
float cy = station.y() + 0.5F + 0.2F * station.side().offsetY;
float cz = station.z() + 0.5F + 0.2F * station.side().offsetZ;
IInjectable injectable = station.getItemOutput();
TravelingItem item = TravelingItem.make(cx, cy, cz, invSlot.getStackInSlot());
if (injectable == null) {
return false;
}
((PipeTransportItems) ((Pipe) station.getPipe().getPipe()).transport).injectItem(item, station.side().getOpposite());
ForgeDirection injectSide = station.side().getOpposite();
invSlot.setStackInSlot(null);
if (!injectable.canInjectItems(injectSide)) {
return false;
}
if (!doInsert) {
return true;
}
ItemStack stack = invSlot.getStackInSlot();
int used = injectable.injectItem(stack, doInsert, injectSide, null);
if (used > 0) {
stack.stackSize -= used;
if (stack.stackSize > 0) {
invSlot.setStackInSlot(stack);
} else {
invSlot.setStackInSlot(null);
}
return true;
}

View file

@ -13,23 +13,19 @@ import java.util.LinkedList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWorkbench;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftRobotics;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.statements.IActionExternal;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IActionProvider;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.IPipeTile.PipeType;
import buildcraft.robotics.RobotUtils;
import buildcraft.silicon.TileAssemblyTable;
import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
public class RobotsActionProvider implements IActionProvider {
@ -38,12 +34,14 @@ public class RobotsActionProvider implements IActionProvider {
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
LinkedList<IActionInternal> result = new LinkedList<IActionInternal>();
TileEntity tile = container.getTile();
if (!(tile instanceof IPipeTile)) {
return result;
}
List<DockingStation> stations = RobotUtils.getStations(tile);
IPipeTile pipeTile = (IPipeTile) tile;
List<DockingStation> stations = RobotUtils.getStations(pipeTile);
if (stations.size() == 0) {
return result;
@ -58,32 +56,32 @@ public class RobotsActionProvider implements IActionProvider {
result.add(BuildCraftRobotics.actionStationForbidRobot);
result.add(BuildCraftRobotics.actionStationForceRobot);
if (((TileGenericPipe) tile).pipe.transport instanceof PipeTransportItems) {
if (pipeTile.getPipeType() == PipeType.ITEM) {
result.add(BuildCraftRobotics.actionStationRequestItems);
result.add(BuildCraftRobotics.actionStationAcceptItems);
}
if (((TileGenericPipe) tile).pipe.transport instanceof PipeTransportFluids) {
if (pipeTile.getPipeType() == PipeType.FLUID) {
result.add(BuildCraftRobotics.actionStationAcceptFluids);
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity sideTile = ((TileGenericPipe) tile).getTile(dir);
Block sideBlock = ((TileGenericPipe) tile).getBlock(dir);
for (DockingStation station : stations) {
TileEntity sideTile = ((TileGenericPipe) tile).getTile(station.side);
Block sideBlock = ((TileGenericPipe) tile).getBlock(station.side);
if (sideTile instanceof IPipeTile) {
continue;
}
if (sideTile instanceof IInventory) {
if (station.getItemInput() != null) {
result.add(BuildCraftRobotics.actionStationProvideItems);
}
if (sideTile instanceof IFluidHandler) {
if (station.getFluidInput() != null) {
result.add(BuildCraftRobotics.actionStationProvideFluids);
}
if (sideTile instanceof IRequestProvider) {
if (station.getRequestProvider() != null) {
result.add(BuildCraftRobotics.actionStationMachineRequestItems);
}