From a9c7c1a2e804fc3960468effde7c54aeb1dc76d8 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Fri, 3 Apr 2015 13:16:22 +0200 Subject: [PATCH] refactors to robot docking station code, allow TEs to provide a singular docking station (wip) --- common/buildcraft/BuildCraftCore.java | 2 +- common/buildcraft/BuildCraftEnergy.java | 2 +- common/buildcraft/BuildCraftRobotics.java | 44 ++-- common/buildcraft/BuildCraftTransport.java | 1 - .../core/blueprints/BptBuilderBase.java | 1 - .../core/blueprints/BptBuilderBlueprint.java | 1 - .../core/blueprints/BptBuilderTemplate.java | 1 - .../buildcraft/core/config/ConfigManager.java | 2 - .../core/recipes/AssemblyRecipeManager.java | 1 - .../core/recipes/RefineryRecipeManager.java | 1 - .../buildcraft/robotics/DockingStation.java | 210 ------------------ common/buildcraft/robotics/EntityRobot.java | 15 +- .../buildcraft/robotics/IStationFilter.java | 2 + common/buildcraft/robotics/ItemRobot.java | 1 + common/buildcraft/robotics/RobotRegistry.java | 18 +- .../robotics/RobotRegistryProvider.java | 4 +- .../robotics/RobotStationPluggable.java | 5 +- common/buildcraft/robotics/RobotUtils.java | 30 ++- common/buildcraft/robotics/StationIndex.java | 4 +- .../ai/AIRobotCraftAssemblyTable.java | 2 +- .../robotics/ai/AIRobotCraftFurnace.java | 2 +- .../robotics/ai/AIRobotCraftWorkbench.java | 2 +- .../robotics/ai/AIRobotDeliverRequested.java | 2 +- .../ai/AIRobotFetchAndEquipItemStack.java | 2 +- .../robotics/ai/AIRobotGoAndLinkToDock.java | 14 +- .../robotics/ai/AIRobotGotoStation.java | 5 +- .../ai/AIRobotGotoStationAndUnload.java | 2 +- .../robotics/ai/AIRobotGotoStationToLoad.java | 2 +- .../ai/AIRobotGotoStationToLoadFluids.java | 2 +- .../ai/AIRobotGotoStationToUnload.java | 2 +- .../ai/AIRobotGotoStationToUnloadFluids.java | 2 +- .../buildcraft/robotics/ai/AIRobotLoad.java | 2 +- .../robotics/ai/AIRobotLoadFluids.java | 2 +- .../robotics/ai/AIRobotRecharge.java | 2 +- .../ai/AIRobotSearchAndGotoStation.java | 2 +- .../ai/AIRobotSearchStackRequest.java | 2 +- .../robotics/ai/AIRobotSearchStation.java | 5 +- .../buildcraft/robotics/ai/AIRobotSleep.java | 2 +- .../buildcraft/robotics/ai/AIRobotUnload.java | 2 +- .../robotics/ai/AIRobotUnloadFluids.java | 2 +- .../robotics/boards/BoardRobotCrafter.java | 4 +- .../boards/BoardRobotGenericBreakBlock.java | 2 +- .../robotics/boards/BoardRobotPump.java | 2 +- common/buildcraft/robotics/map/MapRegion.java | 4 +- common/buildcraft/robotics/map/MapWorld.java | 4 +- .../statements/ActionRobotFilter.java | 9 +- .../statements/ActionRobotFilterTool.java | 7 +- .../statements/ActionRobotGotoStation.java | 11 +- .../statements/ActionStationAcceptItems.java | 2 +- .../statements/ActionStationForbidRobot.java | 2 +- .../statements/ActionStationInputItems.java | 2 +- .../statements/ActionStationRequestItems.java | 2 +- .../statements/DockingStationIterator.java | 52 ----- .../statements/RobotsActionProvider.java | 11 +- .../statements/RobotsTriggerProvider.java | 7 +- .../statements/TriggerRobotInStation.java | 9 +- .../statements/TriggerRobotLinked.java | 9 +- .../statements/TriggerRobotSleep.java | 9 +- .../transport/render/PipeRendererWorld.java | 9 +- .../stripes/StripesHandlerBucket.java | 1 - .../stripes/StripesHandlerPipes.java | 2 - 61 files changed, 160 insertions(+), 405 deletions(-) delete mode 100755 common/buildcraft/robotics/DockingStation.java delete mode 100644 common/buildcraft/robotics/statements/DockingStationIterator.java diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 52f023d2..fb67f2ec 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -66,7 +66,6 @@ import buildcraft.core.BCCreativeTab; import buildcraft.core.BlockBuildTool; import buildcraft.core.BlockEngine; import buildcraft.core.BlockSpring; -import buildcraft.core.config.BuildCraftConfiguration; import buildcraft.core.CommandBuildCraft; import buildcraft.core.CompatHooks; import buildcraft.core.CoreGuiHandler; @@ -86,6 +85,7 @@ import buildcraft.core.TickHandlerCore; import buildcraft.core.TileEngineWood; import buildcraft.core.Version; import buildcraft.core.blueprints.SchematicRegistry; +import buildcraft.core.config.BuildCraftConfiguration; import buildcraft.core.config.ConfigManager; import buildcraft.core.lib.engines.ItemEngine; import buildcraft.core.lib.engines.TileEngineBase; diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 1263c99a..f09128e6 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -51,8 +51,8 @@ import buildcraft.core.BlockSpring; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; -import buildcraft.core.lib.block.BlockBuildCraftFluid; import buildcraft.core.config.ConfigManager; +import buildcraft.core.lib.block.BlockBuildCraftFluid; import buildcraft.core.lib.engines.TileEngineBase; import buildcraft.core.lib.engines.TileEngineBase.EnergyStage; import buildcraft.core.lib.network.ChannelHandler; diff --git a/common/buildcraft/BuildCraftRobotics.java b/common/buildcraft/BuildCraftRobotics.java index 1d7cd4ae..6a5b46e7 100644 --- a/common/buildcraft/BuildCraftRobotics.java +++ b/common/buildcraft/BuildCraftRobotics.java @@ -225,29 +225,37 @@ public class BuildCraftRobotics extends BuildCraftMod { RedstoneBoardRegistry.instance = new ImplRedstoneBoardRegistry(); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPickerNBT.instance, 20); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotCarrierNBT.instance, 10); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLumberjackNBT.instance, 10); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotHarvesterNBT.instance, 10); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotMinerNBT.instance, 10); + // Cheapest, dumbest robot types + // Those generally do very simple tasks + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotPickerNBT.instance, 8000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotCarrierNBT.instance, 8000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotFluidCarrierNBT.instance, 8000); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotFluidCarrierNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPlanterNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotFarmerNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLeaveCutterNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotButcherNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotShovelmanNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotCrafterNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotDeliveryNBT.instance, 5); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPumpNBT.instance, 5); + // More expensive robot types + // Those generally handle block mining/harvesting/placement. + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotLumberjackNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotHarvesterNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotMinerNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotPlanterNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotFarmerNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotLeaveCutterNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotButcherNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotShovelmanNBT.instance, 32000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotPumpNBT.instance, 32000); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotKnightNBT.instance, 1); - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBomberNBT.instance, 1); + // Even more expensive + // These handle complex multi-step operations. + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotCrafterNBT.instance, 128000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotDeliveryNBT.instance, 128000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotKnightNBT.instance, 128000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotBomberNBT.instance, 128000); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotStripesNBT.instance, 128000); + // Most expensive + // Overpowered galore! if (Loader.isModLoaded("BuildCraft|Builders")) { - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBuilderNBT.instance, 0.5F); + RedstoneBoardRegistry.instance.registerBoardType(BoardRobotBuilderNBT.instance, 512000); } - RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotStripesNBT.instance, 0.5F); StatementManager.registerActionProvider(new RobotsActionProvider()); StatementManager.registerTriggerProvider(new RobotsTriggerProvider()); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index e0709286..464fc1f4 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -42,7 +42,6 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.ShapedOreRecipe; diff --git a/common/buildcraft/core/blueprints/BptBuilderBase.java b/common/buildcraft/core/blueprints/BptBuilderBase.java index 733565b7..ad6e6eef 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBase.java +++ b/common/buildcraft/core/blueprints/BptBuilderBase.java @@ -9,7 +9,6 @@ package buildcraft.core.blueprints; import java.util.BitSet; - import org.apache.logging.log4j.Level; import net.minecraft.block.Block; import net.minecraft.init.Blocks; diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index 3a175564..1d6d8813 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -35,7 +35,6 @@ import buildcraft.api.blueprints.Schematic; import buildcraft.api.blueprints.SchematicBlock; import buildcraft.api.blueprints.SchematicEntity; import buildcraft.api.core.BCLog; -import buildcraft.api.core.BlockIndex; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IInvSlot; import buildcraft.api.core.StackKey; diff --git a/common/buildcraft/core/blueprints/BptBuilderTemplate.java b/common/buildcraft/core/blueprints/BptBuilderTemplate.java index a509be24..04a7daba 100644 --- a/common/buildcraft/core/blueprints/BptBuilderTemplate.java +++ b/common/buildcraft/core/blueprints/BptBuilderTemplate.java @@ -14,7 +14,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.blueprints.SchematicBlockBase; -import buildcraft.api.core.BlockIndex; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IInvSlot; import buildcraft.core.builders.BuildingSlot; diff --git a/common/buildcraft/core/config/ConfigManager.java b/common/buildcraft/core/config/ConfigManager.java index c38e2635..307505bc 100644 --- a/common/buildcraft/core/config/ConfigManager.java +++ b/common/buildcraft/core/config/ConfigManager.java @@ -1,7 +1,6 @@ package buildcraft.core.config; import java.util.ArrayList; -import java.util.List; import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -10,7 +9,6 @@ import cpw.mods.fml.client.IModGuiFactory; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement; import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; diff --git a/common/buildcraft/core/recipes/AssemblyRecipeManager.java b/common/buildcraft/core/recipes/AssemblyRecipeManager.java index ef9ce49c..cbe960c0 100644 --- a/common/buildcraft/core/recipes/AssemblyRecipeManager.java +++ b/common/buildcraft/core/recipes/AssemblyRecipeManager.java @@ -13,7 +13,6 @@ import java.util.HashMap; import java.util.Map; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import buildcraft.BuildCraftCore; import buildcraft.api.recipes.IAssemblyRecipeManager; import buildcraft.api.recipes.IFlexibleRecipe; diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index 00decf08..5798d45f 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -13,7 +13,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import net.minecraftforge.fluids.FluidStack; -import buildcraft.BuildCraftCore; import buildcraft.api.core.BCLog; import buildcraft.api.recipes.IFlexibleRecipe; import buildcraft.api.recipes.IRefineryRecipeManager; diff --git a/common/buildcraft/robotics/DockingStation.java b/common/buildcraft/robotics/DockingStation.java deleted file mode 100755 index 6a5ea919..00000000 --- a/common/buildcraft/robotics/DockingStation.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ -package buildcraft.robotics; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.core.BlockIndex; -import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; -import buildcraft.api.robots.RobotManager; -import buildcraft.api.transport.IPipeTile; -import buildcraft.transport.TileGenericPipe; - -public class DockingStation implements IDockingStation { - public ForgeDirection side; - public World world; - - private long robotTakingId = EntityRobotBase.NULL_ROBOT_ID; - private EntityRobotBase robotTaking; - - private boolean linkIsMain = false; - - private BlockIndex index; - private IPipeTile pipe; - - public DockingStation(BlockIndex iIndex, ForgeDirection iSide) { - index = iIndex; - side = iSide; - } - - public DockingStation(TileGenericPipe iPipe, ForgeDirection iSide) { - index = new BlockIndex(iPipe); - pipe = iPipe; - side = iSide; - world = iPipe.getWorld(); - } - - public DockingStation() { - } - - public boolean isMainStation() { - 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; - } - - @Override - public int x() { - return index.x; - } - - @Override - public int y() { - return index.y; - } - - @Override - public int z() { - return index.z; - } - - @Override - public ForgeDirection side() { - return side; - } - - @Override - public EntityRobotBase robotTaking() { - if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { - return null; - } else if (robotTaking == null) { - robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(robotTakingId); - } - - return robotTaking; - } - - public void invalidateRobotTakingEntity() { - robotTaking = null; - } - - @Override - public long linkedId() { - return robotTakingId; - } - - public boolean takeAsMain(EntityRobotBase robot) { - if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { - linkIsMain = true; - robotTaking = robot; - robotTakingId = robot.getRobotId(); - getPipe().scheduleRenderUpdate(); - ((RobotRegistry) RobotManager.registryProvider.getRegistry(world)).markDirty(); - ((EntityRobot) robot).setMainStation(this); - RobotManager.registryProvider.getRegistry(world).take(this, robot.getRobotId()); - - return true; - } else { - return robotTakingId == robot.getRobotId(); - } - } - - @Override - public boolean take(EntityRobotBase robot) { - if (robotTaking == null) { - linkIsMain = false; - robotTaking = robot; - robotTakingId = robot.getRobotId(); - getPipe().scheduleRenderUpdate(); - ((RobotRegistry) RobotManager.registryProvider.getRegistry(world)).markDirty(); - RobotManager.registryProvider.getRegistry(world).take(this, robot.getRobotId()); - - return true; - } else { - return robot.getRobotId() == robotTakingId; - } - } - - public void release(EntityRobotBase robot) { - if (robotTaking == robot && !linkIsMain) { - unsafeRelease(robot); - ((RobotRegistry) RobotManager.registryProvider.getRegistry(world)).markDirty(); - RobotManager.registryProvider.getRegistry(world).release(this, robot.getRobotId()); - } - } - - /** - * Same a release but doesn't clear the registry (presumably called from the - * registry). - */ - public void unsafeRelease(EntityRobotBase robot) { - if (robotTaking == robot) { - linkIsMain = false; - robotTaking = null; - robotTakingId = EntityRobotBase.NULL_ROBOT_ID; - getPipe().scheduleRenderUpdate(); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - NBTTagCompound indexNBT = new NBTTagCompound(); - index.writeTo(indexNBT); - nbt.setTag("index", indexNBT); - nbt.setByte("side", (byte) side.ordinal()); - nbt.setBoolean("isMain", linkIsMain); - nbt.setLong("robotId", robotTakingId); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - index = new BlockIndex (nbt.getCompoundTag("index")); - side = ForgeDirection.values()[nbt.getByte("side")]; - linkIsMain = nbt.getBoolean("isMain"); - robotTakingId = nbt.getLong("robotId"); - } - - @Override - public boolean isTaken() { - return robotTakingId != EntityRobotBase.NULL_ROBOT_ID; - } - - @Override - public long robotIdTaking() { - return robotTakingId; - } - - @Override - public BlockIndex index() { - return index; - } - - @Override - public String toString () { - return "{" + index.x + ", " + index.y + ", " + index.z + ", " + side + " :" + robotTakingId + "}"; - } - - public boolean linkIsDocked() { - if (isTaken()) { - return robotTaking().getDockingStation() == this; - } else { - return false; - } - } - - public boolean canRelease() { - return !isMainStation() && !linkIsDocked(); - } -} - diff --git a/common/buildcraft/robotics/EntityRobot.java b/common/buildcraft/robotics/EntityRobot.java index 371724aa..f66c6c08 100644 --- a/common/buildcraft/robotics/EntityRobot.java +++ b/common/buildcraft/robotics/EntityRobot.java @@ -47,8 +47,8 @@ import buildcraft.api.boards.RedstoneBoardRobotNBT; import buildcraft.api.core.BlockIndex; import buildcraft.api.core.IZone; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; import buildcraft.api.robots.RobotManager; import buildcraft.api.statements.StatementSlot; import buildcraft.api.tiles.IDebuggable; @@ -73,7 +73,7 @@ public class EntityRobot extends EntityRobotBase implements DefaultProps.TEXTURE_PATH_ROBOTS + "/robot_base.png"); public LaserData laser = new LaserData(); - public IDockingStation linkedDockingStation; + public DockingStation linkedDockingStation; public BlockIndex linkedDockingStationIndex; public ForgeDirection linkedDockingStationSide; @@ -578,7 +578,7 @@ public class EntityRobot extends EntityRobotBase implements } @Override - public void dock(IDockingStation station) { + public void dock(DockingStation station) { currentDockingStation = (DockingStation) station; setSteamDirection( @@ -608,11 +608,12 @@ public class EntityRobot extends EntityRobotBase implements return currentDockingStation; } - public void setMainStation(IDockingStation iStation) { - DockingStation station = (DockingStation) iStation; + @Override + public void setMainStation(DockingStation iStation) { + DockingStation station = iStation; if (linkedDockingStation != null && linkedDockingStation != station) { - ((DockingStation) linkedDockingStation).unsafeRelease(this); + linkedDockingStation.unsafeRelease(this); } linkedDockingStation = station; @@ -855,7 +856,7 @@ public class EntityRobot extends EntityRobotBase implements } @Override - public IDockingStation getLinkedStation() { + public DockingStation getLinkedStation() { return linkedDockingStation; } diff --git a/common/buildcraft/robotics/IStationFilter.java b/common/buildcraft/robotics/IStationFilter.java index 479171f2..1fff35f4 100755 --- a/common/buildcraft/robotics/IStationFilter.java +++ b/common/buildcraft/robotics/IStationFilter.java @@ -8,6 +8,8 @@ */ package buildcraft.robotics; +import buildcraft.api.robots.DockingStation; + public interface IStationFilter { boolean matches(DockingStation station); diff --git a/common/buildcraft/robotics/ItemRobot.java b/common/buildcraft/robotics/ItemRobot.java index 74f6b4f3..f9216827 100755 --- a/common/buildcraft/robotics/ItemRobot.java +++ b/common/buildcraft/robotics/ItemRobot.java @@ -27,6 +27,7 @@ import buildcraft.api.boards.RedstoneBoardNBT; import buildcraft.api.boards.RedstoneBoardRegistry; import buildcraft.api.boards.RedstoneBoardRobotNBT; import buildcraft.api.events.RobotPlacementEvent; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; import buildcraft.core.BCCreativeTab; import buildcraft.core.lib.items.ItemBuildCraft; diff --git a/common/buildcraft/robotics/RobotRegistry.java b/common/buildcraft/robotics/RobotRegistry.java index cb295be0..c21d0e20 100755 --- a/common/buildcraft/robotics/RobotRegistry.java +++ b/common/buildcraft/robotics/RobotRegistry.java @@ -22,15 +22,15 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.ChunkEvent; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; import buildcraft.api.robots.IRobotRegistry; import buildcraft.api.robots.ResourceId; public class RobotRegistry extends WorldSavedData implements IRobotRegistry { protected World world; - protected HashMap stations = new HashMap(); + protected HashMap stations = new HashMap(); private long nextRobotID = Long.MIN_VALUE; @@ -222,7 +222,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public synchronized IDockingStation getStation(int x, int y, int z, ForgeDirection side) { + public synchronized DockingStation getStation(int x, int y, int z, ForgeDirection side) { StationIndex index = new StationIndex(side, x, y, z); if (stations.containsKey(index)) { @@ -233,12 +233,12 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public synchronized Collection getStations() { + public synchronized Collection getStations() { return stations.values(); } @Override - public synchronized void registerStation(IDockingStation station) { + public synchronized void registerStation(DockingStation station) { markDirty(); StationIndex index = new StationIndex(station); @@ -251,7 +251,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public synchronized void removeStation(IDockingStation station) { + public synchronized void removeStation(DockingStation station) { markDirty(); StationIndex index = new StationIndex(station); @@ -268,7 +268,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public synchronized void take(IDockingStation station, long robotId) { + public synchronized void take(DockingStation station, long robotId) { if (!stationsTakenByRobot.containsKey(robotId)) { stationsTakenByRobot.put(robotId, new HashSet()); } @@ -277,7 +277,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { } @Override - public synchronized void release(IDockingStation station, long robotId) { + public synchronized void release(DockingStation station, long robotId) { if (stationsTakenByRobot.containsKey(robotId)) { stationsTakenByRobot.get(robotId).remove(new StationIndex(station)); } @@ -303,7 +303,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry { NBTTagList stationList = new NBTTagList(); - for (Map.Entry e : stations.entrySet()) { + for (Map.Entry e : stations.entrySet()) { NBTTagCompound cpt = new NBTTagCompound(); e.getValue().writeToNBT(cpt); stationList.appendTag(cpt); diff --git a/common/buildcraft/robotics/RobotRegistryProvider.java b/common/buildcraft/robotics/RobotRegistryProvider.java index 8abce6e7..c419745a 100644 --- a/common/buildcraft/robotics/RobotRegistryProvider.java +++ b/common/buildcraft/robotics/RobotRegistryProvider.java @@ -3,7 +3,7 @@ package buildcraft.robotics; import java.util.HashMap; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import buildcraft.api.robots.IDockingStation; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.IRobotRegistryProvider; public class RobotRegistryProvider implements IRobotRegistryProvider { @@ -23,7 +23,7 @@ public class RobotRegistryProvider implements IRobotRegistryProvider { newRegistry.world = world; - for (IDockingStation d : newRegistry.stations.values()) { + for (DockingStation d : newRegistry.stations.values()) { ((DockingStation) d).world = world; } diff --git a/common/buildcraft/robotics/RobotStationPluggable.java b/common/buildcraft/robotics/RobotStationPluggable.java index 364ff2d8..fb416879 100644 --- a/common/buildcraft/robotics/RobotStationPluggable.java +++ b/common/buildcraft/robotics/RobotStationPluggable.java @@ -12,7 +12,8 @@ import cofh.api.energy.IEnergyReceiver; import buildcraft.BuildCraftRobotics; import buildcraft.BuildCraftTransport; import buildcraft.api.core.render.ITextureStates; -import buildcraft.api.robots.IDockingStationPluggable; +import buildcraft.api.robots.DockingStation; +import buildcraft.api.robots.IDockingStationProvider; import buildcraft.api.robots.RobotManager; import buildcraft.api.tiles.IDebuggable; import buildcraft.api.transport.IPipe; @@ -25,7 +26,7 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.TileGenericPipe; public class RobotStationPluggable extends PipePluggable implements IPipePluggableItem, IEnergyReceiver, IDebuggable, - IDockingStationPluggable { + IDockingStationProvider { public class RobotStationPluggableRenderer implements IPipePluggableRenderer { private float zFightOffset = 1 / 4096.0F; diff --git a/common/buildcraft/robotics/RobotUtils.java b/common/buildcraft/robotics/RobotUtils.java index 4fa38ace..0fb23bf1 100644 --- a/common/buildcraft/robotics/RobotUtils.java +++ b/common/buildcraft/robotics/RobotUtils.java @@ -1,21 +1,35 @@ package buildcraft.robotics; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.robots.DockingStation; +import buildcraft.api.robots.IDockingStationProvider; import buildcraft.api.transport.IPipeTile; -/** - * Created by asie on 1/24/15. - */ public final class RobotUtils { private RobotUtils() { } - public static DockingStation getStation(IPipeTile tile, ForgeDirection d) { - if (tile.getPipePluggable(d) instanceof RobotStationPluggable) { - RobotStationPluggable pluggable = (RobotStationPluggable) tile.getPipePluggable(d); - return pluggable.getStation(); + public static List getStations(Object tile) { + ArrayList stations = new ArrayList(); + + if (tile instanceof IDockingStationProvider) { + stations.add(((IDockingStationProvider) tile).getStation()); } - return null; + + if (tile instanceof IPipeTile) { + IPipeTile pipeTile = (IPipeTile) tile; + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + if (pipeTile.getPipePluggable(d) instanceof IDockingStationProvider) { + IDockingStationProvider pluggable = (IDockingStationProvider) pipeTile.getPipePluggable(d); + stations.add(pluggable.getStation()); + } + } + } + + return stations; } } diff --git a/common/buildcraft/robotics/StationIndex.java b/common/buildcraft/robotics/StationIndex.java index 0314ea30..4b18a093 100755 --- a/common/buildcraft/robotics/StationIndex.java +++ b/common/buildcraft/robotics/StationIndex.java @@ -11,7 +11,7 @@ package buildcraft.robotics; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.BlockIndex; -import buildcraft.api.robots.IDockingStation; +import buildcraft.api.robots.DockingStation; public class StationIndex { @@ -26,7 +26,7 @@ public class StationIndex { index = new BlockIndex(x, y, z); } - public StationIndex(IDockingStation station) { + public StationIndex(DockingStation station) { side = station.side(); index = station.index(); } diff --git a/common/buildcraft/robotics/ai/AIRobotCraftAssemblyTable.java b/common/buildcraft/robotics/ai/AIRobotCraftAssemblyTable.java index 2215d6b6..587b8bfa 100755 --- a/common/buildcraft/robotics/ai/AIRobotCraftAssemblyTable.java +++ b/common/buildcraft/robotics/ai/AIRobotCraftAssemblyTable.java @@ -17,6 +17,7 @@ import buildcraft.api.core.BlockIndex; import buildcraft.api.core.IInvSlot; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.ResourceIdBlock; import buildcraft.api.robots.RobotManager; @@ -28,7 +29,6 @@ import buildcraft.core.lib.inventory.StackHelper; import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.ArrayStackFilter; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationAllowCraft; diff --git a/common/buildcraft/robotics/ai/AIRobotCraftFurnace.java b/common/buildcraft/robotics/ai/AIRobotCraftFurnace.java index 12b5a46e..9b0490a2 100755 --- a/common/buildcraft/robotics/ai/AIRobotCraftFurnace.java +++ b/common/buildcraft/robotics/ai/AIRobotCraftFurnace.java @@ -16,6 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection; 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.ResourceIdBlock; import buildcraft.core.lib.inventory.ITransactor; @@ -24,7 +25,6 @@ import buildcraft.core.lib.inventory.StackHelper; import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.ArrayStackFilter; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationAllowCraft; diff --git a/common/buildcraft/robotics/ai/AIRobotCraftWorkbench.java b/common/buildcraft/robotics/ai/AIRobotCraftWorkbench.java index 36aec60a..14cc4607 100755 --- a/common/buildcraft/robotics/ai/AIRobotCraftWorkbench.java +++ b/common/buildcraft/robotics/ai/AIRobotCraftWorkbench.java @@ -24,6 +24,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import buildcraft.api.core.IInvSlot; 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.InventoryCopy; @@ -32,7 +33,6 @@ import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.ArrayStackFilter; import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationAllowCraft; diff --git a/common/buildcraft/robotics/ai/AIRobotDeliverRequested.java b/common/buildcraft/robotics/ai/AIRobotDeliverRequested.java index 086f9e60..8a3fee1c 100755 --- a/common/buildcraft/robotics/ai/AIRobotDeliverRequested.java +++ b/common/buildcraft/robotics/ai/AIRobotDeliverRequested.java @@ -12,6 +12,7 @@ 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; @@ -19,7 +20,6 @@ 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.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionStationRequestItemsMachine; import buildcraft.transport.gates.ActionIterator; diff --git a/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java b/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java index 530b30fd..3bd4a2ce 100755 --- a/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java +++ b/common/buildcraft/robotics/ai/AIRobotFetchAndEquipItemStack.java @@ -13,12 +13,12 @@ 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; import buildcraft.core.lib.inventory.ITransactor; import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.AggregateFilter; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.statements.ActionRobotFilterTool; public class AIRobotFetchAndEquipItemStack extends AIRobot { diff --git a/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java b/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java index 38b65fd1..eba32af2 100755 --- a/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java +++ b/common/buildcraft/robotics/ai/AIRobotGoAndLinkToDock.java @@ -9,8 +9,8 @@ package buildcraft.robotics.ai; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.robotics.DockingStation; public class AIRobotGoAndLinkToDock extends AIRobot { @@ -33,9 +33,9 @@ public class AIRobotGoAndLinkToDock extends AIRobot { } else { if (station.takeAsMain(robot)) { startDelegateAI(new AIRobotGotoBlock(robot, - station.x() + station.side.offsetX * 2, - station.y() + station.side.offsetY * 2, - station.z() + station.side.offsetZ * 2)); + station.x() + station.side().offsetX * 2, + station.y() + station.side().offsetY * 2, + station.z() + station.side().offsetZ * 2)); } else { terminate(); } @@ -46,9 +46,9 @@ public class AIRobotGoAndLinkToDock extends AIRobot { public void delegateAIEnded(AIRobot ai) { if (ai instanceof AIRobotGotoBlock) { startDelegateAI(new AIRobotStraightMoveTo(robot, - station.x() + 0.5F + station.side.offsetX * 0.5F, - station.y() + 0.5F + station.side.offsetY * 0.5F, - station.z() + 0.5F + station.side.offsetZ * 0.5F)); + station.x() + 0.5F + station.side().offsetX * 0.5F, + station.y() + 0.5F + station.side().offsetY * 0.5F, + station.z() + 0.5F + station.side().offsetZ * 0.5F)); } else { robot.dock(station); station = null; diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStation.java b/common/buildcraft/robotics/ai/AIRobotGotoStation.java index 4ded36b3..819ab24b 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStation.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStation.java @@ -12,9 +12,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.BlockIndex; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; -import buildcraft.robotics.DockingStation; public class AIRobotGotoStation extends AIRobot { @@ -26,7 +25,7 @@ public class AIRobotGotoStation extends AIRobot { super(iRobot); } - public AIRobotGotoStation(EntityRobotBase iRobot, IDockingStation station) { + public AIRobotGotoStation(EntityRobotBase iRobot, DockingStation station) { super(iRobot); stationIndex = station.index(); diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStationAndUnload.java b/common/buildcraft/robotics/ai/AIRobotGotoStationAndUnload.java index abed801f..fdb8c34a 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStationAndUnload.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStationAndUnload.java @@ -10,8 +10,8 @@ package buildcraft.robotics.ai; import buildcraft.api.core.IZone; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.robotics.DockingStation; public class AIRobotGotoStationAndUnload extends AIRobot { diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStationToLoad.java b/common/buildcraft/robotics/ai/AIRobotGotoStationToLoad.java index 2d89d549..08cc578a 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStationToLoad.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStationToLoad.java @@ -13,11 +13,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; 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.ITransactor; import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationProvideItems; diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStationToLoadFluids.java b/common/buildcraft/robotics/ai/AIRobotGotoStationToLoadFluids.java index 6390691c..143d95d8 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStationToLoadFluids.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStationToLoadFluids.java @@ -14,9 +14,9 @@ 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.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationProvideFluids; diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStationToUnload.java b/common/buildcraft/robotics/ai/AIRobotGotoStationToUnload.java index 84108041..dcd818f5 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStationToUnload.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStationToUnload.java @@ -12,11 +12,11 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.IInvSlot; import buildcraft.api.core.IZone; 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.DockingStation; import buildcraft.robotics.EntityRobot; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionStationInputItems; diff --git a/common/buildcraft/robotics/ai/AIRobotGotoStationToUnloadFluids.java b/common/buildcraft/robotics/ai/AIRobotGotoStationToUnloadFluids.java index 34cebc04..cefddbb2 100755 --- a/common/buildcraft/robotics/ai/AIRobotGotoStationToUnloadFluids.java +++ b/common/buildcraft/robotics/ai/AIRobotGotoStationToUnloadFluids.java @@ -12,9 +12,9 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; 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.SimpleFluidFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationAcceptFluids; diff --git a/common/buildcraft/robotics/ai/AIRobotLoad.java b/common/buildcraft/robotics/ai/AIRobotLoad.java index db16bf4e..a0626050 100755 --- a/common/buildcraft/robotics/ai/AIRobotLoad.java +++ b/common/buildcraft/robotics/ai/AIRobotLoad.java @@ -14,12 +14,12 @@ import net.minecraft.tileentity.TileEntity; 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.core.lib.inventory.ITransactor; import buildcraft.core.lib.inventory.InventoryIterator; import buildcraft.core.lib.inventory.Transactor; import buildcraft.core.lib.inventory.filters.IStackFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationProvideItems; diff --git a/common/buildcraft/robotics/ai/AIRobotLoadFluids.java b/common/buildcraft/robotics/ai/AIRobotLoadFluids.java index 7047b071..582fe669 100755 --- a/common/buildcraft/robotics/ai/AIRobotLoadFluids.java +++ b/common/buildcraft/robotics/ai/AIRobotLoadFluids.java @@ -14,9 +14,9 @@ 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.IFluidFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationProvideFluids; diff --git a/common/buildcraft/robotics/ai/AIRobotRecharge.java b/common/buildcraft/robotics/ai/AIRobotRecharge.java index c734dd39..34e9e82c 100755 --- a/common/buildcraft/robotics/ai/AIRobotRecharge.java +++ b/common/buildcraft/robotics/ai/AIRobotRecharge.java @@ -9,9 +9,9 @@ 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.DockingStation; import buildcraft.robotics.IStationFilter; public class AIRobotRecharge extends AIRobot { diff --git a/common/buildcraft/robotics/ai/AIRobotSearchAndGotoStation.java b/common/buildcraft/robotics/ai/AIRobotSearchAndGotoStation.java index d927ffd2..64fe5e83 100755 --- a/common/buildcraft/robotics/ai/AIRobotSearchAndGotoStation.java +++ b/common/buildcraft/robotics/ai/AIRobotSearchAndGotoStation.java @@ -10,8 +10,8 @@ package buildcraft.robotics.ai; import buildcraft.api.core.IZone; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; public class AIRobotSearchAndGotoStation extends AIRobot { diff --git a/common/buildcraft/robotics/ai/AIRobotSearchStackRequest.java b/common/buildcraft/robotics/ai/AIRobotSearchStackRequest.java index 5c653727..2e406815 100755 --- a/common/buildcraft/robotics/ai/AIRobotSearchStackRequest.java +++ b/common/buildcraft/robotics/ai/AIRobotSearchStackRequest.java @@ -13,6 +13,7 @@ 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; import buildcraft.api.robots.IRequestProvider; import buildcraft.api.robots.StackRequest; @@ -22,7 +23,6 @@ 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.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationRequestItems; diff --git a/common/buildcraft/robotics/ai/AIRobotSearchStation.java b/common/buildcraft/robotics/ai/AIRobotSearchStation.java index 53d56c7c..078e07be 100755 --- a/common/buildcraft/robotics/ai/AIRobotSearchStation.java +++ b/common/buildcraft/robotics/ai/AIRobotSearchStation.java @@ -10,9 +10,8 @@ package buildcraft.robotics.ai; import buildcraft.api.core.IZone; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.IStationFilter; import buildcraft.robotics.statements.ActionStationForbidRobot; @@ -45,7 +44,7 @@ public class AIRobotSearchStation extends AIRobot { double potentialStationDistance = Float.MAX_VALUE; DockingStation potentialStation = null; - for (IDockingStation d : robot.getRegistry().getStations()) { + for (DockingStation d : robot.getRegistry().getStations()) { DockingStation station = (DockingStation) d; if (d.isTaken() && d.robotIdTaking() != robot.getRobotId()) { diff --git a/common/buildcraft/robotics/ai/AIRobotSleep.java b/common/buildcraft/robotics/ai/AIRobotSleep.java index b1a25d4f..f21fd3b3 100755 --- a/common/buildcraft/robotics/ai/AIRobotSleep.java +++ b/common/buildcraft/robotics/ai/AIRobotSleep.java @@ -9,9 +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.DockingStation; import buildcraft.robotics.statements.ActionRobotWakeUp; import buildcraft.transport.gates.ActionIterator; diff --git a/common/buildcraft/robotics/ai/AIRobotUnload.java b/common/buildcraft/robotics/ai/AIRobotUnload.java index 79ed9fdf..18fa8ef0 100755 --- a/common/buildcraft/robotics/ai/AIRobotUnload.java +++ b/common/buildcraft/robotics/ai/AIRobotUnload.java @@ -11,11 +11,11 @@ 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.DockingStation; import buildcraft.robotics.EntityRobot; import buildcraft.robotics.statements.ActionStationInputItems; import buildcraft.transport.gates.ActionIterator; diff --git a/common/buildcraft/robotics/ai/AIRobotUnloadFluids.java b/common/buildcraft/robotics/ai/AIRobotUnloadFluids.java index d4acbfc8..88cfef80 100755 --- a/common/buildcraft/robotics/ai/AIRobotUnloadFluids.java +++ b/common/buildcraft/robotics/ai/AIRobotUnloadFluids.java @@ -12,9 +12,9 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; 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.DockingStation; import buildcraft.robotics.statements.ActionRobotFilter; import buildcraft.robotics.statements.ActionStationAcceptFluids; import buildcraft.transport.Pipe; diff --git a/common/buildcraft/robotics/boards/BoardRobotCrafter.java b/common/buildcraft/robotics/boards/BoardRobotCrafter.java index 26893372..4e10ccf6 100755 --- a/common/buildcraft/robotics/boards/BoardRobotCrafter.java +++ b/common/buildcraft/robotics/boards/BoardRobotCrafter.java @@ -24,8 +24,8 @@ import buildcraft.api.boards.RedstoneBoardRobotNBT; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.recipes.IFlexibleRecipe; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; -import buildcraft.api.robots.IDockingStation; import buildcraft.api.robots.StackRequest; import buildcraft.core.lib.inventory.StackHelper; import buildcraft.core.recipes.AssemblyRecipeManager; @@ -45,7 +45,7 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { private ItemStack order; private ArrayList craftingBlacklist = new ArrayList(); - private HashSet reservedStations = new HashSet(); + private HashSet reservedStations = new HashSet(); private StackRequest currentRequest = null; public BoardRobotCrafter(EntityRobotBase iRobot) { diff --git a/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java b/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java index 801d995b..82b33b16 100644 --- a/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java +++ b/common/buildcraft/robotics/boards/BoardRobotGenericBreakBlock.java @@ -17,6 +17,7 @@ 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; @@ -24,7 +25,6 @@ import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.api.statements.StatementSlot; import buildcraft.core.lib.inventory.filters.IStackFilter; import buildcraft.core.lib.utils.IBlockFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.ai.AIRobotBreak; import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack; import buildcraft.robotics.ai.AIRobotGotoBlock; diff --git a/common/buildcraft/robotics/boards/BoardRobotPump.java b/common/buildcraft/robotics/boards/BoardRobotPump.java index 3f05cf3c..7e73c745 100644 --- a/common/buildcraft/robotics/boards/BoardRobotPump.java +++ b/common/buildcraft/robotics/boards/BoardRobotPump.java @@ -23,13 +23,13 @@ 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.utils.IBlockFilter; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.ai.AIRobotGotoBlock; import buildcraft.robotics.ai.AIRobotGotoSleep; import buildcraft.robotics.ai.AIRobotGotoStationAndUnloadFluids; diff --git a/common/buildcraft/robotics/map/MapRegion.java b/common/buildcraft/robotics/map/MapRegion.java index d31c2cc5..66dc6ea6 100644 --- a/common/buildcraft/robotics/map/MapRegion.java +++ b/common/buildcraft/robotics/map/MapRegion.java @@ -1,10 +1,10 @@ package buildcraft.robotics.map; +import gnu.trove.map.hash.TIntObjectHashMap; + import net.minecraft.nbt.NBTTagCompound; import buildcraft.api.core.INBTStoreable; -import gnu.trove.map.hash.TIntObjectHashMap; - public class MapRegion implements INBTStoreable { private final TIntObjectHashMap chunks = new TIntObjectHashMap(); private final int x, z; diff --git a/common/buildcraft/robotics/map/MapWorld.java b/common/buildcraft/robotics/map/MapWorld.java index 321112e7..d95b20d8 100644 --- a/common/buildcraft/robotics/map/MapWorld.java +++ b/common/buildcraft/robotics/map/MapWorld.java @@ -1,5 +1,7 @@ package buildcraft.robotics.map; +import gnu.trove.map.hash.TLongObjectHashMap; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -16,8 +18,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import buildcraft.core.lib.utils.NBTUtils; -import gnu.trove.map.hash.TLongObjectHashMap; - public class MapWorld { private final World world; private final TLongObjectHashMap regionMap; diff --git a/common/buildcraft/robotics/statements/ActionRobotFilter.java b/common/buildcraft/robotics/statements/ActionRobotFilter.java index 3709641d..de8cda9a 100755 --- a/common/buildcraft/robotics/statements/ActionRobotFilter.java +++ b/common/buildcraft/robotics/statements/ActionRobotFilter.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.robots.IDockingStation; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; @@ -30,7 +30,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.robotics.DockingStation; import buildcraft.transport.gates.ActionIterator; public class ActionRobotFilter extends BCStatement implements IActionInternal { @@ -64,7 +63,7 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal { return new StatementParameterItemStack(); } - public static Collection getGateFilterStacks(IDockingStation station) { + public static Collection getGateFilterStacks(DockingStation station) { ArrayList result = new ArrayList(); for (StatementSlot slot : new ActionIterator(((DockingStation) station).getPipe().getPipe())) { @@ -85,7 +84,7 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal { return result; } - public static IStackFilter getGateFilter(IDockingStation station) { + public static IStackFilter getGateFilter(DockingStation station) { Collection stacks = getGateFilterStacks(station); if (stacks.size() == 0) { @@ -95,7 +94,7 @@ public class ActionRobotFilter extends BCStatement implements IActionInternal { } } - public static IFluidFilter getGateFluidFilter(IDockingStation station) { + public static IFluidFilter getGateFluidFilter(DockingStation station) { Collection stacks = getGateFilterStacks(station); if (stacks.size() == 0) { diff --git a/common/buildcraft/robotics/statements/ActionRobotFilterTool.java b/common/buildcraft/robotics/statements/ActionRobotFilterTool.java index e784e1db..cb224b8d 100644 --- a/common/buildcraft/robotics/statements/ActionRobotFilterTool.java +++ b/common/buildcraft/robotics/statements/ActionRobotFilterTool.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.Collection; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; -import buildcraft.api.robots.IDockingStation; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; @@ -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.robotics.DockingStation; import buildcraft.transport.gates.ActionIterator; public class ActionRobotFilterTool extends BCStatement implements IActionInternal { @@ -57,7 +56,7 @@ public class ActionRobotFilterTool extends BCStatement implements IActionInterna return new StatementParameterItemStack(); } - public static Collection getGateFilterStacks(IDockingStation station) { + public static Collection getGateFilterStacks(DockingStation station) { ArrayList result = new ArrayList(); for (StatementSlot slot : new ActionIterator(((DockingStation) station).getPipe().getPipe())) { @@ -78,7 +77,7 @@ public class ActionRobotFilterTool extends BCStatement implements IActionInterna return result; } - public static IStackFilter getGateFilter(IDockingStation station) { + public static IStackFilter getGateFilter(DockingStation station) { Collection stacks = getGateFilterStacks(station); if (stacks.size() == 0) { diff --git a/common/buildcraft/robotics/statements/ActionRobotGotoStation.java b/common/buildcraft/robotics/statements/ActionRobotGotoStation.java index dc3489e8..3ae83ab0 100644 --- a/common/buildcraft/robotics/statements/ActionRobotGotoStation.java +++ b/common/buildcraft/robotics/statements/ActionRobotGotoStation.java @@ -8,12 +8,16 @@ */ package buildcraft.robotics.statements; +import javax.print.Doc; + +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.BlockIndex; import buildcraft.api.items.IMapLocation; import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.RobotManager; import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IStatementContainer; @@ -22,7 +26,6 @@ import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.api.transport.IPipeTile; import buildcraft.core.lib.utils.StringUtils; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; import buildcraft.robotics.RobotRegistry; import buildcraft.robotics.RobotUtils; @@ -53,10 +56,10 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern IPipeTile tile = (IPipeTile) container.getTile(); RobotRegistry registry = (RobotRegistry) RobotManager.registryProvider.getRegistry(tile.getWorld()); - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - DockingStation station = RobotUtils.getStation(tile, d); + List stations = RobotUtils.getStations(tile); - if (station != null && station.robotTaking() != null) { + for (DockingStation station : stations) { + if (station.robotTaking() != null) { EntityRobot robot = (EntityRobot) station.robotTaking(); AIRobot ai = robot.getOverridingAI(); diff --git a/common/buildcraft/robotics/statements/ActionStationAcceptItems.java b/common/buildcraft/robotics/statements/ActionStationAcceptItems.java index 32504ec3..0597905d 100755 --- a/common/buildcraft/robotics/statements/ActionStationAcceptItems.java +++ b/common/buildcraft/robotics/statements/ActionStationAcceptItems.java @@ -10,12 +10,12 @@ package buildcraft.robotics.statements; import net.minecraft.client.renderer.texture.IIconRegister; 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.core.lib.utils.StringUtils; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; import buildcraft.transport.Pipe; import buildcraft.transport.PipeTransportItems; diff --git a/common/buildcraft/robotics/statements/ActionStationForbidRobot.java b/common/buildcraft/robotics/statements/ActionStationForbidRobot.java index 3401e954..b690b131 100755 --- a/common/buildcraft/robotics/statements/ActionStationForbidRobot.java +++ b/common/buildcraft/robotics/statements/ActionStationForbidRobot.java @@ -10,6 +10,7 @@ package buildcraft.robotics.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; +import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IStatementContainer; @@ -18,7 +19,6 @@ import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.api.statements.StatementSlot; import buildcraft.core.lib.utils.StringUtils; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.ItemRobot; import buildcraft.transport.gates.ActionIterator; diff --git a/common/buildcraft/robotics/statements/ActionStationInputItems.java b/common/buildcraft/robotics/statements/ActionStationInputItems.java index df4ae89b..b5cad1c0 100755 --- a/common/buildcraft/robotics/statements/ActionStationInputItems.java +++ b/common/buildcraft/robotics/statements/ActionStationInputItems.java @@ -9,13 +9,13 @@ package buildcraft.robotics.statements; import buildcraft.api.core.IInvSlot; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.StatementSlot; import buildcraft.core.lib.inventory.filters.StatementParameterStackFilter; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; public abstract class ActionStationInputItems extends BCStatement implements IActionInternal { diff --git a/common/buildcraft/robotics/statements/ActionStationRequestItems.java b/common/buildcraft/robotics/statements/ActionStationRequestItems.java index 7013f988..c97c0b7b 100755 --- a/common/buildcraft/robotics/statements/ActionStationRequestItems.java +++ b/common/buildcraft/robotics/statements/ActionStationRequestItems.java @@ -10,11 +10,11 @@ package buildcraft.robotics.statements; import net.minecraft.client.renderer.texture.IIconRegister; 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.core.lib.utils.StringUtils; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; import buildcraft.transport.Pipe; import buildcraft.transport.PipeTransportItems; diff --git a/common/buildcraft/robotics/statements/DockingStationIterator.java b/common/buildcraft/robotics/statements/DockingStationIterator.java deleted file mode 100644 index ba518516..00000000 --- a/common/buildcraft/robotics/statements/DockingStationIterator.java +++ /dev/null @@ -1,52 +0,0 @@ -package buildcraft.robotics.statements; - -import java.util.Iterator; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.transport.IPipeTile; -import buildcraft.robotics.DockingStation; -import buildcraft.robotics.RobotUtils; - -public class DockingStationIterator implements Iterator { - private final IPipeTile tile; - private DockingStation next; - private int side = -1; - - public DockingStationIterator(IStatementContainer container) { - tile = container.getTile() instanceof IPipeTile ? (IPipeTile) container.getTile() : null; - findNext(); - } - - private void findNext() { - while (side < 6) { - side++; - DockingStation station = RobotUtils.getStation(tile, ForgeDirection.getOrientation(side)); - - if (station != null) { - next = station; - return; - } - } - next = null; - } - - @Override - public boolean hasNext() { - return tile != null && next != null; - } - - @Override - public DockingStation next() { - if (hasNext()) { - DockingStation output = next; - findNext(); - return output; - } else { - return null; - } - } - - @Override - public void remove() { - } -} diff --git a/common/buildcraft/robotics/statements/RobotsActionProvider.java b/common/buildcraft/robotics/statements/RobotsActionProvider.java index c51ac878..1daf8dcd 100755 --- a/common/buildcraft/robotics/statements/RobotsActionProvider.java +++ b/common/buildcraft/robotics/statements/RobotsActionProvider.java @@ -11,6 +11,7 @@ package buildcraft.robotics.statements; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockWorkbench; import net.minecraft.inventory.IInventory; @@ -19,13 +20,13 @@ 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.robotics.DockingStation; import buildcraft.robotics.RobotUtils; import buildcraft.silicon.TileAssemblyTable; import buildcraft.transport.PipeTransportFluids; @@ -43,13 +44,7 @@ public class RobotsActionProvider implements IActionProvider { return result; } - ArrayList stations = new ArrayList(); - - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if (RobotUtils.getStation((IPipeTile) tile, dir) != null) { - stations.add(RobotUtils.getStation((IPipeTile) tile, dir)); - } - } + List stations = RobotUtils.getStations(tile); if (stations.size() == 0) { return result; diff --git a/common/buildcraft/robotics/statements/RobotsTriggerProvider.java b/common/buildcraft/robotics/statements/RobotsTriggerProvider.java index 42404e65..6923b624 100755 --- a/common/buildcraft/robotics/statements/RobotsTriggerProvider.java +++ b/common/buildcraft/robotics/statements/RobotsTriggerProvider.java @@ -10,21 +10,24 @@ package buildcraft.robotics.statements; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftRobotics; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerProvider; +import buildcraft.robotics.RobotUtils; public class RobotsTriggerProvider implements ITriggerProvider { @Override public Collection getInternalTriggers(IStatementContainer container) { LinkedList result = new LinkedList(); - DockingStationIterator iterator = new DockingStationIterator(container); + List stations = RobotUtils.getStations(container.getTile()); - if (iterator.hasNext()) { + if (stations.size() > 0) { result.add(BuildCraftRobotics.triggerRobotSleep); result.add(BuildCraftRobotics.triggerRobotInStation); result.add(BuildCraftRobotics.triggerRobotLinked); diff --git a/common/buildcraft/robotics/statements/TriggerRobotInStation.java b/common/buildcraft/robotics/statements/TriggerRobotInStation.java index ea169a9f..a28ced9c 100755 --- a/common/buildcraft/robotics/statements/TriggerRobotInStation.java +++ b/common/buildcraft/robotics/statements/TriggerRobotInStation.java @@ -8,14 +8,16 @@ */ package buildcraft.robotics.statements; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.lib.utils.StringUtils; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; +import buildcraft.robotics.RobotUtils; public class TriggerRobotInStation extends BCStatement implements ITriggerInternal { @@ -35,10 +37,9 @@ public class TriggerRobotInStation extends BCStatement implements ITriggerIntern @Override public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { - DockingStationIterator iterator = new DockingStationIterator(container); + List stations = RobotUtils.getStations(container.getTile()); - while (iterator.hasNext()) { - DockingStation station = iterator.next(); + for (DockingStation station : stations) { if (station.robotTaking() != null) { EntityRobot robot = (EntityRobot) station.robotTaking(); diff --git a/common/buildcraft/robotics/statements/TriggerRobotLinked.java b/common/buildcraft/robotics/statements/TriggerRobotLinked.java index 243f17d3..b9537b44 100755 --- a/common/buildcraft/robotics/statements/TriggerRobotLinked.java +++ b/common/buildcraft/robotics/statements/TriggerRobotLinked.java @@ -8,13 +8,15 @@ */ package buildcraft.robotics.statements; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.lib.utils.StringUtils; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; +import buildcraft.robotics.RobotUtils; public class TriggerRobotLinked extends BCStatement implements ITriggerInternal { private final boolean reserved; @@ -36,10 +38,9 @@ public class TriggerRobotLinked extends BCStatement implements ITriggerInternal @Override public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { - DockingStationIterator iterator = new DockingStationIterator(container); + List stations = RobotUtils.getStations(container.getTile()); - while (iterator.hasNext()) { - DockingStation station = iterator.next(); + for (DockingStation station: stations) { if (station.isTaken() && (reserved || station.isMainStation())) { return true; } diff --git a/common/buildcraft/robotics/statements/TriggerRobotSleep.java b/common/buildcraft/robotics/statements/TriggerRobotSleep.java index 1347621b..f2dce1b0 100755 --- a/common/buildcraft/robotics/statements/TriggerRobotSleep.java +++ b/common/buildcraft/robotics/statements/TriggerRobotSleep.java @@ -8,14 +8,16 @@ */ package buildcraft.robotics.statements; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; +import buildcraft.api.robots.DockingStation; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.lib.utils.StringUtils; import buildcraft.core.statements.BCStatement; -import buildcraft.robotics.DockingStation; import buildcraft.robotics.EntityRobot; +import buildcraft.robotics.RobotUtils; public class TriggerRobotSleep extends BCStatement implements ITriggerInternal { @@ -35,10 +37,9 @@ public class TriggerRobotSleep extends BCStatement implements ITriggerInternal { @Override public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { - DockingStationIterator iterator = new DockingStationIterator(container); + List stations = RobotUtils.getStations(container.getTile()); - while (iterator.hasNext()) { - DockingStation station = iterator.next(); + for (DockingStation station : stations) { if (station.robotTaking() != null) { EntityRobot robot = (EntityRobot) station.robotTaking(); diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 84ab735d..e140d6ff 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -8,19 +8,15 @@ */ package buildcraft.transport.render; -import buildcraft.transport.*; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.render.ITextureStates; @@ -29,6 +25,11 @@ import buildcraft.api.transport.pluggable.PipePluggable; import buildcraft.core.CoreConstants; import buildcraft.core.lib.render.FakeBlock; import buildcraft.core.lib.utils.ColorUtils; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeRenderState; +import buildcraft.transport.TileGenericPipe; +import buildcraft.transport.TransportProxy; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { diff --git a/common/buildcraft/transport/stripes/StripesHandlerBucket.java b/common/buildcraft/transport/stripes/StripesHandlerBucket.java index 0af7d431..20ccb041 100644 --- a/common/buildcraft/transport/stripes/StripesHandlerBucket.java +++ b/common/buildcraft/transport/stripes/StripesHandlerBucket.java @@ -10,7 +10,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; - import buildcraft.api.transport.IStripesActivator; import buildcraft.api.transport.IStripesHandler; import buildcraft.core.lib.utils.BlockUtils; diff --git a/common/buildcraft/transport/stripes/StripesHandlerPipes.java b/common/buildcraft/transport/stripes/StripesHandlerPipes.java index a3709024..e132ece1 100644 --- a/common/buildcraft/transport/stripes/StripesHandlerPipes.java +++ b/common/buildcraft/transport/stripes/StripesHandlerPipes.java @@ -10,7 +10,6 @@ package buildcraft.transport.stripes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.ForgeDirection; @@ -23,7 +22,6 @@ import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.ItemPipe; import buildcraft.transport.Pipe; import buildcraft.transport.PipeTransportItems; -import buildcraft.transport.TileGenericPipe; public class StripesHandlerPipes implements IStripesHandler {