use of buildcraft.api.statements.IStatement in project BuildCraft by BuildCraft.
the class ActionType method readFromNbt.
@Override
public ActionWrapper readFromNbt(NBTTagCompound nbt) {
if (nbt == null) {
return null;
}
String kind = nbt.getString("kind");
if (kind == null || kind.isEmpty()) {
return null;
}
EnumPipePart side = EnumPipePart.fromMeta(nbt.getByte("side"));
IStatement statement = StatementManager.statements.get(kind);
if (statement instanceof IAction) {
return ActionWrapper.wrap(statement, side.face);
}
BCLog.logger.warn("[gate.trigger] Couldn't find an action called '{}'! (found {})", kind, statement);
return null;
}
use of buildcraft.api.statements.IStatement in project BuildCraft by BuildCraft.
the class TriggerType method readFromNbt.
@Override
public TriggerWrapper readFromNbt(NBTTagCompound nbt) {
if (nbt == null) {
return null;
}
String kind = nbt.getString("kind");
if (kind == null || kind.isEmpty()) {
return null;
}
EnumPipePart side = EnumPipePart.fromMeta(nbt.getByte("side"));
IStatement statement = StatementManager.statements.get(kind);
if (statement instanceof ITrigger) {
return TriggerWrapper.wrap(statement, side.face);
}
BCLog.logger.warn("[gate.trigger] Couldn't find a trigger called '{}'! (found {})", kind, statement);
return null;
}
use of buildcraft.api.statements.IStatement in project BuildCraft by BuildCraft.
the class ContainerGateInterface method statementsToStrings.
private static String[] statementsToStrings(Collection<IStatement> statements) {
final int size = statements.size();
String[] array = new String[size];
int pos = 0;
for (IStatement statement : statements) {
array[pos++] = statement.getUniqueTag();
}
return array;
}
use of buildcraft.api.statements.IStatement in project BuildCraft by BuildCraft.
the class GuiGateInterface method mouseReleased.
@Override
protected void mouseReleased(int mouseX, int mouseY, int eventType) {
super.mouseReleased(mouseX, mouseY, eventType);
if (index >= 0) {
int i = index;
index = -1;
IStatement changeTo;
Iterator<IStatement> it;
if (trigger)
it = container.getTriggerIterator(false);
else
it = container.getActionIterator(false);
do {
changeTo = it.next();
i--;
} while (i >= 0);
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
if (slot == null)
return;
if (trigger && slot instanceof TriggerSlot) {
TriggerSlot trig = (TriggerSlot) slot;
container.setTrigger(trig.slot, changeTo.getUniqueTag(), true);
for (StatementParameterSlot p : trig.parameters) {
IStatementParameter parameter = null;
if (p.slot < changeTo.minParameters()) {
parameter = changeTo.createParameter(p.slot);
}
container.setTriggerParameter(trig.slot, p.slot, parameter, true);
}
}
if (!trigger && slot instanceof ActionSlot) {
ActionSlot trig = (ActionSlot) slot;
container.setAction(trig.slot, changeTo.getUniqueTag(), true);
for (StatementParameterSlot p : trig.parameters) {
IStatementParameter parameter = null;
if (p.slot < changeTo.minParameters()) {
parameter = changeTo.createParameter(p.slot);
}
container.setActionParameter(trig.slot, p.slot, parameter, true);
}
}
}
}
use of buildcraft.api.statements.IStatement in project BuildCraft by BuildCraft.
the class GuiGateInterface method mouseClicked.
@Override
protected void mouseClicked(int x, int y, int type) throws IOException {
if (gate == null) {
return;
}
super.mouseClicked(x, y, type);
AdvancedSlot slot = getSlotAtLocation(x, y);
if (slot != null) {
doSlotClick(slot, type);
return;
}
int sX = 18;
int sY = 6;
Collection<IStatement> collect = container.getTriggerCollection(false);
for (int i = 0; i < collect.size(); i++) {
int pX = this.guiLeft - sX;
int pY = this.guiTop + sY;
if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
trigger = true;
index = i;
return;
}
if (sX > 18 * 5) {
sX = 18;
sY += 18;
} else
sX += 18;
}
sX = 0;
sY = 6;
collect = container.getActionCollection(false);
for (int i = 0; i < collect.size(); i++) {
int pX = this.guiLeft + this.xSize() + sX;
int pY = this.guiTop + sY;
if (x > pX & x < pX + 16 && y > pY && y < pY + 16) {
trigger = false;
index = i;
return;
}
if (sX > 18 * 4) {
sX = 0;
sY += 18;
} else
sX += 18;
}
}
Aggregations