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 width = 50;
public static final int height = 10; public static final int height = 10;
public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) { 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.type = extra;
this.slot = slot; this.slot = slot;
} }
public GuiButtonExtended(int id, int xPosition, String s) { 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 @Override
public void drawButton(Minecraft minecraft, int i, int j) { public void drawButton(Minecraft minecraft, int i, int j) {

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

@ -24,13 +24,13 @@ public class GuiWiring extends GuiScrollable {
//Inputs //Inputs
if(wireEntity.inputs != null && !this.tool.type.equals("input")) { if(wireEntity.inputs != null && !this.tool.type.equals("input")) {
for (int i = 0; i < wireEntity.inputs.length; i++) { 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 //Outputs
if(wireEntity.outputs != null && !this.tool.type.equals("output")) { if(wireEntity.outputs != null && !this.tool.type.equals("output")) {
for (int i = 0; i < wireEntity.outputs.length; i++) { 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>(); tool.sideadd = new ArrayList<Integer>();
} }
} else if(!this.tool.type.equals("unpaired")) { } 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); 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); otherEntity.inputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot);
wireEntity.updateIO(); wireEntity.updateIO();
@ -82,7 +82,7 @@ public class GuiWiring extends GuiScrollable {
tool.zadd = new ArrayList<Integer>(); tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>(); tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired"; 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) { 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); 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); 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 class ChipTileEntity extends AbstractWireTileEntity {
public String mode = "none"; public String mode = "none";
private boolean shouldIncrement = true; private boolean shouldIncrement = true;
private boolean shouldDecrement = true;
@Override @Override
public void update() { public void update() {
switch (mode) { switch (mode) {
case "count": case "inc":
doIncrement(); doIncrement();
updateIO(); updateIO();
break; break;
case "dec":
doDecrement();
updateIO();
break;
case "incdec":
doIncrementDecrement();
updateIO();
break;
case "dup": case "dup":
doDup(); doDup();
updateIO(); 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() { private void doDiv() {
outputs[0].floatvalue = inputs[0].floatvalue / inputs[1].floatvalue; 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); this.outputs[0] = new WiringButton(214, 240, "Output", 0);
hasSettings = true; hasSettings = true;
break; break;
case "count": case "inc":
case "dec":
this.inputs = new WiringButton[3]; this.inputs = new WiringButton[3];
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);
@ -105,6 +147,15 @@ public class ChipTileEntity extends AbstractWireTileEntity {
this.inputs[1] = new WiringButton(214, 200, "Clock", 1); this.inputs[1] = new WiringButton(214, 200, "Clock", 1);
this.inputs[2] = new WiringButton(214, 180, "Reset", 2); this.inputs[2] = new WiringButton(214, 180, "Reset", 2);
break; 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": case "dup":
this.inputs = new WiringButton[1]; this.inputs = new WiringButton[1];
this.outputs = new WiringButton[2]; this.outputs = new WiringButton[2];
@ -113,26 +164,8 @@ public class ChipTileEntity extends AbstractWireTileEntity {
this.inputs[0] = new WiringButton(214, 230, "Input", 0); this.inputs[0] = new WiringButton(214, 230, "Input", 0);
break; break;
case "add": 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": 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": 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": case "div":
this.inputs = new WiringButton[2]; this.inputs = new WiringButton[2];
this.outputs = new WiringButton[1]; this.outputs = new WiringButton[1];

Loading…
Cancel
Save