From 410c5e8c30f0601033cc282c2ce941edcbcfcf26 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Mon, 18 Jan 2016 14:39:51 +0300 Subject: [PATCH 1/9] Fixed IOBits getting stuck in CAD and enhanced their tooltips. Closes #176. --- .../client/gui/component/GuiIO.java | 14 ++- .../integratedcircuits/cp/CircuitData.java | 93 ++++++++----------- .../net/pcb/PacketPCBChangeInput.java | 4 +- 3 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiIO.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiIO.java index 5d4a416..43698e2 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiIO.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiIO.java @@ -95,18 +95,22 @@ public boolean mousePressed(Minecraft mc, int par1, int par2) { public List getHoverInformation() { ArrayList text = new ArrayList(); 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; } } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java index 79e6962..e96b4f2 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java @@ -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; @@ -155,60 +156,53 @@ private EnumConnectionType[] getAndFixModePerSide() { /** Clears the circuit and sets it up **/ public void clearAllAndSetup(int size) { clearAll(size); - setupIO(); + FixIO(); } - /** 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); + } } } } @@ -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]; diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java b/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java index e24f86d..c2d7aeb 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java @@ -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)); } From 9450ef844fa142807e512a3f431e3218270c80bb Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Mon, 18 Jan 2016 21:22:36 +0300 Subject: [PATCH 2/9] Fixed #174. --- .../moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java b/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java index e6a9617..fd6da3f 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java @@ -200,7 +200,7 @@ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int s if ((side & 6) == (socket.getSide() & 6)) return 0; int rot = socket.getSideRel(side); - if (!socket.getConnectionTypeAtSide(side).isRedstone()) + if (!socket.getConnectionTypeAtSide(rot).isRedstone()) return 0; return socket.getRedstoneOutput(rot); From a2b63d6c9ce7e9d96673f0442d4c9311f47e1697 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Mon, 18 Jan 2016 18:04:53 +0300 Subject: [PATCH 3/9] Fixed textures to make connections less abrupt. --- .../textures/gui/sublogicpart.png | Bin 4669 -> 4517 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/integratedcircuits/textures/gui/sublogicpart.png b/src/main/resources/assets/integratedcircuits/textures/gui/sublogicpart.png index 23db946189019629c3fdc71b0f0602708e8beaa5..e2204f03848ecc4973704f682c9641064240d7a1 100644 GIT binary patch delta 4295 zcmV;&5IFC>B&8#eBo78+OGiWi{{a60|De66laVnPe+P6)O+^Rb0TK;402{m+ZvX%h zGD$>1RCwC$-Ct-OSAM|p->USy};e~n3#?k3)CqNK7c`&zpC zd;dr?e{=ecsO$e+ST`_4gW}X_{gfh71l4s#?qXkE51t zG+Mr!kAGodL3=^(bpVE8$lBVPHVi{7%c`j!A|m(Rd#|du4J4J1>;UHG=CqfBT9zf* zY_{zw(5_v(x_0h6H#aAN^H=jWlv3h2PR(;b%d)DC)_b|GtF_i*nr7@dU0z<+uIq;W zf6TURoz#FEE#J+@?*+eM7_wu>4izkG7=}2Gqm$~;O#Y56bq5d(e$zDDe&F3K82lUO zuPxb(f7JB9wAK>Uu!9Ro0|Nt_8jgQEaqXbd^4)&?{?C=mW$k4Qj^pT!PAstw!O`0= z3@H|iy4ER#e+uG1mMzB|eBJfddB`I^JOYP16*uwXCnNOQBE@t+gyJE>=5%`T2Qi=Khl!us?X>Mxe0Z z^KUm8gu}zbs+r}x{rJ6kzlg}-;GnW?TPvkRDJ8D!R_FdnS%5e4`!fpDG^J9h=yJK7 zxE|oo9Q=!r<#Jh9DwQqejkF6-e~#mX&PTn*-z^JvUOgPgY04$GVEw&w;QiOzm-n+~ z?>~4fNx_pg1>LSi&u%?_FHnPX@8B_~t%E=K(@cM&rXopGk1Z|G8_8VP)rMgx5s{UZ z743~!LCqY&+M(GQO0fRLVo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@}A)kG!0go|p@ry#fdqrV*BIZaM6 zWto^Q&28VaP-CWtOoJV<+SOj~L^TT!)gM(f)+CD-B9>DqD0_YCLMo&-yc{_f=S{rXKzg5(*G_N0cnLil8 zuQo57s;o~}o*Ft9vZMNCLvIHE3VED1m1us$Enr2muGN9jO|nKXllO*7c>*kJ4V2S` znO~Eua4-=rLU~`D$|3uMWfnJ1WGdi=@fcn8wxqiId{Ck}#}P9rVy^Ff=%2=@Cw?O}OgMwz%>6JPN0dB1=nK6GRk#+GUFS?Ga{*QH!hx z*;Be|8tDxWdrqqR8sD>d@g+|Fc~KQ7JGQzEMw?0|L8+yTjc7TrXnt&?Ow98KBDG8& zcj-~a6u%N?rePg&jV{dBcE_yBRZ|Ubgo389N$IY|4S#VTEW_<9bkbcuhkM1}Sd~2e zva(3LP!6=;g5*$Pf_LI1t5sU>6#>XD!uj$6v}=|oJU^&k)n1KSPju02dcNRgYNZl^%OW`p+%d6e9 wm Date: Mon, 18 Jan 2016 18:32:57 +0300 Subject: [PATCH 4/9] Made tunnels be a kind of wire. Closes #160 Tunnels are still separate gate, just derived from wire. Current problem: drop-down menu for wires almost goes off-screen, not sure how to fix properly. --- .../client/gui/cad/PlaceHandler.java | 6 +- .../integratedcircuits/cp/CircuitData.java | 2 +- .../integratedcircuits/cp/CircuitPart.java | 2 +- .../cp/legacy/LegacyLoader.java | 1 + .../cp/legacy/LegacyLoader_1_Tunnels.java | 57 +++++++++++++++++++ .../cp/part/PartTunnel.java | 27 ++++----- .../integratedcircuits/cp/part/PartWire.java | 11 +++- .../assets/integratedcircuits/lang/PT_BR.lang | 4 +- .../assets/integratedcircuits/lang/en_US.lang | 4 +- .../assets/integratedcircuits/lang/ru_RU.lang | 6 +- 10 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java index bfdc225..7ebfe4a 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java @@ -51,7 +51,7 @@ public void renderCADCursor(GuiCAD parent, double mouseX, double mouseY, int gri CircuitPartRenderer.renderPart(selectedPart, gridX * PART_SIZE, gridY * PART_SIZE); GL11.glPopMatrix(); GL11.glColor3f(1, 1, 1); - } else if (selectedPart.getPart() instanceof PartWire) { + } else if (selectedPart.getPart().getClass().equals(PartWire.class)) { PartWire wire = (PartWire) selectedPart.getPart(); switch (wire.getColor(selectedPart.getPos(), selectedPart)) { case 1: @@ -143,7 +143,7 @@ public void onMouseDown(GuiCAD parent, int mx, int my, int button) { if (gridX > 0 && gridY > 0 && gridX < w - 1 && gridY < w - 1 && !GuiScreen.isShiftKeyDown()) { parent.startX = gridX; parent.startY = gridY; - if (selectedPart.getPart() instanceof PartWire) { + if (selectedPart.getPart().getClass().equals(PartWire.class)) { parent.drag = true; } } @@ -160,7 +160,7 @@ public void onMouseUp(GuiCAD parent, int mx, int my, int button) { } if (parent.drag) { - if (selectedPart.getPart() instanceof PartWire) { + if (selectedPart.getPart().getClass().equals(PartWire.class)) { int id = CircuitPart.getId(selectedPart.getPart()); int state = selectedPart.getState(); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java index e96b4f2..7ab4d33 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java @@ -32,7 +32,7 @@ public class CircuitData implements Cloneable { // cdata version - public static final int version = 1; + public static final int version = 2; private int size; private int[][] meta; diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java index 0c01700..7e8f66b 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java @@ -279,7 +279,7 @@ public final CircuitPart getNeighbourOnSide(Vec2 pos, ICircuit parent, ForgeDire return parent.getCircuitData().getPart(pos.offset(side)); } - public final boolean getInput(Vec2 pos, ICircuit parent) { + public boolean getInput(Vec2 pos, ICircuit parent) { return getInputFromSide(pos, parent, ForgeDirection.NORTH) || getInputFromSide(pos, parent, ForgeDirection.EAST) || getInputFromSide(pos, parent, ForgeDirection.SOUTH) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java index f285e19..f8b8ef0 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java @@ -16,6 +16,7 @@ public abstract class LegacyLoader implements Comparable { private static final List legacyLoaders = new ArrayList(); static { legacyLoaders.add(new LegacyLoader_0_8()); + legacyLoaders.add(new LegacyLoader_1_Tunnels()); Collections.sort(legacyLoaders); } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java new file mode 100644 index 0000000..1a4c4f3 --- /dev/null +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java @@ -0,0 +1,57 @@ +package moe.nightfall.vic.integratedcircuits.cp.legacy; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import moe.nightfall.vic.integratedcircuits.cp.CircuitData; +import moe.nightfall.vic.integratedcircuits.cp.legacy.LegacyLoader; +import moe.nightfall.vic.integratedcircuits.misc.MiscUtils; +import moe.nightfall.vic.integratedcircuits.misc.Vec2; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public final class LegacyLoader_1_Tunnels extends LegacyLoader { + @Override + public int getVersion() { + return 1; + } + + { + addTransformer(new PartTunnelTransformer(), 27); + } + + private static class PartTunnelTransformer extends PartTransformer { + // The old PartTunnel property map + // PartCPGate: + protected final int oldInput = old.allocate(4); + // PartTunnel: + protected final int oldPosX = old.allocate(8); + protected final int oldPosY = old.allocate(8); + protected final int oldIn = old.allocate(); + + // Tunnels are now derived from wires + // PartCPGate: + protected final int newInput = transformed.allocate(4); + // PartWire: + protected final int newColor = transformed.allocate(2); + // PartTunnel: + protected final int newPosX = transformed.allocate(8); + protected final int newPosY = transformed.allocate(8); + protected final int newIn = transformed.allocate(); + + @Override + public void transformImpl() { + setInt(newInput, getInt(oldInput)); + // Old tunnels are converted to green tunnels + setInt(newColor, 0); // 0 is green + setInt(newPosX, getInt(oldPosX)); + setInt(newPosY, getInt(oldPosY)); + setBit(newIn, getBit(oldIn)); + } + } + +} diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java index 0bc7049..0f9d6fe 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java @@ -18,12 +18,17 @@ import net.minecraft.init.Items; import net.minecraftforge.common.util.ForgeDirection; -public class PartTunnel extends CircuitPart { +public class PartTunnel extends PartWire { public final IntProperty PROP_POS_X = new IntProperty("PROP_POS_X", stitcher, 255); public final IntProperty PROP_POS_Y = new IntProperty("PROP_POS_Y", stitcher, 255); public final BooleanProperty PROP_IN = new BooleanProperty("PROP_IN", stitcher); + @Override + public boolean getInput(Vec2 pos, ICircuit parent) { + return super.getInput(pos, parent) || getProperty(pos, parent, PROP_IN); + } + // pos is for CURRENT part public Vec2 getConnectedPos(Vec2 pos, ICircuit parent) { return new Vec2(getProperty(pos, parent, PROP_POS_X), getProperty(pos, parent, PROP_POS_Y)); @@ -80,7 +85,7 @@ public boolean getOutputToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { boolean in = getProperty(pos, parent, PROP_IN); if (side == ForgeDirection.UNKNOWN) return getInput(pos, parent) && !in; - return (getInput(pos, parent) || in) && !getInputFromSide(pos, parent, side); + return (getInput(pos, parent)) && !getInputFromSide(pos, parent, side); } @Override @@ -126,20 +131,6 @@ public void onRemoved(Vec2 pos, ICircuit parent) { dropConnected(pos, parent, getConnectedPos(pos, parent)); } - @Override - public void renderPart(Vec2 pos, ICircuit parent, double x, double y, EnumRenderType type) { - Tessellator tes = Tessellator.instance; - - RenderUtils.applyColorIRGBA(tes, Config.colorGreen); - CircuitPartRenderer.addQuad(x, y, 16, 4 * 16, 16, 16); - if (getInput(pos, parent) || getProperty(pos, parent, PROP_IN)) { - RenderUtils.applyColorIRGBA(tes, Config.colorGreen); - } else { - RenderUtils.applyColorIRGBA(tes, Config.colorGreen, 0.4F); - } - CircuitPartRenderer.addQuad(x, y, 0, 4 * 16, 16, 16); - } - @Override public Category getCategory() { return Category.WIRE; @@ -156,13 +147,15 @@ public String getLocalizedName(Vec2 pos, ICircuit parent) { @Override public void getCraftingCost(CraftingAmount amount, CircuitData parent, Vec2 pos) { + // Tunnels are twice as expensive as wires and also cost a bit of silicon. amount.add(new ItemAmount(Items.redstone, 0.1)); amount.add(new ItemAmount(Content.itemSiliconDrop, 0.1)); int data = parent.getMeta(pos); Vec2 end = new Vec2(PROP_POS_X.get(data), PROP_POS_Y.get(data)); if (isConnected(end)) { - amount.add(new ItemAmount(Items.redstone, 0.1 * pos.distanceTo(end))); + // Half the amount, because it will be added twice. + amount.add(new ItemAmount(Items.redstone, 0.05 * pos.distanceTo(end))); } } } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java index 1c7503a..af4d597 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java @@ -35,10 +35,17 @@ public boolean getOutputToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { @Override @SideOnly(Side.CLIENT) + // This renders BOTH WIRES AND TUNNELS public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { int color = this.getColor(pos, parent); + boolean tun = this instanceof PartTunnel; Tessellator tes = Tessellator.instance; + if (tun) { + RenderUtils.applyColorIRGBA(tes, Config.colorGreen); + CircuitPartRenderer.addQuad(x, y, 16, 4*16, 16, 16); + } + if (type == CircuitPartRenderer.EnumRenderType.GUI) { switch (color) { case 1: @@ -66,9 +73,9 @@ public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPar int ty = type == CircuitPartRenderer.EnumRenderType.WORLD_16x ? 3 * 16 : 0; int con = CircuitPartRenderer.checkConnections(pos, parent, this); - if ((con & 12) == 12 && (con & ~12) == 0) + if ((con & 12) == 12 && (con & ~12) == 0 && !tun) CircuitPartRenderer.addQuad(x, y, 6 * 16, ty, 16, 16); - else if ((con & 3) == 3 && (con & ~3) == 0) + else if ((con & 3) == 3 && (con & ~3) == 0 && !tun) CircuitPartRenderer.addQuad(x, y, 5 * 16, ty, 16, 16); else { if ((con & 8) > 0) diff --git a/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang b/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang index f3f16cd..4ebf9c8 100644 --- a/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang +++ b/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang @@ -23,7 +23,9 @@ tile.integratedcircuits.assembler.name=Montadora # parts part.integratedcircuits.iobit.name=IOBit part.integratedcircuits.torch.name=Tocha -part.integratedcircuits.tunnel.name=Tunel +part.integratedcircuits.tunnel.0.name=Tunel +part.integratedcircuits.tunnel.1.name=Tunel vermelho +part.integratedcircuits.tunnel.2.name=Tunel laranja part.integratedcircuits.wire.0.name=Fio part.integratedcircuits.wire.1.name=Fio vermelho part.integratedcircuits.wire.2.name=Fio laranja diff --git a/src/main/resources/assets/integratedcircuits/lang/en_US.lang b/src/main/resources/assets/integratedcircuits/lang/en_US.lang index 09d7da2..ecb164a 100644 --- a/src/main/resources/assets/integratedcircuits/lang/en_US.lang +++ b/src/main/resources/assets/integratedcircuits/lang/en_US.lang @@ -25,7 +25,9 @@ tile.integratedcircuits.pcbprinter.name=Printer # parts part.integratedcircuits.iobit.name=IOBit part.integratedcircuits.torch.name=Torch -part.integratedcircuits.tunnel.name=Tunnel +part.integratedcircuits.tunnel.0.name=Tunnel +part.integratedcircuits.tunnel.1.name=Red Tunnel +part.integratedcircuits.tunnel.2.name=Orange Tunnel part.integratedcircuits.wire.0.name=Wire part.integratedcircuits.wire.1.name=Red Wire part.integratedcircuits.wire.2.name=Orange Wire diff --git a/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang b/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang index 125878a..d6cf853 100644 --- a/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang +++ b/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang @@ -23,7 +23,9 @@ tile.integratedcircuits.assembler.name=Сборщик микросхем # parts part.integratedcircuits.iobit.name=Внешний вывод part.integratedcircuits.torch.name=Факел -part.integratedcircuits.tunnel.name=Перемычка +part.integratedcircuits.tunnel.0.name=Перемычка +part.integratedcircuits.tunnel.1.name=Красная Перемычка +part.integratedcircuits.tunnel.2.name=Оранжевая Перемычка part.integratedcircuits.wire.0.name=Провод part.integratedcircuits.wire.1.name=Красный провод part.integratedcircuits.wire.2.name=Оранжевый провод @@ -153,4 +155,4 @@ fdirection.east.name=ВОСТОК fdirection.south.name=ЮГ fdirection.west.name=ЗАПАД fdirection.up.name=ВЕРХ -fdirection.down.name=НИЗ \ No newline at end of file +fdirection.down.name=НИЗ From c83b6d18db440744d878085df7e8fa72d0aa2180 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Tue, 19 Jan 2016 22:19:12 +0300 Subject: [PATCH 5/9] Stopped part chooser dropdowns being partially off-screen Done so by moving them up. --- .../integratedcircuits/client/gui/cad/GuiCAD.java | 7 ++++++- .../client/gui/component/GuiPartChooser.java | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/GuiCAD.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/GuiCAD.java index 2c559e8..fecbb82 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/GuiCAD.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/GuiCAD.java @@ -244,7 +244,12 @@ public void initGui() { // If the part hasn't got a category, or there are no parts in the category, do not add the button for the category. if (category == CircuitPart.Category.NONE || parts.size() == 0) continue; - this.buttonList.add(new GuiPartChooser(7, toolsXPosition, currentPosition, GuiPartChooser.getRenderWrapperParts(parts), this)); + // To fit drop-down menu should have its bottom no lower than eraser button's. + List wrappers = GuiPartChooser.getRenderWrapperParts(parts); + int partsAbove = wrappers.size() - (guiBottom - 19 - currentPosition) / 21; + if (partsAbove < 0) + partsAbove = 0; + this.buttonList.add(new GuiPartChooser(7, toolsXPosition, currentPosition, partsAbove, wrappers, this)); currentPosition += 21; } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiPartChooser.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiPartChooser.java index 7f5e45d..b697d51 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiPartChooser.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/component/GuiPartChooser.java @@ -23,6 +23,7 @@ public class GuiPartChooser extends GuiButton implements IHoverable { private boolean showList = false; private GuiCAD parent; private GuiPartChooser chooserParent; + private int partsAbove = 0; public GuiPartChooser(int id, int x, int y, int mode, GuiCAD parent) { super(id, x, y, 20, 20, ""); @@ -53,14 +54,15 @@ public GuiPartChooser(int id, int x, int y, CircuitRenderWrapper current, List list2, GuiCAD parent) { + public GuiPartChooser(int id, int x, int y, int above, List list2, GuiCAD parent) { super(id, x, y, 20, 20, ""); + partsAbove = above; if (list2.size() > 0) { current = list2.get(0); ArrayList list3 = new ArrayList(list2); this.children = new ArrayList(); for (int i = 0; i < list3.size(); i++) { - GuiPartChooser child = new GuiPartChooser(i, x - 21, y + i * 21, list3.get(i), parent); + GuiPartChooser child = new GuiPartChooser(i, x - 21, y + (i - partsAbove) * 21, list3.get(i), parent); child.chooserParent = this; child.visible = false; this.children.add(child); @@ -70,6 +72,10 @@ public GuiPartChooser(int id, int x, int y, List list2, Gu this.parent = parent; } + public GuiPartChooser(int id, int x, int y, List list2, GuiCAD parent) { + this(id, x, y, 0, list2, parent); + } + public GuiPartChooser(int id, int x, int y, CircuitPart.Category category, GuiCAD parent) { this(id, x, y, getRenderWrapperParts(category), parent); } @@ -100,7 +106,7 @@ public void drawButton(Minecraft mc, int x, int y) { if (showList && children != null) { drawRect(xPosition, yPosition - 1, xPosition + width + 1, yPosition + height + 1, 180 << 24); - drawRect(xPosition - 22, yPosition - 1, xPosition, yPosition + children.size() * 21, 180 << 24); + drawRect(xPosition - 22, yPosition - 1 - partsAbove * 21, xPosition, yPosition + (children.size() - partsAbove) * 21, 180 << 24); for (GuiPartChooser child : children) { child.drawButton(mc, x, y); } From 3daee2d1d9bee44e515c39ecec93bc4c91e21b99 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Wed, 20 Jan 2016 00:33:15 +0300 Subject: [PATCH 6/9] Refactoring. Added `allowsDragPlacement` method, currently only used for wires. Split wire/tunnel rendering into separate methods. --- .../client/gui/cad/PlaceHandler.java | 6 +- .../integratedcircuits/cp/CircuitData.java | 4 +- .../integratedcircuits/cp/CircuitPart.java | 5 ++ .../cp/part/PartTunnel.java | 19 ++++++ .../integratedcircuits/cp/part/PartWire.java | 66 ++++++++++++------- .../net/pcb/PacketPCBChangeInput.java | 2 +- 6 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java index 7ebfe4a..11818fe 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java @@ -51,7 +51,7 @@ public void renderCADCursor(GuiCAD parent, double mouseX, double mouseY, int gri CircuitPartRenderer.renderPart(selectedPart, gridX * PART_SIZE, gridY * PART_SIZE); GL11.glPopMatrix(); GL11.glColor3f(1, 1, 1); - } else if (selectedPart.getPart().getClass().equals(PartWire.class)) { + } else if (selectedPart.getPart().allowsDragPlacement()) { PartWire wire = (PartWire) selectedPart.getPart(); switch (wire.getColor(selectedPart.getPos(), selectedPart)) { case 1: @@ -143,7 +143,7 @@ public void onMouseDown(GuiCAD parent, int mx, int my, int button) { if (gridX > 0 && gridY > 0 && gridX < w - 1 && gridY < w - 1 && !GuiScreen.isShiftKeyDown()) { parent.startX = gridX; parent.startY = gridY; - if (selectedPart.getPart().getClass().equals(PartWire.class)) { + if (selectedPart.getPart().allowsDragPlacement()) { parent.drag = true; } } @@ -160,7 +160,7 @@ public void onMouseUp(GuiCAD parent, int mx, int my, int button) { } if (parent.drag) { - if (selectedPart.getPart().getClass().equals(PartWire.class)) { + if (selectedPart.getPart().allowsDragPlacement()) { int id = CircuitPart.getId(selectedPart.getPart()); int state = selectedPart.getState(); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java index 7ab4d33..8d7c91f 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java @@ -156,11 +156,11 @@ private EnumConnectionType[] getAndFixModePerSide() { /** Clears the circuit and sets it up **/ public void clearAllAndSetup(int size) { clearAll(size); - FixIO(); + fixIO(); } /** Sets up the IOBits and clears unused ones. **/ - public void FixIO() { + public void fixIO() { getAndFixModePerSide(); int o = (supportsBundled() ? size / 2 - 8 : 1); // Offset of first IOBit diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java index 7e8f66b..d4fc1f5 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPart.java @@ -289,6 +289,11 @@ public boolean getInput(Vec2 pos, ICircuit parent) { @SideOnly(Side.CLIENT) public abstract void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type); + @SideOnly(Side.CLIENT) + public boolean allowsDragPlacement() { + return false; + } + /** Gets called on a client update */ public void onChanged(Vec2 pos, ICircuit parent, int oldMeta) { scheduleInputChange(pos, parent); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java index 0f9d6fe..4f3859d 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartTunnel.java @@ -1,5 +1,7 @@ package moe.nightfall.vic.integratedcircuits.cp.part; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import moe.nightfall.vic.integratedcircuits.Config; import moe.nightfall.vic.integratedcircuits.Content; import moe.nightfall.vic.integratedcircuits.cp.CircuitData; @@ -136,6 +138,23 @@ public Category getCategory() { return Category.WIRE; } + @Override + @SideOnly(Side.CLIENT) + public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { + Tessellator tes = Tessellator.instance; + + RenderUtils.applyColorIRGBA(tes, Config.colorGreen); + CircuitPartRenderer.addQuad(x, y, 16, 4*16, 16, 16); + + renderViaWire(pos, parent, x, y, type); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean allowsDragPlacement() { + return false; + } + @Override public String getLocalizedName(Vec2 pos, ICircuit parent) { String name = super.getLocalizedName(pos, parent); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java index af4d597..86630f1 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartWire.java @@ -33,19 +33,11 @@ public boolean getOutputToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { return getInput(pos, parent) && !getInputFromSide(pos, parent, side); } - @Override @SideOnly(Side.CLIENT) - // This renders BOTH WIRES AND TUNNELS - public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { + public final void applyWireRenderColor(Vec2 pos, ICircuit parent, CircuitPartRenderer.EnumRenderType type) { int color = this.getColor(pos, parent); - boolean tun = this instanceof PartTunnel; Tessellator tes = Tessellator.instance; - if (tun) { - RenderUtils.applyColorIRGBA(tes, Config.colorGreen); - CircuitPartRenderer.addQuad(x, y, 16, 4*16, 16, 16); - } - if (type == CircuitPartRenderer.EnumRenderType.GUI) { switch (color) { case 1: @@ -69,25 +61,45 @@ public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPar } } else RenderUtils.applyColorIRGBA(tes, Config.colorGreen, 0.4F); + } + + @SideOnly(Side.CLIENT) + // Render wire with a via + public final void renderViaWire(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { + applyWireRenderColor(pos, parent, type); int ty = type == CircuitPartRenderer.EnumRenderType.WORLD_16x ? 3 * 16 : 0; int con = CircuitPartRenderer.checkConnections(pos, parent, this); - if ((con & 12) == 12 && (con & ~12) == 0 && !tun) - CircuitPartRenderer.addQuad(x, y, 6 * 16, ty, 16, 16); - else if ((con & 3) == 3 && (con & ~3) == 0 && !tun) - CircuitPartRenderer.addQuad(x, y, 5 * 16, ty, 16, 16); - else { - if ((con & 8) > 0) - CircuitPartRenderer.addQuad(x, y, 2 * 16, ty, 16, 16); - if ((con & 4) > 0) - CircuitPartRenderer.addQuad(x, y, 4 * 16, ty, 16, 16); - if ((con & 2) > 0) - CircuitPartRenderer.addQuad(x, y, 1 * 16, ty, 16, 16); - if ((con & 1) > 0) - CircuitPartRenderer.addQuad(x, y, 3 * 16, ty, 16, 16); - CircuitPartRenderer.addQuad(x, y, 0, ty, 16, 16); - } + // Connections with nearby gates / wires + if ((con & 8) > 0) + CircuitPartRenderer.addQuad(x, y, 2 * 16, ty, 16, 16); + if ((con & 4) > 0) + CircuitPartRenderer.addQuad(x, y, 4 * 16, ty, 16, 16); + if ((con & 2) > 0) + CircuitPartRenderer.addQuad(x, y, 1 * 16, ty, 16, 16); + if ((con & 1) > 0) + CircuitPartRenderer.addQuad(x, y, 3 * 16, ty, 16, 16); + // The via (circle which looks like "through pcb") + CircuitPartRenderer.addQuad(x, y, 0, ty, 16, 16); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { + int con = CircuitPartRenderer.checkConnections(pos, parent, this); + if (con == 12 || con == 3) { + // Render straight line wire + applyWireRenderColor(pos, parent, type); + + int ty = type == CircuitPartRenderer.EnumRenderType.WORLD_16x ? 3 * 16 : 0; + + if (con == 12) + CircuitPartRenderer.addQuad(x, y, 6 * 16, ty, 16, 16); + else + CircuitPartRenderer.addQuad(x, y, 5 * 16, ty, 16, 16); + } else + renderViaWire(pos, parent, x, y, type); } @Override @@ -112,6 +124,12 @@ public boolean canConnectToSide(Vec2 pos, ICircuit parent, ForgeDirection side) return true; } + @Override + @SideOnly(Side.CLIENT) + public boolean allowsDragPlacement() { + return true; + } + @Override public void getCraftingCost(CraftingAmount cost, CircuitData parent, Vec2 pos) { cost.add(new ItemAmount(Items.redstone, 0.05)); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java b/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java index c2d7aeb..ba47294 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/net/pcb/PacketPCBChangeInput.java @@ -76,7 +76,7 @@ public void process(EntityPlayer player, Side side) { CircuitData data = te.getCircuitData(); data.getProperties().setCon(con); - data.FixIO(); + data.fixIO(); if (input && side == Side.SERVER) { data.updateInput(); From 13eeb15e6389ac4173c4c6b197c4f7660513f7cf Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Wed, 20 Jan 2016 02:43:02 +0300 Subject: [PATCH 7/9] Added ability to mirror transparent latches and disable their outputs. --- .../cp/CircuitPartRenderer.java | 10 ++++- .../cp/part/latch/PartTransparentLatch.java | 35 ++++++++++++++++-- .../textures/gui/sublogicpart.png | Bin 4517 -> 4748 bytes 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPartRenderer.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPartRenderer.java index 961a576..b8fb8a4 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPartRenderer.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitPartRenderer.java @@ -60,7 +60,15 @@ public static void addQuad(double x, double y, double u, double v, double w, dou } public static void addQuad(double x, double y, double u, double v, double w, double h, double rotation) { - addQuad(x, y, u, v, w, h, w, h, 256, 256, rotation); + addQuad(x, y, u, v, w, h, rotation, false, false); + } + + public static void addQuad(double x, double y, double u, double v, double w, double h, double rotation, boolean invX, boolean invY) { + addQuad(x, y, + invX ? u + w : u, invY ? v + h : v, + w, h, + invX ? -w : w, invY ? -h : h, + 256, 256, rotation); } public static void addQuad(double x, double y, double u, double v, double w, double h, double w2, double h2, diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartTransparentLatch.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartTransparentLatch.java index 44c845d..088d39e 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartTransparentLatch.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartTransparentLatch.java @@ -7,10 +7,22 @@ import moe.nightfall.vic.integratedcircuits.cp.part.PartCPGate; import moe.nightfall.vic.integratedcircuits.misc.Vec2; import moe.nightfall.vic.integratedcircuits.misc.PropertyStitcher.BooleanProperty; +import moe.nightfall.vic.integratedcircuits.misc.PropertyStitcher.IntProperty; import net.minecraftforge.common.util.ForgeDirection; public class PartTransparentLatch extends PartCPGate { public final BooleanProperty PROP_OUT = new BooleanProperty("OUT", stitcher); + public final IntProperty PROP_CONFIG = new IntProperty("CONFIG", stitcher, 5); + + @Override + public void onClick(Vec2 pos, ICircuit parent, int button, boolean ctrl) { + if (button == 0 && ctrl) { + cycleProperty(pos, parent, PROP_CONFIG); + scheduleInputChange(pos, parent); + notifyNeighbours(pos, parent); + } + super.onClick(pos, parent, button, ctrl); + } @Override public void onInputChange(Vec2 pos, ICircuit parent) { @@ -19,7 +31,9 @@ public void onInputChange(Vec2 pos, ICircuit parent) { @Override public void onScheduledTick(Vec2 pos, ICircuit parent) { - if (getInputFromSide(pos, parent, toExternal(pos, parent, ForgeDirection.SOUTH))) { + int cfg = getProperty(pos, parent, PROP_CONFIG); + ForgeDirection writeSide = (cfg & 1) == 0 ? ForgeDirection.SOUTH : ForgeDirection.NORTH; + if (getInputFromSide(pos, parent, toExternal(pos, parent, writeSide))) { setProperty(pos, parent, PROP_OUT, getInputFromSide(pos, parent, toExternal(pos, parent, ForgeDirection.WEST))); @@ -30,16 +44,29 @@ public void onScheduledTick(Vec2 pos, ICircuit parent) { @Override public boolean getOutputToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { ForgeDirection s2 = toInternal(pos, parent, side); - if (s2 == ForgeDirection.NORTH || s2 == ForgeDirection.EAST) + int cfg = getProperty(pos, parent, PROP_CONFIG); + if ((s2 == ((cfg & 1) == 0 ? ForgeDirection.NORTH : ForgeDirection.SOUTH) && (cfg & 2) == 0) + || (s2 == ForgeDirection.EAST && (cfg & 4) == 0)) return getProperty(pos, parent, PROP_OUT); return false; } + @Override + public boolean canConnectToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { + ForgeDirection s2 = toInternal(pos, parent, side); + if (s2 == ForgeDirection.WEST) + return true; + int cfg = getProperty(pos, parent, PROP_CONFIG); + if (s2 == ForgeDirection.EAST) + return (cfg & 4) == 0; + return ((cfg & 2) == 0) || (((cfg & 1) == 0) == (s2 == ForgeDirection.SOUTH)); + } + @Override public void renderPart(Vec2 pos, ICircuit parent, double x, double y, CircuitPartRenderer.EnumRenderType type) { CircuitPartRenderer.renderPartGate(pos, parent, this, x, y, type); - - CircuitPartRenderer.addQuad(x, y, 9 * 16, 16, 16, 16, this.getRotation(pos, parent)); + int cfg = getProperty(pos, parent, PROP_CONFIG); + CircuitPartRenderer.addQuad(x, y, 9 * 16, (1 + (cfg / 2)) * 16, 16, 16, this.getRotation(pos, parent), false, (cfg & 1) != 0); } @Override diff --git a/src/main/resources/assets/integratedcircuits/textures/gui/sublogicpart.png b/src/main/resources/assets/integratedcircuits/textures/gui/sublogicpart.png index e2204f03848ecc4973704f682c9641064240d7a1..abd94e5a283f8e64ebb820cda7b238ee294dc3a0 100644 GIT binary patch literal 4748 zcmds4`#aO`|9_Ek=)h3qH0j`&grdYIaw^m)r{s_hh&dmIZFHcV&qYYy4b_O)NHax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ZRw_ykEv1F1TC-KAR5xh9R8>}UTe)NEc)5{PRhV9VJG%jB*hwR0rr9mtA z^7WVpnEOb@X@BG%zTxrx8|>Z0-^30_ub{#2Q&ZYp2)a}(qMxrlN?@M3J-1uX4d;Bh z8p+U@=J;VQV0NF|1Xv>^D9b z9m<0fXMhaz_vl#i#LuA%g|fN%g`7oEm{=xZ=&!AxaqwL><3irRk9|4Vr6dvA*Tpe^ zK)o64@4yIoLg-9cmprXd{%ZXuwKExN_@^|7EjQRgKZO@)^!txuOz&73*4=s-|34dk B+ARP8 From 1ce2ee9903004cac2deb76f50d65c2102d017c76 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Wed, 20 Jan 2016 03:05:22 +0300 Subject: [PATCH 8/9] Added transparent latches to legacy loader Just to be safe, they should "convert" properly anyway. --- .../cp/legacy/LegacyLoader.java | 7 +++++-- ...cyLoader_1_Tunnels.java => LegacyLoader1.java} | 15 ++++++++++++++- ...ader_0_8.java => LegacyLoaderUnversioned.java} | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) rename src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/{LegacyLoader_1_Tunnels.java => LegacyLoader1.java} (77%) rename src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/{LegacyLoader_0_8.java => LegacyLoaderUnversioned.java} (99%) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java index f8b8ef0..569cb35 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader.java @@ -15,8 +15,11 @@ public abstract class LegacyLoader implements Comparable { private static final List legacyLoaders = new ArrayList(); static { - legacyLoaders.add(new LegacyLoader_0_8()); - legacyLoaders.add(new LegacyLoader_1_Tunnels()); + legacyLoaders.add(new LegacyLoaderUnversioned()); + legacyLoaders.add(new LegacyLoader1()); + /* TODO Fix all NBT transforms being done before all Transforms + * before all PostTransforms. Be careful until then. + */ Collections.sort(legacyLoaders); } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader1.java similarity index 77% rename from src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java rename to src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader1.java index 1a4c4f3..90bad23 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_1_Tunnels.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader1.java @@ -14,16 +14,29 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public final class LegacyLoader_1_Tunnels extends LegacyLoader { +public final class LegacyLoader1 extends LegacyLoader { @Override public int getVersion() { return 1; } { + addTransformer(new PartTransparentLatchTransformer(), 18); addTransformer(new PartTunnelTransformer(), 27); } + private static class PartTransparentLatchTransformer extends PartTransformer { + protected final int oldBits = old.allocate(4 + 2 + 1); + protected final int newBits = transformed.allocate(4 + 2 + 1); + protected final int newConfig = transformed.allocate(3); + + @Override + public void transformImpl() { + setInt(newBits, getInt(oldBits)); + setInt(newConfig, 0); + } + } + private static class PartTunnelTransformer extends PartTransformer { // The old PartTunnel property map // PartCPGate: diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_0_8.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoaderUnversioned.java similarity index 99% rename from src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_0_8.java rename to src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoaderUnversioned.java index 03fa229..bd6441b 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoader_0_8.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/legacy/LegacyLoaderUnversioned.java @@ -14,7 +14,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public final class LegacyLoader_0_8 extends LegacyLoader { +public final class LegacyLoaderUnversioned extends LegacyLoader { @Override public int getVersion() { return 0; From 869ac47606c2418fd070b92a8d7d89db3befe1b9 Mon Sep 17 00:00:00 2001 From: Evgeniy Zhabotinsky Date: Wed, 3 Feb 2016 13:43:04 +0300 Subject: [PATCH 9/9] Allow replacing tunnels by tunnels. Even with the same color (clears connection). --- .../vic/integratedcircuits/client/gui/cad/PlaceHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java index 11818fe..572d2ae 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/cad/PlaceHandler.java @@ -11,6 +11,7 @@ import moe.nightfall.vic.integratedcircuits.cp.part.PartCPGate; import moe.nightfall.vic.integratedcircuits.cp.part.PartNull; import moe.nightfall.vic.integratedcircuits.cp.part.PartWire; +import moe.nightfall.vic.integratedcircuits.cp.part.PartTunnel; import moe.nightfall.vic.integratedcircuits.misc.RenderUtils; import moe.nightfall.vic.integratedcircuits.misc.Vec2; import moe.nightfall.vic.integratedcircuits.net.pcb.PacketPCBCache; @@ -190,7 +191,7 @@ else if (parent.startX > parent.endX) int newID = CircuitPart.getId(selectedPart.getPart()); Vec2 pos = new Vec2(parent.startX, parent.startY); - if (newID != parent.getCircuitData().getID(pos)) { + if (newID != parent.getCircuitData().getID(pos) || newID == CircuitPart.getId(PartTunnel.class)) { CommonProxy.networkWrapper.sendToServer(new PacketPCBChangePart(!(selectedPart.getPart() instanceof PartNull), parent.tileentity.xCoord, parent.tileentity.yCoord, parent.tileentity.zCoord).add(pos, newID, selectedPart.getState())); } }