From c0e198d8c58c74d2b1ab40a0db56fd607d260b78 Mon Sep 17 00:00:00 2001 From: Astoria Date: Mon, 3 Apr 2023 20:38:06 -0500 Subject: [PATCH] More chips! --- .../afloydwiremod/gui/GuiProgrammer.java | 18 ++++- .../tileentity/ChipTileEntity.java | 65 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java index 6e622d6..0cff77d 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java @@ -14,7 +14,11 @@ public class GuiProgrammer extends GuiScrollable { //This.width / 2 this.controlList.add(new GuiButtonExtended(1, this.width, "Constant")); this.controlList.add(new GuiButtonExtended(2, this.width, "Count")); - this.controlList.add(new GuiButtonExtended(3, this.width, "Addition")); + this.controlList.add(new GuiButtonExtended(3, this.width, "Duplicate")); + this.controlList.add(new GuiButtonExtended(4, this.width, "Addition")); + this.controlList.add(new GuiButtonExtended(5, this.width, "Subtraction")); + this.controlList.add(new GuiButtonExtended(6, this.width, "Multiplication")); + this.controlList.add(new GuiButtonExtended(7, this.width, "Division")); } public GuiProgrammer(EntityPlayer player, AbstractWireTileEntity wireEntity) { @@ -33,8 +37,20 @@ public class GuiProgrammer extends GuiScrollable { ((ChipTileEntity) wireEntity).setMode("count"); break; case 3: + ((ChipTileEntity) wireEntity).setMode("dup"); + break; + case 4: ((ChipTileEntity) wireEntity).setMode("add"); break; + case 5: + ((ChipTileEntity) wireEntity).setMode("sub"); + break; + case 6: + ((ChipTileEntity) wireEntity).setMode("mult"); + break; + case 7: + ((ChipTileEntity) wireEntity).setMode("div"); + 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 8097194..f3c7fe5 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/tileentity/ChipTileEntity.java @@ -15,15 +15,51 @@ public class ChipTileEntity extends AbstractWireTileEntity { doIncrement(); updateIO(); break; + case "dup": + doDup(); + updateIO(); + break; case "add": doAdd(); updateIO(); break; + case "sub": + doSub(); + updateIO(); + break; + case "mult": + doMult(); + updateIO(); + break; + case "div": + doDiv(); + updateIO(); + break; } } + private void doDiv() { + outputs[0].floatvalue = inputs[0].floatvalue / inputs[1].floatvalue; + } + + private void doMult() { + outputs[0].floatvalue = inputs[0].floatvalue * inputs[1].floatvalue; + } + + private void doSub() { + outputs[0].floatvalue = inputs[0].floatvalue - inputs[1].floatvalue; + } + + private void doDup() { + outputs[0].floatvalue = inputs[0].floatvalue; + outputs[1].floatvalue = inputs[0].floatvalue; + outputs[0].stringvalue = inputs[0].stringvalue; + outputs[1].stringvalue = inputs[0].stringvalue; + } + private void doAdd() { outputs[0].floatvalue = inputs[0].floatvalue + inputs[1].floatvalue; + outputs[0].stringvalue = inputs[0].stringvalue + inputs[1].stringvalue; } public void doIncrement() { @@ -69,12 +105,41 @@ public class ChipTileEntity extends AbstractWireTileEntity { this.inputs[1] = new WiringButton(214, 200, "Clock", 1); this.inputs[2] = new WiringButton(214, 180, "Reset", 2); break; + case "dup": + this.inputs = new WiringButton[1]; + this.outputs = new WiringButton[2]; + this.outputs[0] = new WiringButton(214, 230, "Output A", 0); + this.outputs[1] = new WiringButton(214, 210, "Output B", 1); + this.inputs[0] = new WiringButton(214, 230, "Input", 0); + break; case "add": this.inputs = new WiringButton[2]; this.outputs = new WiringButton[1]; this.outputs[0] = new WiringButton(214, 230, "Output", 0); this.inputs[0] = new WiringButton(214, 210, "Input A", 0); this.inputs[1] = new WiringButton(214, 190, "Input B", 1); + break; + case "sub": + this.inputs = new WiringButton[2]; + this.outputs = new WiringButton[1]; + this.outputs[0] = new WiringButton(214, 230, "Output", 0); + this.inputs[0] = new WiringButton(214, 210, "Input A", 0); + this.inputs[1] = new WiringButton(214, 190, "Input B", 1); + break; + case "mult": + this.inputs = new WiringButton[2]; + this.outputs = new WiringButton[1]; + this.outputs[0] = new WiringButton(214, 230, "Output", 0); + this.inputs[0] = new WiringButton(214, 210, "Input A", 0); + this.inputs[1] = new WiringButton(214, 190, "Input B", 1); + break; + case "div": + this.inputs = new WiringButton[2]; + this.outputs = new WiringButton[1]; + this.outputs[0] = new WiringButton(214, 230, "Output", 0); + this.inputs[0] = new WiringButton(214, 210, "Input A", 0); + this.inputs[1] = new WiringButton(214, 190, "Input B", 1); + break; } initialized = true; }