Switch instead of if

main
astoria 2 years ago
parent bd824b43a8
commit 80cb07dd48

@ -37,8 +37,10 @@ public class GuiSettings extends GuiScreen {
@Override @Override
protected void actionPerformed(GuiButton guiButton){ protected void actionPerformed(GuiButton guiButton){
if(wireEntity instanceof ChipTileEntity){ if(wireEntity instanceof ChipTileEntity){
if(((ChipTileEntity)wireEntity).mode.equals("constant")){ switch(((ChipTileEntity)wireEntity).mode){
constAction(guiButton); case "constant":
constAction(guiButton);
break;
} }
} }
} }
@ -51,5 +53,6 @@ public class GuiSettings extends GuiScreen {
wireEntity.outputs[0].floatvalue--; wireEntity.outputs[0].floatvalue--;
} }
this.controlList.get(1).displayString = wireEntity.outputs[0].floatvalue + ""; this.controlList.get(1).displayString = wireEntity.outputs[0].floatvalue + "";
wireEntity.updateIO();
} }
} }

@ -46,22 +46,25 @@ public class ChipTileEntity extends AbstractWireTileEntity {
public void setMode(String string) { public void setMode(String string) {
if (mode.equals("none")) { if (mode.equals("none")) {
if (string.equals("constant")) { switch(string) {
mode = string; case "constant":
this.inputs = new WiringButton[0]; mode = string;
this.outputs = new WiringButton[1]; this.inputs = new WiringButton[0];
this.outputs[0] = new WiringButton(214, 240, "Output", 0); this.outputs = new WiringButton[1];
initialized = true; this.outputs[0] = new WiringButton(214, 240, "Output", 0);
hasSettings = true; initialized = true;
} else if (string.equals("count")) { hasSettings = true;
mode = string; break;
this.inputs = new WiringButton[3]; case "count":
this.outputs = new WiringButton[1]; mode = string;
this.outputs[0] = new WiringButton(214, 240, "Output", 0); this.inputs = new WiringButton[3];
this.inputs[0] = new WiringButton(214, 220, "Source", 0); this.outputs = new WiringButton[1];
this.inputs[1] = new WiringButton(214, 200, "Clock", 1); this.outputs[0] = new WiringButton(214, 240, "Output", 0);
this.inputs[2] = new WiringButton(214, 180, "Reset", 2); this.inputs[0] = new WiringButton(214, 220, "Source", 0);
initialized = true; this.inputs[1] = new WiringButton(214, 200, "Clock", 1);
this.inputs[2] = new WiringButton(214, 180, "Reset", 2);
initialized = true;
break;
} }
} }
} }

Loading…
Cancel
Save