diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common')
6 files changed, 610 insertions, 0 deletions
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 8195837a65..84c0686d61 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 @@ -415,6 +415,22 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Adv_Workbench_Bottom = new CustomIcon("TileEntities/gt4/machine_bottom"); + 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_Electric_Auto_Workbench_Side = new CustomIcon("TileEntities/gt4/OVERLAY_SIDE_CABINET"); public static final CustomIcon Casing_CropHarvester_Cutter = new CustomIcon("TileEntities/gt4/OVERLAY_CROP"); 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..8c02f08c65 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneBase.java @@ -0,0 +1,118 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +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; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +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); + } + + 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(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public final boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public final boolean isFacingValid(byte aFacing) { + 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 true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, gregtech.api.interfaces.tileentity.IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public final void onOpenGUI() { + super.onOpenGUI(); + mOpenerCount++; + } + + @Override + public final void onCloseGUI() { + super.onCloseGUI(); + mOpenerCount--; + } + + public final boolean hasRedstoneSignal() { + for (byte i=0;i<6;i++) { + if (getBaseMetaTileEntity().getOutputRedstoneSignal(i) > 0) { + return true; + } + } + return false; + } + + @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 String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip + }; + } + +} 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..0c0cc44d93 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneButtonPanel.java @@ -0,0 +1,207 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +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 gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +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, mDescription, 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, byte aSide, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + if (getBaseMetaTileEntity().isServerSide()) { + mUpdate = 2; + switch (mType) { + case 0: default: + switch (aSide) { + case 0: case 1: + mRedstoneStrength = (byte)((byte)( aX*4) + 4 * (byte)( aZ*4)); + break; + case 2: + mRedstoneStrength = (byte)((byte)(4-aX*4) + 4 * (byte)(4-aY*4)); + break; + case 3: + mRedstoneStrength = (byte)((byte)( aX*4) + 4 * (byte)(4-aY*4)); + break; + case 4: + mRedstoneStrength = (byte)((byte)( aZ*4) + 4 * (byte)(4-aY*4)); + break; + case 5: + mRedstoneStrength = (byte)((byte)(4-aZ*4) + 4 * (byte)(4-aY*4)); + break; + } + break; + case 1: + switch (aSide) { + case 0: case 1: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aX*2) + 2 * (byte)( aZ*2))))); + break; + case 2: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)(2-aX*2) + 2 * (byte)(2-aY*2))))); + break; + case 3: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aX*2) + 2 * (byte)(2-aY*2))))); + break; + case 4: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)( aZ*2) + 2 * (byte)(2-aY*2))))); + break; + case 5: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << (((byte)(2-aZ*2) + 2 * (byte)(2-aY*2))))); + break; + } + break; + case 2: + switch (aSide) { + case 0: case 1: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)( aZ*4)))); + break; + case 2: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); + break; + case 3: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); + break; + case 4: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); + break; + case 5: + mRedstoneStrength = (byte)(mRedstoneStrength ^ (1 << ((byte)(4-aY*4)))); + break; + } + 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 (byte i = 0; i < 6; i++) { + getBaseMetaTileEntity().setStrongOutputRedstoneSignal(i, i == getBaseMetaTileEntity().getFrontFacing()?(byte)0:mRedstoneStrength); + getBaseMetaTileEntity().setInternalOutputRedstoneSignal(i, i == getBaseMetaTileEntity().getFrontFacing()?(byte)0:mRedstoneStrength); + } + } + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == 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 byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType*16+mRedstoneStrength])}; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 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_RedstoneLamp.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java new file mode 100644 index 0000000000..81517c83b9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneLamp.java @@ -0,0 +1,75 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +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; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_RedstoneLamp extends GT_MetaTileEntity_RedstoneBase { + + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[2]; + + static { + sIconList[0] = new CustomIcon("TileEntities/gt4/redstone/Lamp/off"); + sIconList[1] = new CustomIcon("TileEntities/gt4/redstone/Lamp/on"); + } + + public GT_MetaTileEntity_RedstoneLamp(int aID) { + super(aID, "redstone.lamp", "Redstone Controlled Lamp", 0, 0, "Redstone Controlled Lamp"); + } + + public GT_MetaTileEntity_RedstoneLamp(final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 0, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneLamp(this.mName, mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + getBaseMetaTileEntity().setLightValue(getBaseMetaTileEntity().getStrongestRedstone()); + getBaseMetaTileEntity().setActive(getBaseMetaTileEntity().getStrongestRedstone()>0); + } + } + + @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.getSides(i); + rTextures[1][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 1 : 0)][aColorIndex + 1]; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(sIconList[0])}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(sIconList[1])}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java new file mode 100644 index 0000000000..1f65385793 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthDisplay.java @@ -0,0 +1,144 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_RedstoneStrengthDisplay extends GT_MetaTileEntity_RedstoneBase { + + public byte mRedstoneStrength = 0, mType = 0; + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[144]; + + static { + for (int i=0;i<144;i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Display/"+i); + } + } + + public GT_MetaTileEntity_RedstoneStrengthDisplay(int aID, String aUnlocal, String aLocal, String aDescription) { + super(aID, aUnlocal, aLocal, 5, 0, aDescription); + } + + public GT_MetaTileEntity_RedstoneStrengthDisplay(final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneStrengthDisplay(this.mName, mDescription, 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 void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { + mRedstoneStrength = getBaseMetaTileEntity().getStrongestRedstone(); + } + } + + /*@Override + public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + if (aSide == 0) + return aRedstone ? 60 : 59; + if (aSide == 1) + return aRedstone ? 58 : 57; + return aRedstone ? 62 : 61; + }*/ + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + mType = (byte) ((mType + 1) % 6); + } + + /*@Override + public IIcon getTextureIcon(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? sIconList[mType * 16 + mRedstoneStrength] : null; + }*/ + + @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 byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength])}; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 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_Off)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off)}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On)}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java new file mode 100644 index 0000000000..efa3763370 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneStrengthScale.java @@ -0,0 +1,50 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; + +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 gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import net.minecraft.entity.player.EntityPlayer; + +public class GT_MetaTileEntity_RedstoneStrengthScale extends GT_MetaTileEntity_RedstoneStrengthDisplay { + + public static TexturesGtBlock.CustomIcon[] sIconList = new TexturesGtBlock.CustomIcon[32]; + + static { + for (int i=0;i<32;i++) { + sIconList[i] = new CustomIcon("TileEntities/gt4/redstone/Scale/"+i); + } + } + + public GT_MetaTileEntity_RedstoneStrengthScale(int aID) { + super(aID, "redstone.display.scale", "Redstone Scale", "Redstone Strength on a Scale"); + } + + public GT_MetaTileEntity_RedstoneStrengthScale(final String aName, String aDescription, final ITexture[][][] aTextures) { + super(aName, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RedstoneStrengthScale(this.mName, mDescription, this.mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + mType = (byte) ((mType + 1) % 2); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(sIconList[mType * 16 + mRedstoneStrength])}; + } + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + +} |