diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/GuiAssembler.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/GuiAssembler.java index a7f386a..da0f908 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/GuiAssembler.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/GuiAssembler.java @@ -210,12 +210,12 @@ protected void drawGuiContainerBackgroundLayer(float par1, int x, int y) { } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { + public void drawScreen(int x, int y, float f) { + super.drawScreen(x, y, f); if (hoverable != null) - drawHoveringText(hoverable.getHoverInformation(), x - guiLeft, y - guiTop, this.fontRendererObj); + drawHoveringText(hoverable.getHoverInformation(), x, y, this.fontRendererObj); if (renderItemHover) - drawCreativeTabHoveringText(te.craftingSupply.getInsufficient().convertToItemStack().getDisplayName(), x - - guiLeft, y - guiTop); + drawCreativeTabHoveringText(te.craftingSupply.getInsufficient().convertToItemStack().getDisplayName(), x, y); RenderHelper.enableGUIStandardItemLighting(); } 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 5f8ea4e..4ad1854 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 @@ -51,7 +51,7 @@ public void drawButton(Minecraft mc, int x, int y) { ForgeDirection dir = MiscUtils.getDirection(side); isActive = te.getCircuitData().getProperties().getModeAtSide(side) != EnumConnectionType.SIMPLE || color == 0; - boolean isPowered = isActive && te.getInputFromSide(dir, color) || te.getOutputToSide(dir, color); + boolean isPowered = isActive && te.getExternalInputFromSide(dir, color) || te.getOutputToSide(dir, color); if (isActive) { if (isPowered) @@ -85,7 +85,7 @@ public boolean mousePressed(Minecraft mc, int par1, int par2) { boolean b = super.mousePressed(mc, par1, par2) && !parent.blockMouseInput; if (b) { ForgeDirection dir = MiscUtils.getDirection(side); - te.setInputFromSide(dir, color, !te.getInputFromSide(dir, color)); + te.setExternalInputFromSide(dir, color, !te.getExternalInputFromSide(dir, color)); } return b; } @@ -101,7 +101,7 @@ public List getHoverInformation() { if (isActive) { text.add("I: " + I18n.format("gui.integratedcircuits.cad.mode." - + (te.getInputFromSide(dir, color) ? "high" : "low"))); + + (te.getExternalInputFromSide(dir, color) ? "high" : "low"))); text.add("O: " + I18n.format("gui.integratedcircuits.cad.mode." + (te.getOutputToSide(dir, color) ? "high" : "low"))); 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 d81faf2..c725fca 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java @@ -196,10 +196,10 @@ public void updateOutput() { PartIOBit io3 = (PartIOBit) getPart(pos3); PartIOBit io4 = (PartIOBit) getPart(pos4); - io1.onInputChange(pos1, parent); - io2.onInputChange(pos2, parent); - io3.onInputChange(pos3, parent); - io4.onInputChange(pos4, parent); + io1.updateExternalOutput(pos1, parent); + io2.updateExternalOutput(pos2, parent); + io3.updateExternalOutput(pos3, parent); + io4.updateExternalOutput(pos4, parent); } } 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/LegacyLoader_0_8.java index b7786ec..03fa229 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/LegacyLoader_0_8.java @@ -323,7 +323,8 @@ private static class PartSequencerTransformer extends PartDelayedActionTransform @Override public void transformImpl() { super.transformImpl(); - setInt(newDelay, getInt(oldDelay)); + setInt(newDelay, getInt(Math.min(oldDelay + 2, 255))); + // +2 is to keep total period the same (if possible) setInt(newOutSide, getInt(oldOutSide)); // Start new delay if sequencer was stopped. diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartIOBit.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartIOBit.java index 2d0cd0e..deb45e6 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartIOBit.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/PartIOBit.java @@ -56,6 +56,12 @@ public final void setFrequency(Vec2 pos, ICircuit parent, int frequency) { setProperty(pos, parent, PROP_FREQUENCY, frequency); } + public final void updateExternalOutput(Vec2 pos, ICircuit parent) { + ForgeDirection dir = MiscUtils.getDirection(getRotation(pos, parent)); + parent.setOutputToSide(dir, getFrequency(pos, parent), + getInputFromSide(pos, parent, dir.getOpposite())); + } + public boolean canConnectToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { ForgeDirection dir = MiscUtils.getDirection(getRotation(pos, parent)); return side == dir.getOpposite(); @@ -63,12 +69,16 @@ public boolean canConnectToSide(Vec2 pos, ICircuit parent, ForgeDirection side) @Override public void onInputChange(Vec2 pos, ICircuit parent) { - ForgeDirection dir = MiscUtils.getDirection(getRotation(pos, parent)); - parent.setOutputToSide(dir, getFrequency(pos, parent), - getInputFromSide(pos, parent, dir.getOpposite())); + scheduleTick(pos, parent); notifyNeighbours(pos, parent); } + @Override + public void onScheduledTick(Vec2 pos, ICircuit parent) { + updateExternalOutput(pos, parent); + notifyNeighbours(pos, parent); // Implicit updateExternalInput + } + @Override public boolean getOutputToSide(Vec2 pos, ICircuit parent, ForgeDirection side) { ForgeDirection dir = MiscUtils.getDirection(getRotation(pos, parent)); diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartRSLatch.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartRSLatch.java index 9c258d0..21e628b 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartRSLatch.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/part/latch/PartRSLatch.java @@ -10,6 +10,7 @@ import moe.nightfall.vic.integratedcircuits.misc.Vec2; import moe.nightfall.vic.integratedcircuits.misc.PropertyStitcher.IntProperty; import moe.nightfall.vic.integratedcircuits.misc.PropertyStitcher.BooleanProperty; +import moe.nightfall.vic.integratedcircuits.tile.TileEntityCAD; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; @@ -65,11 +66,18 @@ public void onScheduledTick(Vec2 pos, ICircuit parent) { if (in1 != in2) setProperty(pos, parent, PROP_STATE, in1 ? 1 : 2); else if (in1 || getProperty(pos, parent, PROP_CHECK)) { - setProperty(pos, parent, PROP_STATE, 0); - if (!in1) // Inputs shorted. Wait until player fixes it. - scheduleTick(pos, parent); + // Either both inputs are high + // or they are shorted by unpowered wire in "special" mode. + setProperty(pos, parent, PROP_STATE, 0); // Switch to broken state + if (!in1 && !(parent instanceof TileEntityCAD)) { + // Inputs shorted and circuit is ticked outside CAD. + // It will never ever be edited again. + // So just keep this RS latch permanently broken. + notifyNeighbours(pos, parent); + return; + } } else if (getProperty(pos, parent, PROP_STATE) == 0) - // Both inputs off, still in broken state. + // Both inputs off, still in broken state. Switch to "default". // Vanilla and P:R RS latches work the same way. setProperty(pos, parent, PROP_STATE, 1); setProperty(pos, parent, PROP_CHECK, false); 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 7b22c63..65a4410 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/tile/BlockSocket.java @@ -81,8 +81,16 @@ public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) bounds.setBlockBounds(this); } + public AxisAlignedBB getStatelessBoundingBox(World world, int x, int y, int z) { + return null; + } + @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + if (world.getBlock(x, y, z) != this) { // BUGFIX: mojang randomly calls this method for blocks not in the world! + return getStatelessBoundingBox(world, x, y, z); // see: net.minecraft.item.ItemBlock.func_150936_a (1.7.10 srg) + } + setBlockBoundsBasedOnState(world, x, y, z); return super.getCollisionBoundingBoxFromPool(world, x, y, z); } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/tile/TileEntityCAD.java b/src/main/java/moe/nightfall/vic/integratedcircuits/tile/TileEntityCAD.java index c6c4bb7..4afed93 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/tile/TileEntityCAD.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/tile/TileEntityCAD.java @@ -107,9 +107,13 @@ public void writeToNBT(NBTTagCompound compound) { compound.setTag("floppyStack", stackCompound); } + public final boolean getExternalInputFromSide(ForgeDirection dir, int frequency) { + return (in[MiscUtils.getSide(dir)] & 1 << frequency) != 0; + } + @Override public boolean getInputFromSide(ForgeDirection dir, int frequency) { - return (in[MiscUtils.getSide(dir)] & 1 << frequency) != 0; + return getExternalInputFromSide(dir, frequency) && !getOutputToSide(dir, frequency); } public boolean getOutputToSide(ForgeDirection dir, int frequency) { @@ -117,7 +121,7 @@ public boolean getOutputToSide(ForgeDirection dir, int frequency) { } @SideOnly(Side.CLIENT) - public void setInputFromSide(ForgeDirection dir, int frequency, boolean output) { + public final void setExternalInputFromSide(ForgeDirection dir, int frequency, boolean output) { EnumConnectionType mode = circuitData.getProperties().getModeAtSide(MiscUtils.getSide(dir)); if (mode != EnumConnectionType.SIMPLE || frequency == 0) { int[] i = this.in.clone(); diff --git a/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang b/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang index 34d0681..b606239 100644 --- a/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang +++ b/src/main/resources/assets/integratedcircuits/lang/PT_BR.lang @@ -42,11 +42,12 @@ part.integratedcircuits.norgate.name=Porta NÃO OU part.integratedcircuits.xnorgate.name=Porta NÃO OU exclusivo part.integratedcircuits.notgate.name=Porta NÃO +#those names are based on the behaviour as you can see there https://pt.wikipedia.org/wiki/Flip-flop part.integratedcircuits.togglelatch.name=Flip-flop T part.integratedcircuits.rslatch.name=Flip-flop S-R part.integratedcircuits.rslatch.mode=Modo part.integratedcircuits.rslatch.mirrored=Espelhado -part.integratedcircuits.transparentlatch.name=Flip-flop Transparente //those names are based on the behaviour as you can see there https://pt.wikipedia.org/wiki/Flip-flop +part.integratedcircuits.transparentlatch.name=Flip-flop Transparente part.integratedcircuits.timer.name=Temporizador part.integratedcircuits.sequencer.name=Sequenciador @@ -100,13 +101,14 @@ gui.integratedcircuits.7segment.master=Mestre gui.integratedcircuits.7segment.slave=Escravo gui.integratedcircuits.7segment.mode=Modo: +#as these names are used in programming, and anyone ppl that will use this mod will need to have a basic on this, i prefer let this as it is gui.integratedcircuits.7segment.mode.simple=Simples gui.integratedcircuits.7segment.mode.analog=Analogico gui.integratedcircuits.7segment.mode.short.signed=Signed Short gui.integratedcircuits.7segment.mode.short.unsigned=Unsigned Short gui.integratedcircuits.7segment.mode.float=Signed Float gui.integratedcircuits.7segment.mode.binary=Binary String -gui.integratedcircuits.7segment.mode.manual=Manual //as these names are used in programming, and anyone ppl that will use this mod will need to have a basic on this, i prefer let this as it is +gui.integratedcircuits.7segment.mode.manual=Manual gui.integratedcircuits.7segment.mode.simple.tooltip=Um sinal digital de redstone:%n§8§oVerdadeiro ou Falso. gui.integratedcircuits.7segment.mode.analog.tooltip=Um sinal analogico de redstone:%n§8§ode 0 a F.