From 02bb70ec53a9a7907011cbc2cb05d6e098f6c141 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Thu, 30 Oct 2014 20:06:02 +0100 Subject: [PATCH] initialize mandatory parameters properly, fix bug with not removing certain unusable gate types when minParameters() is above 1 --- .../transport/gui/ContainerGateInterface.java | 24 ++++++++----------- .../transport/gui/GuiGateInterface.java | 12 ++++++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index 6dc186e5..93681769 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -100,27 +100,23 @@ public class ContainerGateInterface extends BuildCraftContainer { potentialTriggers.addAll(gate.getAllValidTriggers()); potentialActions.addAll(gate.getAllValidActions()); - if (gate.material.numTriggerParameters == 0) { - Iterator it = potentialTriggers.iterator(); + Iterator it = potentialTriggers.iterator(); - while (it.hasNext()) { - IStatement trigger = it.next(); + while (it.hasNext()) { + IStatement trigger = it.next(); - if (trigger.minParameters() > 0) { - it.remove(); - } + if (trigger.minParameters() > gate.material.numTriggerParameters) { + it.remove(); } } - if (gate.material.numActionParameters == 0) { - Iterator it = potentialActions.iterator(); + it = potentialActions.iterator(); - while (it.hasNext()) { - IStatement action = it.next(); + while (it.hasNext()) { + IStatement action = it.next(); - if (action.minParameters() > 0) { - it.remove(); - } + if (action.minParameters() > gate.material.numActionParameters) { + it.remove(); } } } diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index dfd66895..dbe31e01 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -412,7 +412,11 @@ public class GuiGateInterface extends GuiAdvancedInterface { } for (StatementParameterSlot p : triggerSlot.parameters) { - container.setTriggerParameter(triggerSlot.slot, p.slot, null, true); + IStatementParameter parameter = null; + if (changed != null && p.slot < changed.minParameters()) { + parameter = changed.createParameter(p.slot); + } + container.setTriggerParameter(triggerSlot.slot, p.slot, parameter, true); } } else if (slot instanceof ActionSlot) { ActionSlot actionSlot = (ActionSlot) slot; @@ -451,7 +455,11 @@ public class GuiGateInterface extends GuiAdvancedInterface { } for (StatementParameterSlot p : actionSlot.parameters) { - container.setActionParameter(actionSlot.slot, p.slot, null, true); + IStatementParameter parameter = null; + if (changed != null && p.slot < changed.minParameters()) { + parameter = changed.createParameter(p.slot); + } + container.setActionParameter(actionSlot.slot, p.slot, parameter, true); } } else if (slot instanceof StatementParameterSlot) { StatementParameterSlot paramSlot = (StatementParameterSlot) slot;