From 5ab94d7ecb8d90fc8a56787f8263eb0c2593a517 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Mon, 27 Apr 2015 22:44:28 +0200 Subject: [PATCH] fix invalid board IDs, add some startup time for all robot/world data to initialize --- common/buildcraft/robotics/EntityRobot.java | 20 ++++++++++++++----- .../buildcraft/robotics/ai/AIRobotMain.java | 2 +- .../robotics/boards/BCBoardNBT.java | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/robotics/EntityRobot.java b/common/buildcraft/robotics/EntityRobot.java index 3c2f6ef7..3cf62d83 100644 --- a/common/buildcraft/robotics/EntityRobot.java +++ b/common/buildcraft/robotics/EntityRobot.java @@ -100,6 +100,7 @@ public class EntityRobot extends EntityRobotBase implements private boolean needsUpdate = false; private ItemStack[] inv = new ItemStack[4]; private FluidStack tank; + private int startupCooldown = 100; private int maxFluid = FluidContainerRegistry.BUCKET_VOLUME * 4; private ResourceLocation texture; @@ -262,6 +263,10 @@ public class EntityRobot extends EntityRobotBase implements ticksCharging--; } + if (startupCooldown > 0) { + startupCooldown--; + } + if (!worldObj.isRemote) { // The client-side sleep indicator should also display if the robot is charging. // To not break gates and other things checking for sleep, this is done here. @@ -298,7 +303,7 @@ public class EntityRobot extends EntityRobotBase implements if (linkedDockingStation == null || linkedDockingStation.robotTaking() != this) { - if (!(mainAI.getDelegateAI() instanceof AIRobotShutdown)) { + if (!(mainAI.getDelegateAI() instanceof AIRobotShutdown) && startupCooldown <= 0) { mainAI.startDelegateAI(new AIRobotShutdown(this)); } } @@ -341,10 +346,15 @@ public class EntityRobot extends EntityRobotBase implements @SideOnly(Side.CLIENT) private void spawnEnergyFX() { Minecraft.getMinecraft().effectRenderer.addEffect(new EntityRobotEnergyParticle( - 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)); + 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)); + } + + @Override + public boolean canShutdown() { + return startupCooldown <= 0; } public void setRegularBoundingBox() { diff --git a/common/buildcraft/robotics/ai/AIRobotMain.java b/common/buildcraft/robotics/ai/AIRobotMain.java index b1ff8f50..5c628216 100755 --- a/common/buildcraft/robotics/ai/AIRobotMain.java +++ b/common/buildcraft/robotics/ai/AIRobotMain.java @@ -28,7 +28,7 @@ public class AIRobotMain extends AIRobot { @Override public void preempt(AIRobot ai) { - if (robot.getEnergy() <= EntityRobotBase.SHUTDOWN_ENERGY + if (robot.getEnergy() <= EntityRobotBase.SHUTDOWN_ENERGY && robot.canShutdown() && (robot.getDockingStation() == null || !robot.getDockingStation().providesPower())) { if (!(ai instanceof AIRobotShutdown)) { startDelegateAI(new AIRobotShutdown(robot)); diff --git a/common/buildcraft/robotics/boards/BCBoardNBT.java b/common/buildcraft/robotics/boards/BCBoardNBT.java index 023bf348..0953235e 100644 --- a/common/buildcraft/robotics/boards/BCBoardNBT.java +++ b/common/buildcraft/robotics/boards/BCBoardNBT.java @@ -50,7 +50,7 @@ public class BCBoardNBT extends RedstoneBoardRobotNBT { @Override public String getID() { - return "buildcraft:" + id; + return id; } @Override