Merge branch '6.5.x' of github.com:BuildCraft/BuildCraft into 6.5.x

This commit is contained in:
asiekierka 2015-06-30 12:05:05 +02:00
commit 59cde09f82
15 changed files with 118 additions and 12 deletions

View file

@ -45,7 +45,7 @@ public class AIRobotAttack extends AIRobot {
@Override
public void update() {
if (target.isDead) {
if (target == null || target.isDead) {
terminate();
return;
}

View file

@ -137,6 +137,11 @@ public class AIRobotBreak extends AIRobot {
return (int) Math.ceil((float) BuilderAPI.BREAK_ENERGY * 2 / 30.0F);
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

View file

@ -8,6 +8,11 @@
*/
package buildcraft.robotics.ai;
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;
@ -61,4 +66,31 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
NBTTagCompound indexNBT = new NBTTagCompound();
station.index().writeTo(indexNBT);
nbt.setTag("stationIndex", indexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal());
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("stationIndex")) {
BlockIndex index = new BlockIndex(nbt.getCompoundTag("stationIndex"));
ForgeDirection side = ForgeDirection.values()[nbt.getByte("stationSide")];
station = robot.getRegistry().getStation(index.x, index.y, index.z, side);
} else {
station = robot.getLinkedStation();
}
}
}

View file

@ -31,9 +31,4 @@ public class AIRobotGotoSleep extends AIRobot {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
}

View file

@ -36,7 +36,7 @@ public class AIRobotGotoStationAndLoad extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) {
if (ai.success()) {
if (filter != null && ai.success()) {
startDelegateAI(new AIRobotLoad(robot, filter, quantity));
} else {
setSuccess(false);

View file

@ -34,7 +34,7 @@ public class AIRobotGotoStationAndLoadFluids extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoadFluids) {
if (ai.success()) {
if (filter != null && ai.success()) {
startDelegateAI(new AIRobotLoadFluids(robot, filter));
} else {
setSuccess(false);

View file

@ -59,6 +59,11 @@ public class AIRobotHarvest extends AIRobot {
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

View file

@ -44,7 +44,6 @@ public class AIRobotLoad extends AIRobot {
@Override
public void update() {
if (filter == null) {
// loading error
terminate();
return;
}

View file

@ -38,6 +38,11 @@ public class AIRobotLoadFluids extends AIRobot {
@Override
public void update() {
if (filter == null) {
terminate();
return;
}
waitedCycles++;
if (waitedCycles > 40) {

View file

@ -93,6 +93,11 @@ public class AIRobotSearchBlock extends AIRobot {
return blockFound != null;
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

View file

@ -42,7 +42,6 @@ public class AIRobotSearchRandomGroundBlock extends AIRobot {
@Override
public void update() {
if (filter == null) {
// defensive code
terminate();
}

View file

@ -8,6 +8,8 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.robots.EntityRobotBase;
public class AIRobotStraightMoveTo extends AIRobotGoto {
@ -52,4 +54,29 @@ public class AIRobotStraightMoveTo extends AIRobotGoto {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
nbt.setFloat("x", x);
nbt.setFloat("y", y);
nbt.setFloat("z", z);
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("x")) {
x = nbt.getFloat("x");
y = nbt.getFloat("y");
z = nbt.getFloat("z");
}
}
}

View file

@ -46,6 +46,12 @@ public class AIRobotStripesHandler extends AIRobot implements IStripesActivator
@Override
public void update() {
if (useToBlock == null) {
setSuccess(false);
terminate();
return;
}
useCycles++;
if (useCycles > 60) {

View file

@ -9,7 +9,9 @@
package buildcraft.robotics.boards;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
@ -80,8 +82,9 @@ public class BoardRobotPump extends RedstoneBoardRobot {
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotGotoStationAndUnloadFluids) {
} else if (ai instanceof AIRobotPumpBlock){
releaseBlockFound();
} else if (ai instanceof AIRobotGotoStationAndUnloadFluids) {
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
@ -118,4 +121,27 @@ public class BoardRobotPump extends RedstoneBoardRobot {
return fluidFilter.matches(fluid);
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
if (blockFound != null) {
NBTTagCompound sub = new NBTTagCompound();
blockFound.writeTo(sub);
nbt.setTag("blockFound", sub);
}
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("blockFound")) {
blockFound = new BlockIndex(nbt.getCompoundTag("blockFound"));
}
}
}

View file

@ -68,7 +68,9 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
newStation = getStation((StatementParameterItemStack) parameters[0], registry);
}
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
if (newStation != null) {
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
}
}
}
}