diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java index d5a11d9..aae113f 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java @@ -13,6 +13,16 @@ public class GuiProgrammer extends GuiScrollable { //this.height - 240 is top //This.width / 2 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, "Increment")); this.controlList.add(new GuiButtonExtended(i++, this.width, "Decrement")); @@ -60,6 +70,17 @@ public class GuiProgrammer extends GuiScrollable { case "Increment/Decrement": ((ChipTileEntity) wireEntity).setMode("incdec"); 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); diff --git a/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java b/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java index e553c84..553b6ed 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java @@ -44,9 +44,74 @@ public class ChipTileEntity extends AbstractWireTileEntity { doDiv(); updateIO(); 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() { if (inputs[3].floatvalue > 0) { this.outputs[0].floatvalue = 0; @@ -133,10 +198,12 @@ public class ChipTileEntity extends AbstractWireTileEntity { mode = string; switch(string) { case "constant": + hasSettings = true; + case "TRUE": + case "FALSE": this.inputs = new WiringButton[0]; this.outputs = new WiringButton[1]; this.outputs[0] = new WiringButton(214, 240, "Output", 0); - hasSettings = true; break; case "inc": case "dec": @@ -163,6 +230,18 @@ public class ChipTileEntity extends AbstractWireTileEntity { this.outputs[1] = new WiringButton(214, 210, "Output B", 1); this.inputs[0] = new WiringButton(214, 230, "Input", 0); 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 "sub": case "mult": @@ -175,6 +254,7 @@ public class ChipTileEntity extends AbstractWireTileEntity { break; } initialized = true; + update(); } } }