|
|
@ -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];
|
|
|
|