Skip to content

Commit

Permalink
Fixed IOBits getting stuck in CAD and enhanced their tooltips. Closes V…
Browse files Browse the repository at this point in the history
  • Loading branch information
evg-zhabotinsky committed Jan 18, 2016
1 parent e677a33 commit 410c5e8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,22 @@ public boolean mousePressed(Minecraft mc, int par1, int par2) {
public List<String> getHoverInformation() {
ArrayList<String> text = new ArrayList<String>();
ForgeDirection dir = MiscUtils.getDirection(side);
if (te.getCircuitData().getProperties().getModeAtSide(side) == EnumConnectionType.ANALOG)
text.add("S: " + color);
else
text.add("F: 0x" + Integer.toHexString(color));
if (isActive) {
EnumConnectionType mode = te.getCircuitData().getProperties().getModeAtSide(side);
if (mode != EnumConnectionType.SIMPLE) {
if (mode == EnumConnectionType.ANALOG)
text.add("S: " + color);
else
text.add("F: 0x" + Integer.toHexString(color));
}
text.add("I: "
+ I18n.format("gui.integratedcircuits.cad.mode."
+ (te.getExternalInputFromSide(dir, color) ? "high" : "low")));
text.add("O: "
+ I18n.format("gui.integratedcircuits.cad.mode."
+ (te.getOutputToSide(dir, color) ? "high" : "low")));
}
} else
text.add("N");
return text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import moe.nightfall.vic.integratedcircuits.cp.part.PartIOBit;
import moe.nightfall.vic.integratedcircuits.cp.part.PartNull;
import moe.nightfall.vic.integratedcircuits.misc.CraftingAmount;
import moe.nightfall.vic.integratedcircuits.misc.MiscUtils;
import moe.nightfall.vic.integratedcircuits.misc.Vec2;

import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -155,60 +156,53 @@ private EnumConnectionType[] getAndFixModePerSide() {
/** Clears the circuit and sets it up **/
public void clearAllAndSetup(int size) {
clearAll(size);
setupIO();
FixIO();

This comment has been minimized.

Copy link
@Victorious3

Victorious3 Jan 18, 2016

lower case, duh!

}

/** Clears the IOBits, and sets them up again. **/
public void clearIOAndSetupIO() {
clearIO();
setupIO();
}

/** Sets up the IOBits for the circuit. **/
public void setupIO() {
/** Sets up the IOBits and clears unused ones. **/
public void FixIO() {
getAndFixModePerSide();

int o = (supportsBundled() ? size / 2 - 8 : 1);
int o = (supportsBundled() ? size / 2 - 8 : 1); // Offset of first IOBit
// Get the ID of the IOBit
int cid = CircuitPart.getId(PartIOBit.class);
Vec2[] pos = new Vec2[4];

for (int i = 0; i < (supportsBundled() ? 16 : 1); i++) {
// Get the positions
Vec2 pos1 = new Vec2(size - 1 - (i + o), 0);
Vec2 pos2 = new Vec2(size - 1, size - 1 - (i + o));
Vec2 pos3 = new Vec2(i + o, size - 1);
Vec2 pos4 = new Vec2(0, i + o);

if (prop.getModeAtSide(0) != EnumConnectionType.NONE && !(prop.getModeAtSide(0) == EnumConnectionType.SIMPLE && i >= 1)) {
// Set the part at the position to be a IOBit
setID(pos1, cid);
// Get the IOBit at that position
PartIOBit io1 = (PartIOBit) getPart(pos1);
// Set the number of the IOBit (colour / redstone strength)
io1.setFrequency(pos1, parent, i);
// The rotation is what side the IOBit is on
io1.setRotation(pos1, parent, 0);
}

if (prop.getModeAtSide(1) != EnumConnectionType.NONE && !(prop.getModeAtSide(1) == EnumConnectionType.SIMPLE && i >= 1)) {
setID(pos2, cid);
PartIOBit io2 = (PartIOBit) getPart(pos2);
io2.setFrequency(pos2, parent, i);
io2.setRotation(pos2, parent, 1);
}
pos[0] = new Vec2(size - 1 - (i + o), 0);
pos[1] = new Vec2(size - 1, size - 1 - (i + o));
pos[2] = new Vec2(i + o, size - 1);
pos[3] = new Vec2(0, i + o);

if (prop.getModeAtSide(2) != EnumConnectionType.NONE && !(prop.getModeAtSide(2) == EnumConnectionType.SIMPLE && i >= 1)) {
setID(pos3, cid);
PartIOBit io3 = (PartIOBit) getPart(pos3);
io3.setFrequency(pos3, parent, i);
io3.setRotation(pos3, parent, 2);
}

if (prop.getModeAtSide(3) != EnumConnectionType.NONE && !(prop.getModeAtSide(3) == EnumConnectionType.SIMPLE && i >= 1)) {
setID(pos4, cid);
PartIOBit io4 = (PartIOBit) getPart(pos4);
io4.setFrequency(pos4, parent, i);
io4.setRotation(pos4, parent, 3);
for (int j = 0; j < 4; j++) {
if (prop.getModeAtSide(j) != EnumConnectionType.NONE && !(prop.getModeAtSide(j) == EnumConnectionType.SIMPLE && i >= 1)) {
// Set the part at the position to be a IOBit
setID(pos[j], cid);
// Get the IOBit at that position
PartIOBit io = (PartIOBit) getPart(pos[j]);
// Set the number of the IOBit (colour / redstone strength)
io.setFrequency(pos[j], parent, i);
// The rotation is what side the IOBit is on
io.setRotation(pos[j], parent, j);
// Make sure that IOBit does not stall
io.scheduleInputChange(pos[j], parent);
} else {
// Get old part at the position
CircuitPart part = getPart(pos[j]);
if (part instanceof PartIOBit) {
// There was an IOBit. Clear corresponding output signal.
PartIOBit io = (PartIOBit)part;
parent.setOutputToSide(
MiscUtils.getDirection(io.getRotation(pos[j], parent)),
io.getFrequency(pos[j], parent), false);
}
// Clear part at the position
setID(pos[j], 0);
setMeta(pos[j], 0);
// Notify neighbour parts about is
getPart(pos[j]).notifyNeighbours(pos[j], parent);
}
}
}
}
Expand Down Expand Up @@ -238,17 +232,6 @@ public void clearColumn(int x) {
}
}

public void clearIO() {
// Clear top
clearRow(0);
// Clear bottom
clearRow(this.size - 1);
// Clear left
clearColumn(0);
// Clear right
clearColumn(this.size - 1);
}

/** Clears the contents of the circuit and gives it a new size. **/
public void clearContents(int size) {
this.id = new int[size][size];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public void process(EntityPlayer player, Side side) {
CircuitData data = te.getCircuitData();

data.getProperties().setCon(con);
data.clearIOAndSetupIO();
data.FixIO();

if (input && side == Side.SERVER) {
te.getCircuitData().updateInput();
data.updateInput();
CommonProxy.networkWrapper.sendToAllAround(this, new TargetPoint(te.getWorldObj().getWorldInfo()
.getVanillaDimension(), xCoord, yCoord, zCoord, 8));
}
Expand Down

0 comments on commit 410c5e8

Please sign in to comment.