More Chips!

main
Astoria 2 years ago
parent 513156aad8
commit 6baf9edc67

@ -13,6 +13,16 @@ public class GuiProgrammer extends GuiScrollable {
//this.height - 240 is top //this.height - 240 is top
//This.width / 2 //This.width / 2
int i = 0; int i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "TRUE"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "FALSE"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "AND"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NAND"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "OR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "XOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "XNOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NOT"));
i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width, "Constant")); this.controlList.add(new GuiButtonExtended(i++, this.width, "Constant"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Increment")); this.controlList.add(new GuiButtonExtended(i++, this.width, "Increment"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Decrement")); this.controlList.add(new GuiButtonExtended(i++, this.width, "Decrement"));
@ -60,6 +70,17 @@ public class GuiProgrammer extends GuiScrollable {
case "Increment/Decrement": case "Increment/Decrement":
((ChipTileEntity) wireEntity).setMode("incdec"); ((ChipTileEntity) wireEntity).setMode("incdec");
break; break;
case "TRUE":
case "FALSE":
case "NOT":
case "AND":
case "OR":
case "XOR":
case "NAND":
case "NOR":
case "XNOR":
((ChipTileEntity) wireEntity).setMode(guibutton.displayString);
break;
} }
} }
this.mc.displayGuiScreen(null); this.mc.displayGuiScreen(null);

@ -44,7 +44,72 @@ public class ChipTileEntity extends AbstractWireTileEntity {
doDiv(); doDiv();
updateIO(); updateIO();
break; break;
case "NOT":
doNOT();
updateIO();
break;
case "AND":
doAND();
updateIO();
break;
case "OR":
doOR();
updateIO();
break;
case "XOR":
doXOR();
updateIO();
break;
case "NAND":
doNAND();
updateIO();
break;
case "NOR":
doNOR();
updateIO();
break;
case "XNOR":
doXNOR();
updateIO();
break;
case "TRUE":
outputs[0].floatvalue = 1.0f;
updateIO();
break;
case "FALSE":
outputs[0].floatvalue = 0.0f;
updateIO();
break;
}
} }
private void doXNOR() {
outputs[0].floatvalue = inputs[0].floatvalue == 1 ^ inputs[1].floatvalue == 1 ? 0.0f : 1.0f;
}
private void doNOR() {
outputs[0].floatvalue = inputs[0].floatvalue == 1 || inputs[1].floatvalue == 1 ? 0.0f : 1.0f;
}
private void doNAND() {
outputs[0].floatvalue = inputs[0].floatvalue == 1 && inputs[1].floatvalue == 1 ? 0.0f : 1.0f;
}
private void doXOR() {
outputs[0].floatvalue = inputs[0].floatvalue == 1 ^ inputs[1].floatvalue == 1 ? 1.0f : 0.0f;
}
private void doOR() {
outputs[0].floatvalue = inputs[0].floatvalue == 1 || inputs[1].floatvalue == 1 ? 1.0f : 0.0f;
}
private void doAND() {
System.out.println("ae");
outputs[0].floatvalue = inputs[0].floatvalue == 1 && inputs[1].floatvalue == 1 ? 1.0f : 0.0f;
}
private void doNOT() {
this.outputs[0].floatvalue = inputs[0].floatvalue == 0 ? 1.0f : 0.0f;
} }
private void doIncrementDecrement() { private void doIncrementDecrement() {
@ -133,10 +198,12 @@ public class ChipTileEntity extends AbstractWireTileEntity {
mode = string; mode = string;
switch(string) { switch(string) {
case "constant": case "constant":
hasSettings = true;
case "TRUE":
case "FALSE":
this.inputs = new WiringButton[0]; this.inputs = new WiringButton[0];
this.outputs = new WiringButton[1]; this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0); this.outputs[0] = new WiringButton(214, 240, "Output", 0);
hasSettings = true;
break; break;
case "inc": case "inc":
case "dec": case "dec":
@ -163,6 +230,18 @@ public class ChipTileEntity extends AbstractWireTileEntity {
this.outputs[1] = new WiringButton(214, 210, "Output B", 1); this.outputs[1] = new WiringButton(214, 210, "Output B", 1);
this.inputs[0] = new WiringButton(214, 230, "Input", 0); this.inputs[0] = new WiringButton(214, 230, "Input", 0);
break; break;
case "NOT":
this.inputs = new WiringButton[1];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 230, "Output", 0);
this.inputs[0] = new WiringButton(214, 210, "Input", 0);
break;
case "AND":
case "OR":
case "XOR":
case "NAND":
case "NOR":
case "XNOR":
case "add": case "add":
case "sub": case "sub":
case "mult": case "mult":
@ -175,6 +254,7 @@ public class ChipTileEntity extends AbstractWireTileEntity {
break; break;
} }
initialized = true; initialized = true;
update();
} }
} }
} }

Loading…
Cancel
Save