Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…its.git into dev
  • Loading branch information
Victorious3 committed Aug 9, 2015
2 parents fdc6c7e + 0fc19a6 commit 7108d5b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -101,7 +101,7 @@ public List<String> 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")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,29 @@ 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();
}

@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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,21 @@ 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) {
return (out[MiscUtils.getSide(dir)] & 1 << frequency) != 0;
}

@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();
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/assets/integratedcircuits/lang/PT_BR.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7108d5b

Please sign in to comment.