diff --git a/gradle.properties b/gradle.properties index b20bb07..bc0d718 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,6 @@ qmlVersion = 0.1.99 ocVersion = 1.5.13+ wailaVersion = 1.5.9 bluepowerVersion = 0.2.948 -projectredVersion = 4.7.0pre9.92 +projectredVersion = 4.7.0pre10.93 buildcraftVersion = 7.1.+ redlogicVersion = 59.1.7 diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/Gui7Segment.java b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/Gui7Segment.java index 6d6f5d1..05fa270 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/Gui7Segment.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/client/gui/Gui7Segment.java @@ -1,22 +1,18 @@ package moe.nightfall.vic.integratedcircuits.client.gui; -import java.util.Arrays; - -import moe.nightfall.vic.integratedcircuits.client.Gate7SegmentRenderer; -import moe.nightfall.vic.integratedcircuits.client.Resources; -import moe.nightfall.vic.integratedcircuits.client.gui.GuiInterfaces.IHoverable; -import moe.nightfall.vic.integratedcircuits.client.gui.GuiInterfaces.IHoverableHandler; -import moe.nightfall.vic.integratedcircuits.client.gui.component.GuiCheckBoxExt; -import moe.nightfall.vic.integratedcircuits.client.gui.component.GuiDropdown; -import moe.nightfall.vic.integratedcircuits.gate.Gate7Segment; -import moe.nightfall.vic.integratedcircuits.net.Packet7SegmentChangeMode; -import moe.nightfall.vic.integratedcircuits.proxy.CommonProxy; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; +import java.util.*; + +import org.lwjgl.input.*; +import org.lwjgl.opengl.*; + +import moe.nightfall.vic.integratedcircuits.client.*; +import moe.nightfall.vic.integratedcircuits.client.gui.GuiInterfaces.*; +import moe.nightfall.vic.integratedcircuits.client.gui.component.*; +import moe.nightfall.vic.integratedcircuits.gate.*; +import moe.nightfall.vic.integratedcircuits.net.*; +import moe.nightfall.vic.integratedcircuits.proxy.*; +import net.minecraft.client.gui.*; +import net.minecraft.client.resources.*; public class Gui7Segment extends GuiScreen implements IHoverableHandler { private Gate7Segment part; @@ -61,14 +57,18 @@ public void initGui() { I18n.format("gui.integratedcircuits.7segment.mode.short.unsigned"), I18n.format("gui.integratedcircuits.7segment.mode.float"), I18n.format("gui.integratedcircuits.7segment.mode.binary"), - I18n.format("gui.integratedcircuits.7segment.mode.manual")), this).setTooltips(Arrays.asList( + I18n.format("gui.integratedcircuits.7segment.mode.manual"), + I18n.format("gui.integratedcircuits.7segment.mode.int.signed"), + I18n.format("gui.integratedcircuits.7segment.mode.int.unsigned")), this).setTooltips(Arrays.asList( I18n.format("gui.integratedcircuits.7segment.mode.simple.tooltip"), I18n.format("gui.integratedcircuits.7segment.mode.analog.tooltip"), I18n.format("gui.integratedcircuits.7segment.mode.short.signed.tooltip"), I18n.format("gui.integratedcircuits.7segment.mode.short.unsigned.tooltip"), I18n.format("gui.integratedcircuits.7segment.mode.float.tooltip"), I18n.format("gui.integratedcircuits.7segment.mode.binary.tooltip"), - I18n.format("gui.integratedcircuits.7segment.mode.manual.tooltip"))))); + I18n.format("gui.integratedcircuits.7segment.mode.manual.tooltip"), + I18n.format("gui.integratedcircuits.7segment.mode.int.signed.tooltip"), + I18n.format("gui.integratedcircuits.7segment.mode.int.unsigned.tooltip"))))); refreshUI(); } @@ -150,4 +150,4 @@ protected void keyTyped(char ch, int keycode) { public void setCurrentItem(IHoverable hoverable) { this.hoverable = hoverable; } -} +} \ No newline at end of file diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/gate/Gate7Segment.java b/src/main/java/moe/nightfall/vic/integratedcircuits/gate/Gate7Segment.java index 0493467..1efb515 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/gate/Gate7Segment.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/gate/Gate7Segment.java @@ -20,6 +20,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagIntArray; import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.EnumConnectionState; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.Constants.NBT; @@ -34,13 +35,14 @@ import com.google.common.collect.Lists; public class Gate7Segment extends Gate { - + private final Cuboid6 dimensions = new Cuboid6(2, 0, 1, 14, 3, 15); - + public int digit = NUMBERS[0]; public int color; public boolean isSlave; public boolean hasSlaves; + public boolean hasThreeBuses = true; public int mode = MODE_SIMPLE; public BlockCoord parent; @@ -48,12 +50,12 @@ public class Gate7Segment extends Gate { // TODO Relative positions, will break upon moving like this public ArrayList slaves = Lists.newArrayList(); - // 0 - // -- + // 0 + // -- // 5|6 |1 - // -- + // -- // 4|3 |2 - // -- # 7 + // -- # 7 public static final byte[] NUMBERS = { 63, 6, 91, 79, 102, 109, 125, 7, 127, 111, 119, 124, 57, 94, 121, 113 }; // 0-F // In reverse order @@ -73,6 +75,8 @@ public class Gate7Segment extends Gate { public static final int MODE_FLOAT = 4; public static final int MODE_BINARY_STRING = 5; public static final int MODE_MANUAL = 6; + public static final int MODE_INT_SIGNED = 7; + public static final int MODE_INT_UNSIGNED = 8; @Override public void preparePlacement(EntityPlayer player, ItemStack stack) { @@ -94,6 +98,7 @@ public void onAdded() { return; isSlave = false; + int abs = Rotation.rotateSide(provider.getSide(), provider.getRotationAbs(3)); BlockCoord pos = provider.getPos(); BlockCoord pos2 = pos.copy(); @@ -195,9 +200,7 @@ public Gate7Segment getSegment(BlockCoord crd) { return null; } - private void updateSlaves() { - if (provider.getWorld().isRemote) - return; + private void updateSlavesDefault() { int input = 0; @@ -223,10 +226,12 @@ private void updateSlaves() { int length = 16; for (byte[] in : provider.getInput()) { + int i2 = 0; for (int i = 0; i < 16; i++) i2 |= (in[i] != 0 ? 1 : 0) << i; input |= i2; + } boolean outOfBounds = false; @@ -240,7 +245,7 @@ private void updateSlaves() { if (mode == MODE_MANUAL) { writeDigits(null); - writeDigit(input & 255); + writeDigit((input & 255)); return; } else if (mode == MODE_FLOAT) { float conv = MiscUtils.toBinary16Float(input); @@ -279,7 +284,6 @@ else if (slaves.size() > 2) dispString = Integer.toBinaryString(input); else dispString = String.valueOf(input); - int size = dispString.length() - 1; if (size > slaves.size() - (isSigned() ? 1 : 0)) outOfBounds = true; @@ -302,6 +306,73 @@ else if (slaves.size() > 2) } } + private void updateSlavesSplit() { + boolean sign = false; + byte[][] provIn = provider.getInput(); + + StringBuilder sb = new StringBuilder(); + + for (int i = 15; i >= 0; i--) { + char b = (provIn[2][i] != 0 ? '1' : '0'); + sb.append(b); + } + for (int i = 15; i >= 0; i--) { + char b = (provIn[3][i] != 0 ? '1' : '0'); + sb.append(b); + } + + long input = Long.parseLong(sb.toString(), 2); + + boolean outOfBounds = false; + int decimalDot = -1; + String dispString = ""; + + if (isSigned()) { + sign = (input & (1 << 31)) != 0; + input &= 0x7FFFFFFF; + } + + if (input < 0) + dispString = "0"; + else { + dispString = Long.toString(input); + } + + int size = dispString.length() - 1; + if (size > slaves.size() - (isSigned() ? 1 : 0)) + outOfBounds = true; + + dispString = StringUtils.reverse(dispString); + for (int i = 0; i <= slaves.size(); i++) { + int decimal = i < dispString.length() ? Integer.valueOf(String.valueOf(dispString.charAt(i))) : 0; + Gate7Segment slave = this; + if (i > 0) { + BlockCoord bc = slaves.get(i - 1); + slave = getSegment(bc); + } + if (slave != null) { + if (i == slaves.size() && isSigned()) + slave.writeDigit(sign ? SIGN : 0); + else + slave.writeDigit(outOfBounds ? SIGN : NUMBERS[decimal] | (decimalDot == i ? DOT : 0)); + } + } + + } + + private void updateSlaves() { + if (provider.getWorld().isRemote) + return; + + if (mode != MODE_INT_SIGNED && mode != MODE_INT_UNSIGNED) { + hasThreeBuses = true; + updateSlavesDefault(); + } else { + hasThreeBuses = false; + updateSlavesSplit(); + } + } + private void writeDigits(byte[] digits) { for (int i = 0; i <= slaves.size(); i++) { Gate7Segment slave = this; @@ -323,7 +394,7 @@ private void writeDigit(int digit) { } private boolean isSigned() { - return mode == MODE_SHORT_SIGNED || mode == MODE_FLOAT; + return mode == MODE_SHORT_SIGNED || mode == MODE_FLOAT || mode == MODE_INT_SIGNED; } private void sendChangesToClient() { @@ -410,9 +481,17 @@ public ItemStack getItemStack() { return new ItemStack(Content.item7Segment, 1, color); } + public EnumConnectionType getSplitConnectionTypeAtSide(int side) { + return (side == 2 || side == 3) ? EnumConnectionType.BUNDLED : EnumConnectionType.NONE; + } + @Override public EnumConnectionType getConnectionTypeAtSide(int side) { - return isSlave || (hasSlaves && side == 1) ? EnumConnectionType.NONE : mode == MODE_SIMPLE ? EnumConnectionType.SIMPLE : mode == MODE_ANALOG ? EnumConnectionType.ANALOG : EnumConnectionType.BUNDLED; + if (mode == MODE_INT_SIGNED || mode == MODE_INT_UNSIGNED) + return getSplitConnectionTypeAtSide(side); + return isSlave || (hasSlaves && side == 1) ? EnumConnectionType.NONE + : mode == MODE_SIMPLE ? EnumConnectionType.SIMPLE + : mode == MODE_ANALOG ? EnumConnectionType.ANALOG : EnumConnectionType.BUNDLED; } @Override diff --git a/src/main/resources/assets/integratedcircuits/lang/en_US.lang b/src/main/resources/assets/integratedcircuits/lang/en_US.lang index 09d7da2..c820c6d 100644 --- a/src/main/resources/assets/integratedcircuits/lang/en_US.lang +++ b/src/main/resources/assets/integratedcircuits/lang/en_US.lang @@ -125,6 +125,8 @@ gui.integratedcircuits.7segment.mode.simple=Simple gui.integratedcircuits.7segment.mode.analog=Analog gui.integratedcircuits.7segment.mode.short.signed=Signed Short gui.integratedcircuits.7segment.mode.short.unsigned=Unsigned Short +gui.integratedcircuits.7segment.mode.int.signed=Signed Int +gui.integratedcircuits.7segment.mode.int.unsigned=Unsigned Int gui.integratedcircuits.7segment.mode.float=Signed Float gui.integratedcircuits.7segment.mode.binary=Binary String gui.integratedcircuits.7segment.mode.manual=Manual @@ -133,6 +135,8 @@ gui.integratedcircuits.7segment.mode.simple.tooltip=A digital redstone signal:%n gui.integratedcircuits.7segment.mode.analog.tooltip=An analog redstone signal:%n§8§oFrom 0 to F. gui.integratedcircuits.7segment.mode.short.signed.tooltip=Parses a bundled signal as%nsigned 16 bit short:%n§8§oFrom -32768 to 32768. gui.integratedcircuits.7segment.mode.short.unsigned.tooltip=Parses a bundled signal as%nunsigned 16 bit short:%n§8§oFrom 0 to 65535. +gui.integratedcircuits.7segment.mode.int.signed.tooltip=Parses a bundled signal as%nsigned 32 bit int:%n§8§oFrom -2147483647 to 2147483647%n§8§oTop - upper 16 bits, Right - lower 16 bits. +gui.integratedcircuits.7segment.mode.int.unsigned.tooltip=Parses a bundled signal as%nunsigned 32 bit int:%n§8§oFrom 0 to 4294967295%n§8§oTop - upper 16 bits, Right - lower 16 bits. gui.integratedcircuits.7segment.mode.float.tooltip=Parses a bundled signal as%n16 bit floating-point (binary16):%n§8§oFrom -122880 to 122880. gui.integratedcircuits.7segment.mode.binary.tooltip=Outputs a bundled signal%nby its binary digits. gui.integratedcircuits.7segment.mode.manual.tooltip=Allows to modify the individual%nsegments with a bundled signal. diff --git a/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang b/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang index 125878a..291509b 100644 --- a/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang +++ b/src/main/resources/assets/integratedcircuits/lang/ru_RU.lang @@ -102,8 +102,10 @@ gui.integratedcircuits.7segment.mode=Режим: gui.integratedcircuits.7segment.mode.simple=Простой gui.integratedcircuits.7segment.mode.analog=Аналоговый -gui.integratedcircuits.7segment.mode.short.signed=Знаковое целое -gui.integratedcircuits.7segment.mode.short.unsigned=Беззнаковое целое +gui.integratedcircuits.7segment.mode.short.signed=Знаковое короткое целое +gui.integratedcircuits.7segment.mode.short.unsigned=Беззнаковое короткое целое +gui.integratedcircuits.7segment.mode.int.signed=Знаковое целое +gui.integratedcircuits.7segment.mode.int.unsigned=Беззнаковое целое gui.integratedcircuits.7segment.mode.float=С плавающей точкой gui.integratedcircuits.7segment.mode.binary=Двоичный gui.integratedcircuits.7segment.mode.manual=Ручной @@ -112,6 +114,8 @@ gui.integratedcircuits.7segment.mode.simple.tooltip=Цифровой сигна gui.integratedcircuits.7segment.mode.analog.tooltip=Аналоговый сигнал красного камня:%n§8§oОт 0 до F. gui.integratedcircuits.7segment.mode.short.signed.tooltip=Выводит сигнал с кабеля как%nзнаковое 16-битное целое:%n§8§oОт -32768 до 32767. gui.integratedcircuits.7segment.mode.short.unsigned.tooltip=Выводит сигнал с кабеля как%nбеззнаковое 16-битное целое:%n§8§oОт 0 до 65535. +gui.integratedcircuits.7segment.mode.short.signed.tooltip=Выводит сигнал с кабеля как%nзнаковое 32-битное целое:%n§8§oОт -2147483647 до 2147483647. +gui.integratedcircuits.7segment.mode.short.unsigned.tooltip=Выводит сигнал с кабеля как%nбеззнаковое 32-битное целое:%n§8§oОт 0 до 4294967295. gui.integratedcircuits.7segment.mode.float.tooltip=Выводит сигнал с кабеля как%n16-битное число с плавающей запятой:%n§8§oОт 0,000061 до 65504,%n§8§oпри точности 3,3 десятичных цифры. gui.integratedcircuits.7segment.mode.binary.tooltip=Выводит сигнал с кабеля побитово. gui.integratedcircuits.7segment.mode.manual.tooltip=Каждый сегмент управляется%nсвоим сигналом с кабеля.