added control of wether an AI can be loaded from NBT
This commit is contained in:
parent
846e186c9a
commit
4f41d134a7
6 changed files with 35 additions and 3 deletions
|
@ -25,4 +25,9 @@ public abstract class RedstoneBoardRobot extends AIRobot implements IRedstoneBoa
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,10 @@ public class AIRobot {
|
|||
return 0.1;
|
||||
}
|
||||
|
||||
public boolean canLoadFromNBT() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to receive items in parameters, return items that are left after
|
||||
* the operation.
|
||||
|
@ -150,7 +154,7 @@ public class AIRobot {
|
|||
writeSelfToNBT(data);
|
||||
nbt.setTag("data", data);
|
||||
|
||||
if (delegateAI != null) {
|
||||
if (delegateAI != null && delegateAI.canLoadFromNBT()) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
|
||||
delegateAI.writeToNBT(sub);
|
||||
|
@ -167,8 +171,11 @@ public class AIRobot {
|
|||
try {
|
||||
delegateAI = (AIRobot) Class.forName(sub.getString("class")).getConstructor(EntityRobotBase.class)
|
||||
.newInstance(robot);
|
||||
delegateAI.parentAI = this;
|
||||
delegateAI.loadFromNBT(sub);
|
||||
|
||||
if (delegateAI.canLoadFromNBT()) {
|
||||
delegateAI.parentAI = this;
|
||||
delegateAI.loadFromNBT(sub);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -133,6 +133,11 @@ public class AIRobotGotoBlock extends AIRobotGoto {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSelfToNBT(NBTTagCompound nbt) {
|
||||
super.writeSelfToNBT(nbt);
|
||||
|
|
|
@ -31,4 +31,9 @@ public class AIRobotGotoSleep extends AIRobot {
|
|||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,11 @@ public class AIRobotGotoStation extends AIRobot {
|
|||
return docked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSelfToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound indexNBT = new NBTTagCompound();
|
||||
|
|
|
@ -55,4 +55,9 @@ public class AIRobotMain extends AIRobot {
|
|||
public AIRobot getOverridingAI() {
|
||||
return overridingAI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue