diff options
6 files changed, 634 insertions, 15 deletions
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 4d67603db0..e731cf0730 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -547,6 +547,7 @@ public enum GregtechItemList implements GregtechItemContainer { GT4_Redstone_Button_Panel, GT4_Redstone_Scale, GT4_Redstone_Display, + GT4_Redstone_Circuit, //Gt4 Workbenches GT4_Workbench_Bronze, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java new file mode 100644 index 0000000000..acae0d39c5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java @@ -0,0 +1,176 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneCircuitBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class GT_Container_RedstoneCircuitBlock extends GT_ContainerMetaTile_Machine { + + public GT_Container_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 60, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 42, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 1, 26, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 26, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 26, 60, false, true, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0 || aSlotIndex > 6) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) + return null; + if (aSlotIndex < 4) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack == null) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).changeGateData(aSlotIndex, aMouseclick == 0 ? aShifthold == 0 ? +1 : aShifthold == 1 ? +128 : +16 : aShifthold == 0 ? -1 : aShifthold == 1 ? -128 : -16); + } + else { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) + tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).stackGateData(aSlotIndex, tStack); + } + return null; + } + else if (aSlotIndex == 4) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchOutput(); + } + else if (aSlotIndex == 5) { + mTileEntity.setActive(!mTileEntity.isActive()); + } + else if (aSlotIndex == 6) { + if (aMouseclick == 0) + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateForward(aShifthold != 0); + else + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateBackward(aShifthold != 0); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public int mData[] = new int[]{0, 0, 0, 0, 0, 0, 0, 0}, mGate = 0; + + @SuppressWarnings("rawtypes") + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) + return; + mGate = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGate; + mData = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGateData; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, mGate & 65535); + var1.sendProgressBarUpdate(this, 101, mGate >>> 16); + var1.sendProgressBarUpdate(this, 102, mData[0] & 65535); + var1.sendProgressBarUpdate(this, 103, mData[0] >>> 16); + var1.sendProgressBarUpdate(this, 104, mData[1] & 65535); + var1.sendProgressBarUpdate(this, 105, mData[1] >>> 16); + var1.sendProgressBarUpdate(this, 106, mData[2] & 65535); + var1.sendProgressBarUpdate(this, 107, mData[2] >>> 16); + var1.sendProgressBarUpdate(this, 108, mData[3] & 65535); + var1.sendProgressBarUpdate(this, 109, mData[3] >>> 16); + var1.sendProgressBarUpdate(this, 110, mData[4] & 65535); + var1.sendProgressBarUpdate(this, 111, mData[4] >>> 16); + var1.sendProgressBarUpdate(this, 112, mData[5] & 65535); + var1.sendProgressBarUpdate(this, 113, mData[5] >>> 16); + var1.sendProgressBarUpdate(this, 114, mData[6] & 65535); + var1.sendProgressBarUpdate(this, 115, mData[6] >>> 16); + var1.sendProgressBarUpdate(this, 116, mData[7] & 65535); + var1.sendProgressBarUpdate(this, 117, mData[7] >>> 16); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100 : + mGate = mGate & -65536 | par2; + break; + case 101 : + mGate = mGate & 65535 | par2 << 16; + break; + case 102 : + mData[0] = mData[0] & -65536 | par2; + break; + case 103 : + mData[0] = mData[0] & 65535 | par2 << 16; + break; + case 104 : + mData[1] = mData[1] & -65536 | par2; + break; + case 105 : + mData[1] = mData[1] & 65535 | par2 << 16; + break; + case 106 : + mData[2] = mData[2] & -65536 | par2; + break; + case 107 : + mData[2] = mData[2] & 65535 | par2 << 16; + break; + case 108 : + mData[3] = mData[3] & -65536 | par2; + break; + case 109 : + mData[3] = mData[3] & 65535 | par2 << 16; + break; + case 110 : + mData[4] = mData[4] & -65536 | par2; + break; + case 111 : + mData[4] = mData[4] & 65535 | par2 << 16; + break; + case 112 : + mData[5] = mData[5] & -65536 | par2; + break; + case 113 : + mData[5] = mData[5] & 65535 | par2 << 16; + break; + case 114 : + mData[6] = mData[6] & -65536 | par2; + break; + case 115 : + mData[6] = mData[6] & 65535 | par2 << 16; + break; + case 116 : + mData[7] = mData[7] & -65536 | par2; + break; + case 117 : + mData[7] = mData[7] & 65535 | par2 << 16; + break; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java new file mode 100644 index 0000000000..89636fbaf2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java @@ -0,0 +1,62 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import gregtech.api.GregTech_API; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_CircuitryBehavior; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTile_Machine { + + public GT_GUIContainer_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_RedstoneCircuitBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "RedstoneCircuitBlock.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(((GT_Container_RedstoneCircuitBlock) mContainer).mGate); + if (tCircuit != null) { + this.fontRendererObj.drawString(tCircuit.getName(), 46, 8, 16448255); + this.fontRendererObj.drawString(tCircuit.getDescription(), 46, 19, 16448255); + + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0), 46, 33, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1), 46, 44, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2), 46, 55, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3), 46, 66, 16448255); + + String tString; + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[0]) : tString, 99, 33, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[1]) : tString, 99, 44, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[2]) : tString, 99, 55, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[3]) : tString, 99, 66, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + + if (mContainer != null) { + if (((GT_Container_RedstoneCircuitBlock) mContainer).mOutput > 0) + drawTexturedModalRect(x + 151, y + 5, 176, 0, 18, 18); + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mActive & 1) > 0) + drawTexturedModalRect(x + 151, y + 23, 176, 18, 18, 18); + if (((GT_Container_RedstoneCircuitBlock) mContainer).mDisplayErrorCode > 0) + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mTileEntity.getTimer() / 5) % 2 == 0) + drawTexturedModalRect(x + 140, y + 9, 194, 0, 7, 7); + else + ; + else + drawTexturedModalRect(x + 140, y + 9, 201, 0, 7, 7); + } + } +} 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..e3779d1e9b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java @@ -0,0 +1,391 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import java.util.*; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IRedstoneCircuitBlock; +import gregtech.api.interfaces.ITexture; +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.util.*; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_RedstoneCircuitBlock; +import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_RedstoneCircuitBlock; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_RedstoneBase implements IRedstoneCircuitBlock { + + 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", 0, 0, "Computes Redstone"); + } + + public GT_MetaTileEntity_RedstoneCircuitBlock(final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 0, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescription, this.mTextures); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return getBaseMetaTileEntity().getBackFacing() == aSide; + } + + @Override + public long getMinimumStoredEU() { + return 500; + } + + @Override + public long maxEUInput() { + return 32; + } + + @Override + public long maxEUOutput() { + return bOutput ? 32 : 0; + } + + @Override + public int getSizeInventory() { + return 5; + } + + @Override + public long maxEUStore() { + return 1000; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer, 147); + 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 switchOutput() { + bOutput = !bOutput; + } + + public void switchGateForward(boolean aShift) { + try { + Set<Integer> tKeys = GregTech_API.sCircuitryBehaviors.keySet(); + ArrayList<Integer> tList = new ArrayList<Integer>(); + 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<Integer>(); + 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((byte) 0, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 1, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 2, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 3, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 4, (byte) 0); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal((byte) 5, (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(); + for (int i = 0; i < mGateData.length; i++) + mGateData[i] = 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() > 400) { + 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); + } + } + } + getBaseMetaTileEntity().setErrorDisplayID(0); + } + else { + getBaseMetaTileEntity().setErrorDisplayID(1); + } + } + } + + + /** The Item List for Covers */ + public static final Map<Integer, ItemStack> sCoversItems = new HashMap<Integer, ItemStack>(); + + private static void initCovers() { + for (GT_ItemStack aKey : GregTech_API.sCovers.keySet()) { + ItemStack aStack = aKey.toStack().copy(); + if (aStack != null) { + sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); + } + } + } + + public static ItemStack getCoverByID(int aStack) { + if (sCoversItems.isEmpty()) { + initCovers(); + } + return sCoversItems.get(Integer.valueOf(aStack)); + } + + @Override + public byte getOutputFacing() { + return getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean setRedstone(byte aStrength, byte aSide) { + if (getOutputRedstone(aSide) != aStrength) { + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits(1, false)) { + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(aSide, aStrength); + getBaseMetaTileEntity().setErrorDisplayID(0); + return true; + } + else { + getBaseMetaTileEntity().setErrorDisplayID(1); + return false; + } + } + return false; + } + + /* @Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == getOutputFacing()) { + if (aSide == 0) + return aRedstone ? 56 : 54; + if (aSide == 1) + return aRedstone ? 53 : 52; + return aRedstone ? 94 : 93; + } + if (aSide == 0) + return aRedstone ? 60 : 59; + if (aSide == 1) + return aRedstone ? 58 : 57; + return aRedstone ? 62 : 61; + }*/ + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public byte getOutputRedstone(byte aSide) { + return getBaseMetaTileEntity().getOutputRedstoneSignal(aSide); + } + + @Override + public byte getInputRedstone(byte aSide) { + return getBaseMetaTileEntity().getInternalInputRedstoneSignal(aSide); + } + + @Override + public Block getBlockAtSide(byte aSide) { + return getBaseMetaTileEntity().getBlockAtSide(aSide); + } + + @Override + public byte getMetaIDAtSide(byte aSide) { + return getBaseMetaTileEntity().getMetaIDAtSide(aSide); + } + + @Override + public TileEntity getTileEntityAtSide(byte aSide) { + return getBaseMetaTileEntity().getTileEntityAtSide(aSide); + } + + @Override + public int getRandom(int aRange) { + return getBaseMetaTileEntity().getRandomNumber(aRange); + } + + @Override + public GT_CoverBehavior getCover(byte aSide) { + return getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide); + } + + @Override + public int getCoverID(byte aSide) { + return getBaseMetaTileEntity().getCoverIDAtSide(aSide); + } + + @Override + public int getCoverVariable(byte aSide) { + return getBaseMetaTileEntity().getCoverDataAtSide(aSide); + } + + @Override + public ICoverable getOwnTileEntity() { + return getBaseMetaTileEntity(); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java index 75128392ea..e71e71d6ed 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -5,27 +5,15 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; -import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.*; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_ThermalBoiler; import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; -import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneButtonPanel; -import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneLamp; -import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneStrengthDisplay; -import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneStrengthScale; +import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.*; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_AdvancedCraftingTable; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_BronzeCraftingTable; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Compartment; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Desk; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_FileCabinet; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Iron; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.*; public class Gregtech4Content { @@ -66,6 +54,7 @@ public class Gregtech4Content { GregtechItemList.GT4_Redstone_Button_Panel.set(new GT_MetaTileEntity_RedstoneButtonPanel(31121).getStackForm(1L)); GregtechItemList.GT4_Redstone_Scale.set(new GT_MetaTileEntity_RedstoneStrengthScale(31122).getStackForm(1L)); GregtechItemList.GT4_Redstone_Display.set(new GT_MetaTileEntity_RedstoneStrengthDisplay(31123, "redstone.display.strength", "Redstone Display", "Displays Redstone Strength").getStackForm(1L)); + GregtechItemList.GT4_Redstone_Circuit.set(new GT_MetaTileEntity_RedstoneCircuitBlock(31124).getStackForm(1L)); } diff --git a/src/main/resources/assets/miscutils/textures/gui/RedstoneCircuitBlock.png b/src/main/resources/assets/miscutils/textures/gui/RedstoneCircuitBlock.png Binary files differnew file mode 100644 index 0000000000..0df259c657 --- /dev/null +++ b/src/main/resources/assets/miscutils/textures/gui/RedstoneCircuitBlock.png |