aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorRyan Nasers <42074409+Cardinalstars@users.noreply.github.com>2024-08-05 03:30:58 -0500
committerGitHub <noreply@github.com>2024-08-05 15:30:58 +0700
commit1ab7b9dbcbf375ceff1449502acd0f873f2da51a (patch)
tree0b68625e6e1ab655ca6892272211fb4bb4a79cd1 /src/main/java
parent5c9c4000c6130bd44ad43204dd6220dcda401c10 (diff)
downloadGT5-Unofficial-1ab7b9dbcbf375ceff1449502acd0f873f2da51a.tar.gz
GT5-Unofficial-1ab7b9dbcbf375ceff1449502acd0f873f2da51a.tar.bz2
GT5-Unofficial-1ab7b9dbcbf375ceff1449502acd0f873f2da51a.zip
Adding some stuff I removed long ago (#2702)
* Adding back in stuff I removed * Fixing connections * Idk what this was * Spotless --------- Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Machines.java5
-rw-r--r--src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java10
-rw-r--r--src/main/java/gtPlusPlus/core/lib/CORE.java1
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java7
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java32
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java111
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java205
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java659
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java73
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java139
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java54
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRedstoneButtonPanel.java16
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRedstoneCircuitBlock.java17
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRedstoneLamp.java16
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRedstoneStrengthDisplay.java21
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRedstoneStrengthScale.java17
16 files changed, 1380 insertions, 3 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
index 3d24799746..dad96c9222 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
@@ -53,6 +53,7 @@ import gregtech.api.util.GT_Utility;
import gregtech.common.covers.CoverInfo;
import gregtech.common.render.GT_Renderer_Block;
import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest;
+import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneBase;
@Optional.Interface(iface = "com.cricketcraft.chisel.api.IFacade", modid = "ChiselAPI")
public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlock, ITileEntityProvider, IFacade {
@@ -169,8 +170,8 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
default -> ForgeDirection.UNKNOWN;
};
final TileEntity machineEntity = aWorld.getTileEntity(aX, aY, aZ);
- return machineEntity instanceof CoverableTileEntity cte && cte.getCoverInfoAtSide(forgeSide)
- .getCoverID() != 0;
+ return machineEntity instanceof BaseMetaTileEntity bmte && (bmte.getCoverInfoAtSide(forgeSide)
+ .getCoverID() != 0 || bmte.getMetaTileEntity() instanceof GT_MetaTileEntity_RedstoneBase);
}
@Override
diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
index 90373e2c4c..8e780c724e 100644
--- a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
+++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
@@ -84,6 +84,11 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPollutionDevices;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerSubStation;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechQuantumForceTransformer;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRTG;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRedstoneButtonPanel;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRedstoneCircuitBlock;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRedstoneLamp;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRedstoneStrengthDisplay;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRedstoneStrengthScale;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRocketFuelGenerator;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSemiFluidgenerators;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSimpleWasher;
@@ -180,6 +185,11 @@ public class COMPAT_HANDLER {
GregtechIndustrialRockBreaker.run();
GregtechIndustrialChisel.run();
GregtechIndustrialFluidHeater.run();
+ GregtechRedstoneButtonPanel.run();
+ GregtechRedstoneCircuitBlock.run();
+ GregtechRedstoneLamp.run();
+ GregtechRedstoneStrengthDisplay.run();
+ GregtechRedstoneStrengthScale.run();
}
// InterMod
diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java
index 088923895d..535a3f0821 100644
--- a/src/main/java/gtPlusPlus/core/lib/CORE.java
+++ b/src/main/java/gtPlusPlus/core/lib/CORE.java
@@ -106,6 +106,7 @@ public class CORE {
public static boolean enableMachine_Pollution = true;
public static boolean enableCustom_Pipes = true;
public static boolean enableCustom_Cables = true;
+ public static boolean enableMachine_RedstoneBlocks = true;
// Multiblocks
public static boolean enableMultiblock_AlloyBlastSmelter = true;
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
index 930d34d10d..e62695c0b5 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
@@ -825,7 +825,12 @@ public enum GregtechItemList implements GregtechItemContainer {
SimpleDustWasher_IV,
SimpleDustWasher_ZPM,
- ;
+ // Redstone Utilities
+ RedstoneButtonPanel,
+ RedstoneCircuitBlock,
+ RedstoneLamp,
+ RedstoneStrengthDisplay,
+ RedstoneStrengthScale;
public static final GregtechItemList[] DYE_ONLY_ITEMS = { Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV };
private ItemStack mStack;
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
index 743cd0b85b..4025668966 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
@@ -239,6 +239,38 @@ public class TexturesGtBlock {
"TileEntities/MACHINE_CASING_GRINDING_FACTORY");
public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION");
+ // Redstone blocks
+ public static final CustomIcon Casing_Redstone_Top_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_top_redstone_off");
+ public static final CustomIcon Casing_Redstone_Top_Main_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_top_redstone_main_off");
+ public static final CustomIcon Casing_Redstone_Top_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_top_redstone_on");
+ public static final CustomIcon Casing_Redstone_Top_Main_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_top_redstone_main_on");
+
+ public static final CustomIcon Casing_Redstone_Side_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_side_redstone_off");
+ public static final CustomIcon Casing_Redstone_Side_Main_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_side_redstone_main_off");
+ public static final CustomIcon Casing_Redstone_Side_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_side_redstone_on");
+ public static final CustomIcon Casing_Redstone_Side_Main_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_side_redstone_main_on");
+
+ public static final CustomIcon Casing_Redstone_Bottom_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_bottom_redstone_off");
+ public static final CustomIcon Casing_Redstone_Bottom_Main_Off = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_bottom_redstone_main_off");
+ public static final CustomIcon Casing_Redstone_Bottom_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_bottom_redstone_on");
+ public static final CustomIcon Casing_Redstone_Bottom_Main_On = new CustomIcon(
+ "TileEntities/gt4/redstone/machine_bottom_redstone_main_on");
+
+ public static final CustomIcon Casing_InventoryManagaer_Red = new CustomIcon("TileEntities/gt4/OVERLAY_RED");
+ public static final CustomIcon Casing_InventoryManagaer_Red_Redstone = new CustomIcon(
+ "TileEntities/gt4/OVERLAY_RED_REDSTONE");
+
// Custom Pipes
public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1");
public static final CustomIcon TEXTURE_PIPE_GENERIC = new CustomIcon("iconsets/MACHINE_CASING_PIPE_GENERIC");
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java
new file mode 100644
index 0000000000..ee6ccff4b1
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java
@@ -0,0 +1,111 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.redstone;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.objects.GT_ItemStack;
+import gtPlusPlus.core.lib.CORE;
+
+public abstract class GT_MetaTileEntity_RedstoneBase extends GT_MetaTileEntity_TieredMachineBlock {
+
+ protected int mOpenerCount;
+
+ public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount,
+ String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_RedstoneBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount,
+ String[] aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_RedstoneBase(String aName, int aTier, int aInvSlotCount, String[] aDescription,
+ ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ @Override
+ public final boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) {
+ return side != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public final boolean isValidSlot(int aIndex) {
+ return false;
+ }
+
+ @Override
+ public final boolean isFacingValid(ForgeDirection facing) {
+ return true;
+ }
+
+ @Override
+ public final boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public abstract void saveNBTData(NBTTagCompound aNBT);
+
+ @Override
+ public abstract void loadNBTData(NBTTagCompound aNBT);
+
+ @Override
+ public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ return false;
+ }
+
+ @Override
+ public final void onOpenGUI() {
+ super.onOpenGUI();
+ mOpenerCount++;
+ }
+
+ @Override
+ public final void onCloseGUI() {
+ super.onCloseGUI();
+ mOpenerCount--;
+ }
+
+ public boolean hasRedstoneSignal() {
+ if (getBaseMetaTileEntity().getStrongestRedstone() > 0) {
+ return true;
+ }
+ for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ if (getBaseMetaTileEntity().getOutputRedstoneSignal(side) > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side,
+ ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side,
+ ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public String[] getDescription() {
+ return ArrayUtils.add(this.mDescriptionArray, CORE.GT_Tooltip.get());
+ }
+}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java
new file mode 100644
index 0000000000..174a13d3c8
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java
@@ -0,0 +1,205 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.redstone;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.objects.GT_RenderedTexture;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
+
+public class GT_MetaTileEntity_RedstoneButtonPanel extends GT_MetaTileEntity_RedstoneBase {
+
+ public byte mRedstoneStrength = 0, mType = 0, mUpdate = 0;
+
+ public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[64];
+
+ static {
+ for (int i = 0; i < 64; i++) {
+ sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/ButtonPanel/" + i);
+ }
+ }
+
+ public GT_MetaTileEntity_RedstoneButtonPanel(int aID) {
+ super(
+ aID,
+ "redstone.button.panel",
+ "Button Panel",
+ 5,
+ 0,
+ "Right-click with Screwdriver to change Button Design");
+ }
+
+ public GT_MetaTileEntity_RedstoneButtonPanel(final String aName, String[] aDescription,
+ final ITexture[][][] aTextures) {
+ super(aName, 5, 0, aDescription, aTextures);
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_RedstoneButtonPanel(this.mName, mDescriptionArray, this.mTextures);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setByte("mRedstoneStrength", mRedstoneStrength);
+ aNBT.setByte("mType", mType);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mRedstoneStrength = aNBT.getByte("mRedstoneStrength");
+ mType = aNBT.getByte("mType");
+ }
+
+ @Override
+ public void onValueUpdate(byte aValue) {
+ mRedstoneStrength = (byte) (aValue & 15);
+ mType = (byte) (aValue >>> 4);
+ }
+
+ @Override
+ public byte getUpdateData() {
+ return (byte) ((mRedstoneStrength & 15) | (mType << 4));
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side,
+ float aX, float aY, float aZ) {
+ if (side == getBaseMetaTileEntity().getFrontFacing()) {
+ if (getBaseMetaTileEntity().isServerSide()) {
+ mUpdate = 2;
+ switch (mType) {
+ case 0:
+ default:
+ switch (side) {
+ case DOWN, UP -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (aZ * 4));
+ case NORTH -> mRedstoneStrength = (byte) ((byte) (4 - aX * 4) + 4 * (byte) (4 - aY * 4));
+ case SOUTH -> mRedstoneStrength = (byte) ((byte) (aX * 4) + 4 * (byte) (4 - aY * 4));
+ case WEST -> mRedstoneStrength = (byte) ((byte) (aZ * 4) + 4 * (byte) (4 - aY * 4));
+ case EAST -> mRedstoneStrength = (byte) ((byte) (4 - aZ * 4) + 4 * (byte) (4 - aY * 4));
+ }
+ break;
+ case 1:
+ switch (side) {
+ case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength
+ ^ (1 << (((byte) (aX * 2) + 2 * (byte) (aZ * 2)))));
+ case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength
+ ^ (1 << (((byte) (2 - aX * 2) + 2 * (byte) (2 - aY * 2)))));
+ case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength
+ ^ (1 << (((byte) (aX * 2) + 2 * (byte) (2 - aY * 2)))));
+ case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength
+ ^ (1 << (((byte) (aZ * 2) + 2 * (byte) (2 - aY * 2)))));
+ case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength
+ ^ (1 << (((byte) (2 - aZ * 2) + 2 * (byte) (2 - aY * 2)))));
+ }
+ break;
+ case 2:
+ switch (side) {
+ case DOWN, UP -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (aZ * 4))));
+ case NORTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4))));
+ case SOUTH -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4))));
+ case WEST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4))));
+ case EAST -> mRedstoneStrength = (byte) (mRedstoneStrength ^ (1 << ((byte) (4 - aY * 4))));
+ }
+ break;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (getBaseMetaTileEntity().isServerSide()) {
+ getBaseMetaTileEntity().setGenericRedstoneOutput(true);
+ if (mUpdate > 0) {
+ mUpdate--;
+ } else if (getBaseMetaTileEntity().isAllowedToWork()) {
+ mRedstoneStrength = 0;
+ }
+ for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ getBaseMetaTileEntity().setStrongOutputRedstoneSignal(
+ side,
+ side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(
+ side,
+ side == getBaseMetaTileEntity().getFrontFacing() ? (byte) 0 : mRedstoneStrength);
+ }
+ }
+ }
+
+ @Override
+ public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (side == getBaseMetaTileEntity().getFrontFacing()) mType = (byte) ((mType + 1) % 3);
+ }
+
+ @Override
+ public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
+ final ITexture[][][] rTextures = new ITexture[10][17][];
+ for (byte i = -1; i < 16; i++) {
+ rTextures[0][i + 1] = this.getFront(i);
+ rTextures[1][i + 1] = this.getSides(i);
+ rTextures[2][i + 1] = this.getBottom(i);
+ rTextures[3][i + 1] = this.getTop(i);
+ rTextures[4][i + 1] = this.getSides(i);
+ rTextures[5][i + 1] = this.getFront(i);
+ rTextures[6][i + 1] = this.getSidesActive(i);
+ rTextures[7][i + 1] = this.getBottomActive(i);
+ rTextures[8][i + 1] = this.getTopActive(i);
+ rTextures[9][i + 1] = this.getSidesActive(i);
+ }
+ return rTextures;
+ }
+
+ @Override
+ public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side,
+ final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) {
+ if (side == facing) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1],
+ new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength]) };
+ }
+ return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (side == facing ? 0
+ : side == facing.getOpposite() ? 1
+ : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex + 1];
+ }
+
+ public ITexture[] getFront(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1] };
+ }
+
+ public ITexture[] getTop(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_Off) };
+ }
+
+ public ITexture[] getTopActive(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Main_On) };
+ }
+
+ public ITexture[] getBottom(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_Off) };
+ }
+
+ public ITexture[] getBottomActive(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Main_On) };
+ }
+
+ public ITexture[] getSides(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_Off) };
+ }
+
+ public ITexture[] getSidesActive(final byte aColor) {
+ return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1],
+ new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Main_On) };
+ }
+}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java
new file mode 100644
index 0000000000..66d8b76e0c
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java
@@ -0,0 +1,659 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.redstone;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.oredict.OreDictionary;
+
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
+import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget;
+import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
+import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget;
+import com.gtnewhorizons.modularui.common.widget.SlotWidget;
+import com.gtnewhorizons.modularui.common.widget.TextWidget;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.gui.modularui.GT_UIInfos;
+import gregtech.api.gui.modularui.GT_UITextures;
+import gregtech.api.interfaces.IRedstoneCircuitBlock;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.modularui.IAddUIWidgets;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_CircuitryBehavior;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
+import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+
+public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_RedstoneBase
+ implements IRedstoneCircuitBlock, IAddUIWidgets {
+
+ public int mGate = 0, mGateData[] = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
+ public boolean bOutput = true;
+
+ public GT_MetaTileEntity_RedstoneCircuitBlock(int aID) {
+ super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone");
+ }
+
+ public GT_MetaTileEntity_RedstoneCircuitBlock(final String aName, String[] aDescription,
+ final ITexture[][][] aTextures) {
+ super(aName, 1, 5, aDescription, aTextures);
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescriptionArray, this.mTextures);
+ }
+
+ @Override
+ public boolean hasSidedRedstoneOutputBehavior() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ @Override
+ public boolean isInputFacing(ForgeDirection side) {
+ return !this.isOutputFacing(side);
+ }
+
+ @Override
+ public boolean isElectric() {
+ return true;
+ }
+
+ @Override
+ public boolean isPneumatic() {
+ return false;
+ }
+
+ @Override
+ public boolean isSteampowered() {
+ return false;
+ }
+
+ @Override
+ public boolean isOutputFacing(ForgeDirection side) {
+ return side == this.getOutputFacing();
+ }
+
+ @Override
+ public long getMinimumStoredEU() {
+ return 512;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return GT_Values.V[1];
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return bOutput ? GT_Values.V[1] : 0;
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return 2;
+ }
+
+ @Override
+ public long maxAmperesOut() {
+ return 1;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return 5;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return GT_Values.V[3] * 1024;
+ }
+
+ @Override
+ public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer);
+ return true;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setInteger("mGate", mGate);
+ aNBT.setIntArray("mGateData", mGateData);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mGate = aNBT.getInteger("mGate");
+ mGateData = aNBT.getIntArray("mGateData");
+ if (mGateData.length != 8) mGateData = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
+ }
+
+ public void switchGateForward(boolean aShift) {
+ try {
+ Set<Integer> tKeys = GregTech_API.sCircuitryBehaviors.keySet();
+ ArrayList<Integer> tList = new ArrayList<>();
+ tList.addAll(tKeys);
+ if (tList.size() <= 0) return;
+ Collections.sort(tList);
+ if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0);
+ int tIndex = Collections.binarySearch(tList, mGate);
+ tIndex += aShift ? 16 : 1;
+ while (tIndex >= tList.size()) tIndex -= tList.size();
+ mGate = tList.get(tIndex);
+ switchGate();
+ } catch (Throwable e) {
+ GT_Log.err.print(e);
+ }
+ }
+
+ public void switchGateBackward(boolean aShift) {
+ try {
+ Set<Integer> tKeys = GregTech_API.sCircuitryBehaviors.keySet();
+ ArrayList<Integer> tList = new ArrayList<>();
+ tList.addAll(tKeys);
+ if (tList.size() <= 0) return;
+ Collections.sort(tList);
+ if (!GregTech_API.sCircuitryBehaviors.containsKey(mGate)) mGate = tList.get(0);
+ int tIndex = Collections.binarySearch(tList, mGate);
+ tIndex -= aShift ? 16 : 1;
+ while (tIndex < 0) tIndex += tList.size();
+ mGate = tList.get(tIndex);
+ switchGate();
+ } catch (Throwable e) {
+ GT_Log.err.print(e);
+ }
+ }
+
+ @Override
+ public void onFacingChange() {
+ resetRedstone();
+ }
+
+ private void resetRedstone() {
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.DOWN, (byte) 0);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.UP, (byte) 0);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.NORTH, (byte) 0);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.SOUTH, (byte) 0);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.WEST, (byte) 0);
+ getBaseMetaTileEntity().setInternalOutputRedstoneSignal(ForgeDirection.EAST, (byte) 0);
+ }
+
+ public void changeGateData(int aIndex, int aValue) {
+ mGateData[aIndex] += aValue;
+ validateGateData();
+ }
+
+ public void stackGateData(int aIndex, ItemStack aStack) {
+ mGateData[aIndex] = GT_Utility.stackToInt(aStack);
+ validateGateData();
+ }
+
+ private void switchGate() {
+ resetRedstone();
+ Arrays.fill(mGateData, 0);
+ GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate);
+ if (tBehaviour != null) try {
+ tBehaviour.initParameters(mGateData, this);
+ } catch (Throwable e) {
+ GT_Log.err.print(e);
+ }
+ validateGateData();
+ }
+
+ private void validateGateData() {
+ GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate);
+ if (tBehaviour != null) try {
+ tBehaviour.validateParameters(mGateData, this);
+ } catch (Throwable e) {
+ GT_Log.err.print(e);
+ }
+ }
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
+ super.onFirstTick(aBaseMetaTileEntity);
+ getBaseMetaTileEntity().setGenericRedstoneOutput(true);
+ validateGateData();
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPreTick(aBaseMetaTileEntity, aTick);
+ getBaseMetaTileEntity().setGenericRedstoneOutput(true);
+ if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) {
+ mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null;
+ if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) {
+ if (getBaseMetaTileEntity().isActive()) {
+ GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate);
+ if (tBehaviour != null) {
+ try {
+ tBehaviour.onTick(mGateData, this);
+ if (tBehaviour.displayItemStack(mGateData, this, 0))
+ mInventory[1] = getCoverByID(mGateData[0]);
+ if (tBehaviour.displayItemStack(mGateData, this, 1))
+ mInventory[2] = getCoverByID(mGateData[1]);
+ if (tBehaviour.displayItemStack(mGateData, this, 2))
+ mInventory[3] = getCoverByID(mGateData[2]);
+ if (tBehaviour.displayItemStack(mGateData, this, 3))
+ mInventory[4] = getCoverByID(mGateData[3]);
+ } catch (Throwable e) {
+ GT_Log.err.print(e);