diff --git a/common/buildcraft/robotics/ai/AIRobotMain.java b/common/buildcraft/robotics/ai/AIRobotMain.java index 85641cc4..eea4118b 100755 --- a/common/buildcraft/robotics/ai/AIRobotMain.java +++ b/common/buildcraft/robotics/ai/AIRobotMain.java @@ -14,9 +14,11 @@ import buildcraft.api.robots.EntityRobotBase; public class AIRobotMain extends AIRobot { private AIRobot overridingAI; + private int rechargeCooldown; public AIRobotMain(EntityRobotBase iRobot) { super(iRobot); + rechargeCooldown = 0; } @Override @@ -32,7 +34,9 @@ public class AIRobotMain extends AIRobot { } } else if (robot.getEnergy() < EntityRobotBase.SAFETY_ENERGY) { if (!(ai instanceof AIRobotRecharge) && !(ai instanceof AIRobotShutdown)) { - startDelegateAI(new AIRobotRecharge(robot)); + if (rechargeCooldown-- == 0) { + startDelegateAI(new AIRobotRecharge(robot)); + } } } else if (overridingAI != null && ai != overridingAI) { startDelegateAI(overridingAI); @@ -50,6 +54,11 @@ public class AIRobotMain extends AIRobot { @Override public void delegateAIEnded(AIRobot ai) { + if (ai instanceof AIRobotRecharge) { + if (!ai.success()) { + rechargeCooldown = 120; + } + } if (ai == overridingAI) { overridingAI = null; } diff --git a/common/buildcraft/robotics/ai/AIRobotRecharge.java b/common/buildcraft/robotics/ai/AIRobotRecharge.java index af591be0..e9c7998b 100755 --- a/common/buildcraft/robotics/ai/AIRobotRecharge.java +++ b/common/buildcraft/robotics/ai/AIRobotRecharge.java @@ -16,8 +16,11 @@ import buildcraft.robotics.IStationFilter; public class AIRobotRecharge extends AIRobot { + private boolean success; + public AIRobotRecharge(EntityRobotBase iRobot) { super(iRobot); + success = false; } @Override @@ -53,7 +56,14 @@ public class AIRobotRecharge extends AIRobot { if (!ai.success()) { setSuccess(false); terminate(); + } else { + success = true; } } } + + @Override + public boolean success() { + return success; + } }