fix valves for power and add omnidirectional valves with no parameter, closes #2019
This commit is contained in:
parent
c426661973
commit
257c49f4f9
4 changed files with 55 additions and 44 deletions
|
@ -427,6 +427,10 @@ public class PipeTransportPower extends PipeTransport {
|
|||
public void requestEnergy(ForgeDirection from, int amount) {
|
||||
step();
|
||||
|
||||
if (!outputsOpen[from.ordinal()]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.container.pipe instanceof IPipeTransportPowerHook) {
|
||||
nextPowerQuery[from.ordinal()] += ((IPipeTransportPowerHook) this.container.pipe).requestEnergy(from, amount);
|
||||
} else {
|
||||
|
|
|
@ -364,12 +364,13 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void slotClicked(AdvancedSlot slot, int mouseButton) {
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
if (gate == null) {
|
||||
return;
|
||||
}
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
super.slotClicked(slot, mouseButton);
|
||||
AdvancedSlot slot = getSlotAtLocation(i, j);
|
||||
|
||||
if (slot instanceof TriggerSlot && container.hasTriggers()) {
|
||||
TriggerSlot triggerSlot = (TriggerSlot) slot;
|
||||
|
@ -378,14 +379,14 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
|
||||
if (triggerSlot.getStatement() == null) {
|
||||
|
||||
if (mouseButton == 0) {
|
||||
if (k == 0) {
|
||||
changed = container.getFirstTrigger();
|
||||
} else {
|
||||
changed = container.getLastTrigger();
|
||||
}
|
||||
|
||||
} else {
|
||||
Iterator<ITrigger> it = container.getTriggerIterator(mouseButton != 0);
|
||||
Iterator<ITrigger> it = container.getTriggerIterator(k != 0);
|
||||
|
||||
for (; it.hasNext();) {
|
||||
ITrigger trigger = it.next();
|
||||
|
@ -417,14 +418,14 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
IAction changed = null;
|
||||
if (actionSlot.getStatement() == null) {
|
||||
|
||||
if (mouseButton == 0) {
|
||||
if (k == 0) {
|
||||
changed = container.getFirstAction();
|
||||
} else {
|
||||
changed = container.getLastAction();
|
||||
}
|
||||
|
||||
} else {
|
||||
Iterator<IAction> it = container.getActionIterator(mouseButton != 0);
|
||||
Iterator<IAction> it = container.getActionIterator(k != 0);
|
||||
|
||||
for (; it.hasNext();) {
|
||||
IAction action = it.next();
|
||||
|
|
|
@ -213,7 +213,9 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
|||
}
|
||||
|
||||
public boolean isPowerSource(TileEntity tile, ForgeDirection from) {
|
||||
if (tile instanceof IPowerEmitter && ((IPowerEmitter) tile).canEmitPowerFrom(from.getOpposite())) {
|
||||
if (!transport.inputOpen(from)) {
|
||||
return false;
|
||||
} else if (tile instanceof IPowerEmitter && ((IPowerEmitter) tile).canEmitPowerFrom(from.getOpposite())) {
|
||||
return true;
|
||||
} else {
|
||||
return tile instanceof IEnergyHandler && ((IEnergyHandler) tile).canConnectEnergy(from.getOpposite());
|
||||
|
|
|
@ -22,78 +22,82 @@ import buildcraft.core.utils.StringUtils;
|
|||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeTransport;
|
||||
|
||||
|
||||
public class ActionValve extends BCActionActive {
|
||||
|
||||
public enum ValveState {
|
||||
OPEN(true, true),
|
||||
INPUT_ONLY(true, false),
|
||||
OUTPUT_ONLY(false, true),
|
||||
CLOSED(false, false);
|
||||
|
||||
public static final ValveState[] VALUES = values();
|
||||
public final boolean inputOpen;
|
||||
public final boolean outputOpen;
|
||||
|
||||
private ValveState(boolean in, boolean out) {
|
||||
inputOpen = in;
|
||||
outputOpen = out;
|
||||
}
|
||||
OPEN(true, true),
|
||||
INPUT_ONLY(true, false),
|
||||
OUTPUT_ONLY(false, true),
|
||||
CLOSED(false, false);
|
||||
|
||||
public static final ValveState[] VALUES = values();
|
||||
public final boolean inputOpen;
|
||||
public final boolean outputOpen;
|
||||
|
||||
private ValveState(boolean in, boolean out) {
|
||||
inputOpen = in;
|
||||
outputOpen = out;
|
||||
}
|
||||
}
|
||||
|
||||
public final ValveState state;
|
||||
|
||||
|
||||
public ActionValve(ValveState valveState) {
|
||||
super("buildcraft:pipe.valve." + valveState.name().toLowerCase(Locale.ENGLISH));
|
||||
state = valveState;
|
||||
super("buildcraft:pipe.valve." + valveState.name().toLowerCase(Locale.ENGLISH));
|
||||
state = valveState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtils.localize("gate.action.pipe.valve." + state.name().toLowerCase(Locale.ENGLISH));
|
||||
return StringUtils.localize("gate.action.pipe.valve." + state.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/action_valve_" + state.name().toLowerCase(Locale.ENGLISH));
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/action_valve_" + state.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minParameters() {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IActionParameter createParameter(int index) {
|
||||
IActionParameter param = null;
|
||||
|
||||
if (index == 0) {
|
||||
param = new ActionParameterDirection();
|
||||
}
|
||||
|
||||
return param;
|
||||
IActionParameter param = null;
|
||||
|
||||
if (index == 0) {
|
||||
param = new ActionParameterDirection();
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionActivate(IGate gate, IActionParameter[] parameters) {
|
||||
if (parameters[0] != null) {
|
||||
IPipe pipe = gate.getPipe();
|
||||
|
||||
|
||||
if (pipe != null && pipe instanceof Pipe) {
|
||||
PipeTransport transport = ((Pipe) pipe).transport;
|
||||
ForgeDirection side = ((ActionParameterDirection) parameters[0]).direction;
|
||||
|
||||
if (side != ForgeDirection.UNKNOWN) {
|
||||
transport.allowInput(side, state.inputOpen);
|
||||
transport.allowOutput(side, state.outputOpen);
|
||||
PipeTransport transport = ((Pipe) pipe).transport;
|
||||
if (parameters[0] != null) {
|
||||
ForgeDirection side = ((ActionParameterDirection) parameters[0]).direction;
|
||||
|
||||
if (side != ForgeDirection.UNKNOWN) {
|
||||
transport.allowInput(side, state.inputOpen);
|
||||
transport.allowOutput(side, state.outputOpen);
|
||||
}
|
||||
} else {
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
|
||||
transport.allowInput(side, state.inputOpen);
|
||||
transport.allowOutput(side, state.outputOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue