More chips + some weirdness (BREAKS SAVES)

main
Astoria 2 years ago
parent 0a35d762ec
commit a1b3b107f5

@ -13,12 +13,12 @@ public class GuiButtonExtended extends GuiButton {
public static final int width = 50;
public static final int height = 10;
public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * id), width, height, s);
super(id, xPosition / 2 - (width / 2), 50 - height + (height * (id + 1)), width, height, s);
this.type = extra;
this.slot = slot;
}
public GuiButtonExtended(int id, int xPosition, String s) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * id), width, height, s);
super(id, xPosition / 2 - (width / 2), 50 - height + (height * (id + 1)), width, height, s);
}
@Override
public void drawButton(Minecraft minecraft, int i, int j) {

@ -12,13 +12,16 @@ public class GuiProgrammer extends GuiScrollable {
public void initGui() {
//this.height - 240 is top
//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, "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"));
int 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"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Increment/Decrement"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Duplicate"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Addition"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Subtraction"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Multiplication"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Division"));
}
public GuiProgrammer(EntityPlayer player, AbstractWireTileEntity wireEntity) {
@ -29,28 +32,34 @@ public class GuiProgrammer extends GuiScrollable {
@Override
protected void actionPerformed(GuiButton guibutton) {
if(wireEntity instanceof ChipTileEntity) {
switch(guibutton.id){
case 1:
switch(guibutton.displayString){
case "Constant":
((ChipTileEntity) wireEntity).setMode("constant");
break;
case 2:
((ChipTileEntity) wireEntity).setMode("count");
case "Increment":
((ChipTileEntity) wireEntity).setMode("inc");
break;
case 3:
case "Duplicate":
((ChipTileEntity) wireEntity).setMode("dup");
break;
case 4:
case "Addition":
((ChipTileEntity) wireEntity).setMode("add");
break;
case 5:
case "Subtraction":
((ChipTileEntity) wireEntity).setMode("sub");
break;
case 6:
case "Multiplication":
((ChipTileEntity) wireEntity).setMode("mult");
break;
case 7:
case "Division":
((ChipTileEntity) wireEntity).setMode("div");
break;
case "Decrement":
((ChipTileEntity) wireEntity).setMode("dec");
break;
case "Increment/Decrement":
((ChipTileEntity) wireEntity).setMode("incdec");
break;
}
}
this.mc.displayGuiScreen(null);

@ -24,13 +24,13 @@ public class GuiWiring extends GuiScrollable {
//Inputs
if(wireEntity.inputs != null && !this.tool.type.equals("input")) {
for (int i = 0; i < wireEntity.inputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i + 1, this.width - 50, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot));
this.controlList.add(new GuiButtonExtended(i, this.width - 50, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot));
}
}
//Outputs
if(wireEntity.outputs != null && !this.tool.type.equals("output")) {
for (int i = 0; i < wireEntity.outputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i + 1, this.width + 50, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot));
this.controlList.add(new GuiButtonExtended(i, this.width + 50, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot));
}
}
}
@ -73,7 +73,7 @@ public class GuiWiring extends GuiScrollable {
tool.sideadd = new ArrayList<Integer>();
}
} else if(!this.tool.type.equals("unpaired")) {
if(this.tool.type.equals("input") && wireEntity.outputs[tool.slot].wire.isMade != true && otherEntity.inputs[guibutton.slot].wire.isMade != true) {
if(this.tool.type.equals("input") && wireEntity.outputs[guibutton.slot].wire.isMade != true && otherEntity.inputs[tool.slot].wire.isMade != true) {
wireEntity.outputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false, tool.red, tool.green, tool.blue, tool.alpha, tool.width);
otherEntity.inputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot);
wireEntity.updateIO();
@ -82,7 +82,7 @@ public class GuiWiring extends GuiScrollable {
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired";
} else if(this.tool.type.equals("output") && otherEntity.outputs[tool.slot].wire.isMade != true && wireEntity.inputs[tool.slot].wire.isMade != true ) {
} else if(this.tool.type.equals("output") && otherEntity.outputs[tool.slot].wire.isMade != true && wireEntity.inputs[guibutton.slot].wire.isMade != true ) {
if(otherEntity != null) {
otherEntity.outputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true, tool.red, tool.green, tool.blue, tool.alpha, tool.width);
wireEntity.inputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot);

@ -7,14 +7,23 @@ import net.minecraft.src.NBTTagCompound;
public class ChipTileEntity extends AbstractWireTileEntity {
public String mode = "none";
private boolean shouldIncrement = true;
private boolean shouldDecrement = true;
@Override
public void update() {
switch (mode) {
case "count":
case "inc":
doIncrement();
updateIO();
break;
case "dec":
doDecrement();
updateIO();
break;
case "incdec":
doIncrementDecrement();
updateIO();
break;
case "dup":
doDup();
updateIO();
@ -38,6 +47,38 @@ public class ChipTileEntity extends AbstractWireTileEntity {
}
}
private void doIncrementDecrement() {
if (inputs[3].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue + this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true;
}
if (this.inputs[2].floatvalue > 0 && shouldDecrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue - this.inputs[0].floatvalue;
shouldDecrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldDecrement) {
shouldDecrement = true;
}
}
private void doDecrement() {
if (inputs[2].floatvalue > 0) {
this.outputs[0].floatvalue = 0;
return;
}
if (this.inputs[1].floatvalue > 0 && shouldIncrement) {
this.outputs[0].floatvalue = this.outputs[0].floatvalue - this.inputs[0].floatvalue;
shouldIncrement = false;
} else if (this.inputs[1].floatvalue == 0.0 && !shouldIncrement) {
shouldIncrement = true;
}
}
private void doDiv() {
outputs[0].floatvalue = inputs[0].floatvalue / inputs[1].floatvalue;
}
@ -97,7 +138,8 @@ public class ChipTileEntity extends AbstractWireTileEntity {
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
hasSettings = true;
break;
case "count":
case "inc":
case "dec":
this.inputs = new WiringButton[3];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
@ -105,6 +147,15 @@ 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 "incdec":
this.inputs = new WiringButton[4];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
this.inputs[0] = new WiringButton(214, 220, "Source", 0);
this.inputs[1] = new WiringButton(214, 220, "Increment", 1);
this.inputs[2] = new WiringButton(214, 200, "Decrement", 2);
this.inputs[3] = new WiringButton(214, 180, "Reset", 3);
break;
case "dup":
this.inputs = new WiringButton[1];
this.outputs = new WiringButton[2];
@ -113,26 +164,8 @@ public class ChipTileEntity extends AbstractWireTileEntity {
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];

Loading…
Cancel
Save