use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class TileFiller method readParametersFromNBT.
private void readParametersFromNBT(NBTTagCompound nbt) {
IStatementParameter[] patternParameters = new IStatementParameter[nbt.getByte("length")];
for (int i = 0; i < patternParameters.length; i++) {
if (nbt.hasKey("p" + i)) {
NBTTagCompound patternData = nbt.getCompoundTag("p" + i);
patternParameters[i] = StatementManager.createParameter(patternData.getString("kind"));
patternParameters[i].readFromNBT(patternData);
}
}
this.patternParameters = patternParameters;
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class TileFiller method writeParametersToNBT.
private void writeParametersToNBT(NBTTagCompound nbt) {
IStatementParameter[] patternParameters = this.patternParameters;
nbt.setByte("length", (byte) (patternParameters != null ? patternParameters.length : 0));
if (patternParameters != null) {
for (int i = 0; i < patternParameters.length; i++) {
if (patternParameters[i] != null) {
NBTTagCompound patternData = new NBTTagCompound();
patternData.setString("kind", patternParameters[i].getUniqueTag());
// ArrayIndexOutOfBounds
patternParameters[i].writeToNBT(patternData);
nbt.setTag("p" + i, patternData);
}
}
}
}
use of buildcraft.api.statements.IStatementParameter in project LogisticsPipes by RS485.
the class LPBCTileGenericPipe method statementEquals.
private boolean statementEquals(StatementSlot slot1, StatementSlot slot2) {
if (slot1.statement != slot2.statement || slot1.parameters.length != slot2.parameters.length) {
return false;
}
for (int i = 0; i < slot1.parameters.length; i++) {
IStatementParameter p1 = slot1.parameters[i];
IStatementParameter p2 = slot2.parameters[i];
if ((p1 != null && !(p1.equals(p2))) || (p1 == null && p2 != null)) {
return false;
}
}
return true;
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class SchematicPipe method rotateGateLeft.
private void rotateGateLeft(NBTTagCompound gateNBT) {
for (int i = 0; i < Gate.MAX_STATEMENTS; ++i) {
if (gateNBT.hasKey("trigger[" + i + "]")) {
IStatement t = StatementManager.statements.get(gateNBT.getString("trigger[" + i + "]"));
t = t.rotateLeft();
gateNBT.setString("trigger[" + i + "]", t.getUniqueTag());
}
if (gateNBT.hasKey("action[" + i + "]")) {
IStatement a = StatementManager.statements.get(gateNBT.getString("action[" + i + "]"));
a = a.rotateLeft();
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
}
for (int j = 0; j < Gate.MAX_PARAMETERS; ++j) {
if (gateNBT.hasKey("triggerParameters[" + i + "][" + j + "]")) {
NBTTagCompound cpt = gateNBT.getCompoundTag("triggerParameters[" + i + "][" + j + "]");
IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
parameter.readFromNBT(cpt);
parameter = parameter.rotateLeft();
parameter.writeToNBT(cpt);
gateNBT.setTag("triggerParameters[" + i + "][" + j + "]", cpt);
}
if (gateNBT.hasKey("actionParameters[" + i + "][" + j + "]")) {
NBTTagCompound cpt = gateNBT.getCompoundTag("actionParameters[" + i + "][" + j + "]");
IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
parameter.readFromNBT(cpt);
parameter = parameter.rotateLeft();
parameter.writeToNBT(cpt);
gateNBT.setTag("actionParameters[" + i + "][" + j + "]", cpt);
}
}
}
if (gateNBT.hasKey("direction")) {
EnumFacing face = EnumFacing.VALUES[gateNBT.getInteger("direction")];
if (face.getAxis() != Axis.Y) {
face = face.rotateY();
}
gateNBT.setInteger("direction", face.ordinal());
}
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class TriggerPipeSignal method isTriggerActive.
@Override
public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) {
if (!(container instanceof IGate)) {
return false;
}
IGate gate = (IGate) container;
IWireManager wires = gate.getPipeHolder().getWireManager();
if (active) {
if (!wires.isAnyPowered(colour)) {
return false;
}
} else if (wires.isAnyPowered(colour)) {
return false;
}
for (IStatementParameter param : parameters) {
if (param != null && param instanceof TriggerParameterSignal) {
TriggerParameterSignal signal = (TriggerParameterSignal) param;
if (signal.colour != null) {
if (!wires.isAnyPowered(signal.colour)) {
return false;
}
} else if (wires.isAnyPowered(signal.colour)) {
return false;
}
}
}
return true;
}
Aggregations