diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-09-09 21:10:23 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-09-09 21:10:23 +1000 |
commit | 3b15de7e6090b0b60dd77311d8e599c7dccd9326 (patch) | |
tree | cd72c71d0f57f2733285a44b8d46659b239967c5 /src/Java/gtPlusPlus/xmod | |
parent | db713aab91e567051de587dcb9aeebf7d0b0b308 (diff) | |
download | GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.tar.gz GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.tar.bz2 GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.zip |
- Removed Superconductors and Conduction Nodes.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
11 files changed, 8 insertions, 4764 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java deleted file mode 100644 index b6f798c57a..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java +++ /dev/null @@ -1,263 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.VN; - -import java.util.ArrayList; -import java.util.Arrays; - -import cofh.energy.IEnergyReceiver; -import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable; -import gregtech.api.interfaces.tileentity.*; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaPipeEntityBase_Cable; -import ic2.api.energy.tile.IEnergySink; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -public class GregtechMetaPipeEntity_SuperConductor extends GregtechMetaPipeEntityBase_Cable implements IMetaTileEntityCable { - - public final float mThickNess; - public final GT_Materials mMaterial; - public final long mCableLossPerMeter, mAmperage, mVoltage; - public final boolean mInsulated, mCanShock; - - public GregtechMetaPipeEntity_SuperConductor(final int aID, final String aName, final String aNameRegional, final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock) { - super(aID, aName, aNameRegional, 0, aMaterial, 0, aAmperage, aVoltage, aInsulated, aCanShock); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = 0; - } - - public GregtechMetaPipeEntity_SuperConductor(final String aName, final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock) { - super(aName, 0, aMaterial, 0, aAmperage, aVoltage, aInsulated, aCanShock); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = 0; - } - - @Override - public byte getTileEntityBaseType() { - return (byte)(this.mInsulated?9:8); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntity_SuperConductor(this.mName, this.mThickNess, this.mMaterial, this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) { - if (!this.mInsulated) { - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa)}; - } - if (aConnected) { - final float tThickNess = this.getThickNess(); - if (tThickNess < 0.37F) { - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - if (tThickNess < 0.49F) { - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - if (tThickNess < 0.74F) { - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - if (tThickNess < 0.99F) { - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - return new ITexture[] {new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - - @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, final Entity aEntity) { - if (this.mCanShock && ((((BaseMetaPipeEntity)this.getBaseMetaTileEntity()).mConnections & -128) == 0) && (aEntity instanceof EntityLivingBase)) { - GT_Utility.applyElectricityDamage((EntityLivingBase)aEntity, this.mTransferredVoltageLast20, this.mTransferredAmperageLast20); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { - if (!this.mCanShock) { - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return AxisAlignedBB.getBoundingBox(aX+0.125D, aY+0.125D, aZ+0.125D, aX+0.875D, aY+0.875D, aZ+0.875D); - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(final byte aFacing) {return false;} - @Override public boolean isValidSlot(final int aIndex) {return true;} - // @Override public final boolean renderInside(byte aSide) {return false;} - @Override public int getProgresstime() {return (int)this.mTransferredAmperage*64;} - @Override public int maxProgresstime() {return (int)this.mAmperage*64;} - - @Override - public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) { - return 0; - } - return this.transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<>(Arrays.asList((TileEntity)this.getBaseMetaTileEntity()))); - } - - @Override - public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage, final ArrayList<TileEntity> aAlreadyPassedTileEntityList) { - long rUsedAmperes = 0; - aVoltage -= this.mCableLossPerMeter; - if (aVoltage > 0) { - for (byte i = 0; (i < 6) && (aAmperage > rUsedAmperes); i++) { - if ((i != aSide) && ((this.mConnections & (1<<i)) != 0) && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, this.getBaseMetaTileEntity().getCoverIDAtSide(i), this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { - final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); - if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { - aAlreadyPassedTileEntityList.add(tTileEntity); - if (tTileEntity instanceof IEnergyConnected) { - if (this.getBaseMetaTileEntity().getColorization() >= 0) { - final byte tColor = ((IEnergyConnected)tTileEntity).getColorization(); - if ((tColor >= 0) && (tColor != this.getBaseMetaTileEntity().getColorization())) { - continue; - } - } - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) && ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity))) { - if (((IGregTechTileEntity)tTileEntity).getTimer() > 50) { - rUsedAmperes += ((IMetaTileEntityCable)((IGregTechTileEntity)tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes, aAlreadyPassedTileEntityList); - } - } else { - rUsedAmperes += ((IEnergyConnected)tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes); - } - // } else if (tTileEntity instanceof IEnergySink) { - // ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) { - // if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++; - // } - } else if (tTileEntity instanceof IEnergySink) { - final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)this.getBaseMetaTileEntity(), tDirection)) { - if ((((IEnergySink)tTileEntity).getDemandedEnergy() > 0) && (((IEnergySink)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage)) { - rUsedAmperes++; - } - } - } else if(GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver)){ - final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - final int rfOut = (int) ((aVoltage * GregTech_API.mEUtoRF) / 100); - if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){ - ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; - }else if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)>0){ - if(this.mRestRF==0){ - final int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false);rUsedAmperes++; - this.mRestRF = rfOut - RFtrans; - }else{ - final int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) this.mRestRF, false); - this.mRestRF = this.mRestRF - RFtrans; - } - } - if(GregTech_API.mRFExplosions && (((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < (rfOut * 600))){ - if(rfOut > ((32 * GregTech_API.mEUtoRF) / 100)) { - this.doExplosion(rfOut); - } - } - } - } - } - } - } - this.mTransferredAmperage += rUsedAmperes; - this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); - this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); - if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)) { - this.getBaseMetaTileEntity().setToFire(); - return aAmperage; - } - return rUsedAmperes; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - this.mTransferredAmperage = 0; - - if ((aTick % 20) == 0) { - this.mTransferredVoltageLast20 = 0; - this.mTransferredAmperageLast20 = 0; - this.mConnections = 0; - for (byte i = 0, j = 0; i < 6; i++) { - j = GT_Utility.getOppositeSide(i); - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { - final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IColoredTileEntity) { - if (aBaseMetaTileEntity.getColorization() >= 0) { - final byte tColor = ((IColoredTileEntity)tTileEntity).getColorization(); - if ((tColor >= 0) && (tColor != aBaseMetaTileEntity.getColorization())) { - continue; - } - } - } - if ((tTileEntity instanceof IEnergyConnected) && (((IEnergyConnected)tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected)tTileEntity).outputsEnergyTo(j))) { - this.mConnections |= (1<<i); - continue; - } - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable)) { - if (((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity))) { - this.mConnections |= (1<<i); - continue; - } - } - if ((tTileEntity instanceof IEnergySink) && ((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - this.mConnections |= (1<<i); - continue; - } - if(GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver) && ((IEnergyReceiver)tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))){ - this.mConnections |= (1<<i); - continue; - } - /* - if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - mConnections |= (1<<i); - continue; - }*/ - } - } - } - } - } - - - @Override - public String[] getDescription() { - return new String[] { - "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " (" + VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt", - CORE.GT_Tooltip, - " ", - "This Wire is Lossless.", - "Please, adhere to cooling directions." - }; - } - - - @Override - public float getThickNess() { - return this.mThickNess; - } - -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java deleted file mode 100644 index e8cbf4abe2..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java +++ /dev/null @@ -1,316 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; - -import java.util.Collection; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless.GregtechMetaTileEntityLosslessBasicTank; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public abstract class GregtechMetaSuperConductorNodeBase extends GregtechMetaTileEntityLosslessBasicTank { - public GregtechMetaSuperConductorNodeBase(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GregtechMetaSuperConductorNodeBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @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.getBack(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.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(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) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Cooling Efficiency: " + this.getEfficiency() + "%", CORE.GT_Tooltip}; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isFacingValid(final byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long getMinimumStoredEU() { - return V[this.mTier] * 16 * this.mInventory.length; - } - - @Override - public long maxEUStore() { - return V[this.mTier] * 64; - } - - @Override - public long maxEUInput() { - return V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return V[this.mTier]; - } - - @Override - public long maxAmperesIn() { - return 16; - } - - @Override - public long maxAmperesOut() { - return 16; - } - - @Override - public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return this.getFuelValue(aFluid) > 0; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if ((this.getEUVar() == this.maxEUStore()) || (this.mFluid == null)){ - aBaseMetaTileEntity.disableWorking(); - } - else { - aBaseMetaTileEntity.enableWorking(); - } - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { - this.mInventory[this.getStackDisplaySlot()] = null; - } else { - if (this.mInventory[this.getStackDisplaySlot()] == null) { - this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - } - this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); - } - } else { - final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - if ((tConsumed > 0) && (this.mFluid.amount > tConsumed)) { - final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored())); - if (tFluidAmountToUse > 0 /*&& aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)*/) { - this.mFluid.amount -= tFluidAmountToUse * tConsumed; - } - } - } - if ((this.mInventory[this.getInputSlot()] != null) && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { - final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); - if (tFuelValue >= 0) { - final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { - //aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); - } - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(final FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(final FluidStack aLiquid) { - if ((aLiquid == null) || (this.getRecipes() == null)) { - return 0; - } - FluidStack tLiquid; - final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; - if (tRecipeList != null) { - for (final GT_Recipe tFuel : tRecipeList) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { - if (aLiquid.isFluidEqual(tLiquid)) { - return 0; - } - } - } - } - //return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); - return 0; - } - - public int getFuelValue(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return 0; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return 0; - } - //return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); - return 0; - } - - public ItemStack getEmptyContainer(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return null; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return GT_Utility.copy(tFuel.getOutput(0)); - } - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && ((this.getFuelValue(aStack) > 0) || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); - } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public int getTankPressure() { - return -100; - } - - -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java deleted file mode 100644 index 3343750c09..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java +++ /dev/null @@ -1,2113 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; - -import java.util.*; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.net.GT_Packet_TileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import ic2.api.Direction; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.EnumSkyBlock; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main TileEntity for EVERYTHING. - */ -public class GregtechBaseMetaTileEntityLossless extends BaseTileEntity implements IGregTechTileEntity { - private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; - protected MetaTileEntity mMetaTileEntity; - protected long mStoredEnergy = 0, mStoredSteam = 0; - protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; - protected boolean mReleaseEnergy = false; - protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; - private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; - private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; - private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; - private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; - private short mID = 0; - private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; - private String mOwnerName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - - public GregtechBaseMetaTileEntityLossless() { - } - - @Override - public void writeToNBT(final NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - aNBT.setInteger("mID", this.mID); - aNBT.setLong("mStoredSteam", this.mStoredSteam); - aNBT.setLong("mStoredEnergy", this.mStoredEnergy); - aNBT.setIntArray("mCoverData", this.mCoverData); - aNBT.setIntArray("mCoverSides", this.mCoverSides); - aNBT.setByteArray("mRedstoneSided", this.mSidedRedstone); - aNBT.setByte("mColor", this.mColor); - aNBT.setByte("mLightValue", this.mLightValue); - aNBT.setByte("mOtherUpgrades", this.mOtherUpgrades); - aNBT.setByte("mWorkData", this.mWorkData); - aNBT.setByte("mStrongRedstone", this.mStrongRedstone); - aNBT.setShort("mFacing", this.mFacing); - aNBT.setString("mOwnerName", this.mOwnerName); - aNBT.setBoolean("mLockUpgrade", this.mLockUpgrade); - aNBT.setBoolean("mMuffler", this.mMuffler); - aNBT.setBoolean("mSteamConverter", this.mSteamConverter); - aNBT.setBoolean("mActive", this.mActive); - aNBT.setBoolean("mRedstone", this.mRedstone); - aNBT.setBoolean("mWorks", !this.mWorks); - aNBT.setBoolean("mInputDisabled", this.mInputDisabled); - aNBT.setBoolean("mOutputDisabled", this.mOutputDisabled); - aNBT.setTag("GT.CraftingComponents", this.mRecipeStuff); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - if (this.hasValidMetaTileEntity()) { - final NBTTagList tItemList = new NBTTagList(); - for (int i = 0; i < this.mMetaTileEntity.getRealInventory().length; i++) { - final ItemStack tStack = this.mMetaTileEntity.getRealInventory()[i]; - if (tStack != null) { - final NBTTagCompound tTag = new NBTTagCompound(); - tTag.setInteger("IntSlot", i); - tStack.writeToNBT(tTag); - tItemList.appendTag(tTag); - } - } - aNBT.setTag("Inventory", tItemList); - - try { - this.mMetaTileEntity.saveNBTData(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void readFromNBT(final NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - this.setInitialValuesAsNBT(aNBT, (short) 0); - } - - @Override - public void setInitialValuesAsNBT(final NBTTagCompound aNBT, final short aID) { - if (aNBT == null) { - if (aID > 0) { - this.mID = aID; - } else { - this.mID = this.mID > 0 ? this.mID : 0; - } - if (this.mID != 0) { - this.createNewMetatileEntity(this.mID); - } - this.mSidedRedstone = (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15}); - } else { - if (aID <= 0) { - this.mID = (short) aNBT.getInteger("mID"); - } else { - this.mID = aID; - } - this.mStoredSteam = aNBT.getInteger("mStoredSteam"); - this.mStoredEnergy = aNBT.getInteger("mStoredEnergy"); - this.mColor = aNBT.getByte("mColor"); - this.mLightValue = aNBT.getByte("mLightValue"); - this.mWorkData = aNBT.getByte("mWorkData"); - this.mStrongRedstone = aNBT.getByte("mStrongRedstone"); - this.mFacing = this.oFacing = (byte) aNBT.getShort("mFacing"); - this.mOwnerName = aNBT.getString("mOwnerName"); - this.mLockUpgrade = aNBT.getBoolean("mLockUpgrade"); - this.mMuffler = aNBT.getBoolean("mMuffler"); - this.mSteamConverter = aNBT.getBoolean("mSteamConverter"); - this.mActive = aNBT.getBoolean("mActive"); - this.mRedstone = aNBT.getBoolean("mRedstone"); - this.mWorks = !aNBT.getBoolean("mWorks"); - this.mInputDisabled = aNBT.getBoolean("mInputDisabled"); - this.mOutputDisabled = aNBT.getBoolean("mOutputDisabled"); - this.mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries")); - this.mCoverSides = aNBT.getIntArray("mCoverSides"); - this.mCoverData = aNBT.getIntArray("mCoverData"); - this.mSidedRedstone = aNBT.getByteArray("mRedstoneSided"); - this.mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - - if (this.mCoverData.length != 6) { - this.mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mCoverSides.length != 6) { - this.mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mSidedRedstone.length != 6) { - if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - this.mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - } else { - this.mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - } - } - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - - if ((this.mID != 0) && this.createNewMetatileEntity(this.mID)) { - final NBTTagList tItemList = aNBT.getTagList("Inventory", 10); - for (int i = 0; i < tItemList.tagCount(); i++) { - final NBTTagCompound tTag = tItemList.getCompoundTagAt(i); - final int tSlot = tTag.getInteger("IntSlot"); - if ((tSlot >= 0) && (tSlot < this.mMetaTileEntity.getRealInventory().length)) { - this.mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); - } - } - - try { - this.mMetaTileEntity.loadNBTData(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } - - if (this.mCoverData.length != 6) { - this.mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mCoverSides.length != 6) { - this.mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mSidedRedstone.length != 6) { - if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - this.mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - } else { - this.mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - } - } - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - } - - private boolean createNewMetatileEntity(final short aID) { - if ((aID <= 0) || (aID >= GregTech_API.METATILEENTITIES.length) || (GregTech_API.METATILEENTITIES[aID] == null)) { - GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!"); - } else { - if (aID != 0) { - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.setBaseMetaTileEntity(null); - } - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - this.mTickTimer = 0; - this.mID = aID; - return true; - } - } - return false; - } - - /** - * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion - * It's called right before onPostTick() - */ - public void updateStatus() { - // - } - - /** - * Called when trying to charge Items - */ - public void chargeItem(final ItemStack aStack) { - this.decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, this.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getOutputTier()), false, false), true); - } - - /** - * Called when trying to discharge Items - */ - public void dischargeItem(final ItemStack aStack) { - this.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, this.getEUCapacity() - this.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getInputTier()), false, false, false), true); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.hasValidMetaTileEntity()) { - if (this.mMetaTileEntity == null) { - return; - } - this.mMetaTileEntity.setBaseMetaTileEntity(this); - } - - this.mRunningThroughTick = true; - long tTime = System.currentTimeMillis(); - - for (int tCode = 0; this.hasValidMetaTileEntity() && (tCode >= 0); ) { - try { - switch (tCode) { - case 0: - tCode++; - if (this.mTickTimer++ == 0) { - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - if (this.isServerSide()) { - for (byte i = 0; i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - if (!this.mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(this.getCoverIDAtSide(i)))) { - this.dropCover(i, i, true); - } - } - } - } - - this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); - - this.mMetaTileEntity.onFirstTick(this); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 1: - tCode++; - if (this.isClientSide()) { - if (this.mColor != this.oColor) { - this.mMetaTileEntity.onColorChangeClient(this.oColor = this.mColor); - this.issueTextureUpdate(); - } - - if (this.mLightValue != this.oLightValueClient) { - this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord, this.mLightValue); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord + 1); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord - 1); - this.oLightValueClient = this.mLightValue; - this.issueTextureUpdate(); - } - - if (this.mNeedsUpdate) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - this.mNeedsUpdate = false; - } - } - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - if (this.isServerSide() && (this.mTickTimer > 10)) { - for (byte i = (byte) (tCode - 2); i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - tCode++; - final GT_CoverBehavior tCover = this.getCoverBehaviorAtSide(i); - final int tCoverTickRate = tCover.getTickRate(i, this.getCoverIDAtSide(i), this.mCoverData[i], this); - if ((tCoverTickRate > 0) && ((this.mTickTimer % tCoverTickRate) == 0)) { - this.mCoverData[i] = tCover.doCoverThings(i, this.getInputRedstoneSignal(i), this.getCoverIDAtSide(i), this.mCoverData[i], this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - } - } - - } - case 8: - tCode = 9; - if (this.isServerSide()) { - if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) { - this.mAverageEUInputIndex = 0; - } - if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) { - this.mAverageEUOutputIndex = 0; - } - - this.mAverageEUInput[this.mAverageEUInputIndex] = 0; - this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0; - } - case 9: - tCode++; - this.mMetaTileEntity.onPreTick(this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 10: - tCode++; - if (this.isServerSide()) { - if ((this.mRedstone != this.oRedstone) || (this.mTickTimer == 10)) { - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - this.oRedstone = this.mRedstone; - this.issueBlockUpdate(); - } - - if ((this.xCoord != this.oX) || (this.yCoord != this.oY) || (this.zCoord != this.oZ)) { - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - this.issueClientUpdate(); - this.clearTileEntityBuffer(); - } - - if (this.mFacing != this.oFacing) { - this.oFacing = this.mFacing; - for (byte i = 0; i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - if (!this.mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(this.getCoverIDAtSide(i)))) { - this.dropCover(i, i, true); - } - } - } - this.issueBlockUpdate(); - } - - if ((this.mTickTimer > 20) && this.mMetaTileEntity.isElectric()) { - this.mAcceptedAmperes = 0; - - if (this.getOutputVoltage() != this.oOutput) { - this.oOutput = this.getOutputVoltage(); - } - - if (this.mMetaTileEntity.isEnetOutput() || this.mMetaTileEntity.isEnetInput()) { - for (byte i = 0; i < 6; i++) { - boolean - temp = this.isEnergyInputSide(i); - if (temp != this.mActiveEUInputs[i]) { - this.mActiveEUInputs[i] = temp; - } - temp = this.isEnergyOutputSide(i); - if (temp != this.mActiveEUOutputs[i]) { - this.mActiveEUOutputs[i] = temp; - } - } - } - - - - if (this.mMetaTileEntity.isEnetOutput() && (this.oOutput > 0)) { - final long tOutputVoltage = this.oOutput, tUsableAmperage = Math.min(this.getOutputAmperage(), (this.getStoredEU() - this.mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); - if (tUsableAmperage > 0) { - final long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(this.oOutput, tUsableAmperage, this); - this.mAverageEUOutput[this.mAverageEUOutputIndex] += tEU; - this.decreaseStoredEU(tEU, true); - } - } - - - if (this.getEUCapacity() > 0) { - if (GregTech_API.sMachineFireExplosions && (this.getRandomNumber(1000) == 0)) { - final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6)); - if ((tBlock != null) && (tBlock instanceof BlockFire)) { - this.doEnergyExplosion(); - } - } - - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - - if (this.getRandomNumber(1000) == 0) { - if (((this.getCoverIDAtSide((byte) 1) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord) - 2) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 2) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord - 1) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 3) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord + 1) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 4) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord - 1, this.zCoord) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 5) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord + 1, this.zCoord) - 1) < this.yCoord))) { - if (GregTech_API.sMachineRainExplosions && this.worldObj.isRaining() && (this.getBiome().rainfall > 0)) { - if (this.getRandomNumber(10) == 0) { - try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "badweather"); - } catch (final Exception e) { - } - this.doEnergyExplosion(); - } else { - this.setOnFire(); - } - } - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - if (GregTech_API.sMachineThunderExplosions && this.worldObj.isThundering() && (this.getBiome().rainfall > 0) && (this.getRandomNumber(3) == 0)) { - try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "badweather"); - } catch (final Exception e) { - } - this.doEnergyExplosion(); - } - } - } - } - } - - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 11: - tCode++; - if (this.isServerSide()) { - if ((this.mMetaTileEntity.dechargerSlotCount() > 0) && (this.getStoredEU() < this.getEUCapacity())) { - for (int i = this.mMetaTileEntity.dechargerSlotStartIndex(), k = this.mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if ((this.mMetaTileEntity.mInventory[i] != null) && (this.getStoredEU() < this.getEUCapacity())) { - this.dischargeItem(this.mMetaTileEntity.mInventory[i]); - if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) { - this.mMetaTileEntity.mInventory[i] = null; - } - this.mInventoryChanged = true; - } - } - } - } - case 12: - tCode++; - if (this.isServerSide()) { - if ((this.mMetaTileEntity.rechargerSlotCount() > 0) && (this.getStoredEU() > 0)) { - for (int i = this.mMetaTileEntity.rechargerSlotStartIndex(), k = this.mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { - if ((this.getStoredEU() > 0) && (this.mMetaTileEntity.mInventory[i] != null)) { - this.chargeItem(this.mMetaTileEntity.mInventory[i]); - if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) { - this.mMetaTileEntity.mInventory[i] = null; - } - this.mInventoryChanged = true; - } - } - } - } - case 13: - tCode++; - this.updateStatus(); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 14: - tCode++; - this.mMetaTileEntity.onPostTick(this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 15: - tCode++; - if (this.isServerSide()) { - if ((this.mTickTimer % 10) == 0) { - if (this.mSendClientData) { - NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_TileEntity(this.xCoord, (short) this.yCoord, this.zCoord, this.mID, this.mCoverSides[0], this.mCoverSides[1], this.mCoverSides[2], this.mCoverSides[3], this.mCoverSides[4], this.mCoverSides[5], this.oTextureData = (byte) ((this.mFacing & 7) | (this.mActive ? 8 : 0) | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)), this.oUpdateData = this.hasValidMetaTileEntity() ? this.mMetaTileEntity.getUpdateData() : 0, this.oRedstoneData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) | ((this.mSidedRedstone[1] > 0) ? 2 : 0) | ((this.mSidedRedstone[2] > 0) ? 4 : 0) | ((this.mSidedRedstone[3] > 0) ? 8 : 0) | ((this.mSidedRedstone[4] > 0) ? 16 : 0) | ((this.mSidedRedstone[5] > 0) ? 32 : 0)), this.oColor = this.mColor), this.xCoord, this.zCoord); - this.mSendClientData = false; - } - } - - if (this.mTickTimer > 10) { - byte tData = (byte) ((this.mFacing & 7) | (this.mActive ? 8 : 0) | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); - if (tData != this.oTextureData) { - this.sendBlockEvent((byte) 0, this.oTextureData = tData); - } - tData = this.mMetaTileEntity.getUpdateData(); - if (tData != this.oUpdateData) { - this.sendBlockEvent((byte) 1, this.oUpdateData = tData); - } - if (this.mColor != this.oColor) { - this.sendBlockEvent((byte) 2, this.oColor = this.mColor); - } - tData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) | ((this.mSidedRedstone[1] > 0) ? 2 : 0) | ((this.mSidedRedstone[2] > 0) ? 4 : 0) | ((this.mSidedRedstone[3] > 0) ? 8 : 0) | ((this.mSidedRedstone[4] > 0) ? 16 : 0) | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != this.oRedstoneData) { - this.sendBlockEvent((byte) 3, this.oRedstoneData = tData); - } - if (this.mLightValue != this.oLightValue) { - this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord, this.mLightValue); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord + 1); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord - 1); - this.issueTextureUpdate(); - this.sendBlockEvent((byte) 7, this.oLightValue = this.mLightValue); - } - } - - if (this.mNeedsBlockUpdate) { - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockOffset(0, 0, 0)); - this.mNeedsBlockUpdate = false; - } - } - default: - tCode = -1; - break; - } - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (this.isServerSide() && this.hasValidMetaTileEntity()) { - tTime = System.currentTimeMillis() - tTime; - if (this.mTimeStatistics.length > 0) { - this.mTimeStatistics[this.mTimeStatisticsIndex = (this.mTimeStatisticsIndex + 1) % this.mTimeStatistics.length] = (int) tTime; - } - if ((tTime > 0) && (tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING) && (this.mTickTimer > 1000) && this.getMetaTileEntity().doTickProfilingMessageDuringThisTick() && (this.mLagWarningCount++ < 10)) { - System.out.println("WARNING: Possible Lag Source at [" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + "] in Dimension " + this.worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + this.getMetaTileEntity().getClass()); - } - } - - this.mWorkUpdate = this.mInventoryChanged = this.mRunningThroughTick = false; - } - - @Override - public Packet getDescriptionPacket() { - this.issueClientUpdate(); - return null; - } - - public final void receiveMetaTileEntityData(final short aID, final int aCover0, final int aCover1, final int aCover2, final int aCover3, final int aCover4, final int aCover5, final byte aTextureData, final byte aUpdateData, final byte aRedstoneData, final byte aColorData) { - this.issueTextureUpdate(); - if ((this.mID != aID) && (aID > 0)) { - this.mID = aID; - this.createNewMetatileEntity(this.mID); - } - - this.mCoverSides[0] = aCover0; - this.mCoverSides[1] = aCover1; - this.mCoverSides[2] = aCover2; - this.mCoverSides[3] = aCover3; - this.mCoverSides[4] = aCover4; - this.mCoverSides[5] = aCover5; - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - - this.receiveClientEvent(0, aTextureData); - this.receiveClientEvent(1, aUpdateData); - this.receiveClientEvent(2, aColorData); - this.receiveClientEvent(3, aRedstoneData); - } - - @Override - public boolean receiveClientEvent(final int aEventID, int aValue) { - super.receiveClientEvent(aEventID, aValue); - - if (this.hasValidMetaTileEntity()) { - try { - this.mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (this.isClientSide()) { - this.issueTextureUpdate(); - switch (aEventID) { - case 0: - this.mFacing = (byte) (aValue & 7); - this.mActive = ((aValue & 8) != 0); - this.mRedstone = ((aValue & 16) != 0); - //mLockUpgrade = ((aValue&32) != 0); - break; - case 1: - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.onValueUpdate((byte) aValue); - } - break; - case 2: - if ((aValue > 16) || (aValue < 0)) { - aValue = 0; - } - this.mColor = (byte) aValue; - break; - case 3: - this.mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - this.mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - this.mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - this.mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - this.mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - this.mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); - break; - case 4: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.doSound((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 5: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.startSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 6: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.stopSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 7: - this.mLightValue = (byte) aValue; - break; - } - } - return true; - } - - public ArrayList<String> getDebugInfo(final EntityPlayer aPlayer, final int aLogLevel) { - final ArrayList<String> tList = new ArrayList<>(); - if (aLogLevel > 2) { - tList.add("Meta-ID: " + this.mID + (this.canAccessData() ? " valid" : " invalid") + (this.mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); - } - if (aLogLevel > 1) { - if (this.mTimeStatistics.length > 0) { - double tAverageTime = 0; - for (final int tTime : this.mTimeStatistics) { - tAverageTime += tTime; - } - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / this.mTimeStatistics.length) + "ms over the last " + this.mTimeStatistics.length + " ticks."); - } - if (this.mLagWarningCount > 0) { - tList.add("This TileEntity has also caused " + (this.mLagWarningCount >= 10 ? "more than 10" : this.mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); - } - tList.add("Is" + (this.mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); - } - if (aLogLevel > 0) { - if ((this.getSteamCapacity() > 0) && this.hasSteamEngineUpgrade()) { - tList.add(this.getStoredSteam() + " of " + this.getSteamCapacity() + " Steam"); - } - tList.add("Machine is " + (this.mActive ? "active" : "inactive")); - if (!this.mHasEnoughEnergy) { - tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process."); - } - } - return this.mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); - } - - @Override - public void issueTextureUpdate() { - this.mNeedsUpdate = true; - } - - @Override - public void issueBlockUpdate() { - this.mNeedsBlockUpdate = true; - } - - @Override - public void issueClientUpdate() { - this.mSendClientData = true; - } - - @Override - public void issueCoverUpdate(final byte aSide) { - this.issueClientUpdate(); - } - - @Override - public byte getStrongestRedstone() { - return (byte) Math.max(this.getInternalInputRedstoneSignal((byte) 0), Math.max(this.getInternalInputRedstoneSignal((byte) 1), Math.max(this.getInternalInputRedstoneSignal((byte) 2), Math.max(this.getInternalInputRedstoneSignal((byte) 3), Math.max(this.getInternalInputRedstoneSignal((byte) 4), this.getInternalInputRedstoneSignal((byte) 5)))))); - } - - @Override - public boolean getRedstone() { - return this.getRedstone((byte) 0) || this.getRedstone((byte) 1) || this.getRedstone((byte) 2) || this.getRedstone((byte) 3) || this.getRedstone((byte) 4) || this.getRedstone((byte) 5); - } - - @Override - public boolean getRedstone(final byte aSide) { - return this.getInternalInputRedstoneSignal(aSide) > 0; - } - - public ITexture getCoverTexture(final byte aSide) { - return GregTech_API.sCovers.get(new GT_ItemStack(this.getCoverIDAtSide(aSide))); - } - - @Override - public boolean isGivingInformation() { - if (this.canAccessData()) { - return this.mMetaTileEntity.isGivingInformation(); - } - return false; - } - - @Override - public boolean isValidFacing(final byte aSide) { - if (this.canAccessData()) { - return this.mMetaTileEntity.isFacingValid(aSide); - } - return false; - } - - @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide(this.mFacing); - } - - @Override - public byte getFrontFacing() { - return this.mFacing; - } - - @Override - public void setFrontFacing(final byte aFacing) { - if (this.isValidFacing(aFacing)) { - this.mFacing = aFacing; - this.mMetaTileEntity.onFacingChange(); - this.onMachineBlockUpdate(); - } - } - - @Override - public int getSizeInventory() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getSizeInventory(); - } - return 0; - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - if (this.canAccessData()) { - return this.mMetaTileEntity.getStackInSlot(aIndex); - } - return null; - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - this.mInventoryChanged = true; - if (this.canAccessData()) { - this.mMetaTileEntity.setInventorySlotContents(aIndex, this.worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); - } - } - - @Override - public String getInventoryName() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getInventoryName(); - } - if (GregTech_API.METATILEENTITIES[this.mID] != null) { - return GregTech_API.METATILEENTITIES[this.mID].getInventoryName(); - } - return ""; - } - - @Override - public int getInventoryStackLimit() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getInventoryStackLimit(); - } - return 64; - } - - @Override - public void openInventory() { - if (this.canAccessData()) { - this.mMetaTileEntity.onOpenGUI(); - } - } - - @Override - public void closeInventory() { - if (this.canAccessData()) { - this.mMetaTileEntity.onCloseGUI(); - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer aPlayer) { - return this.canAccessData() && this.playerOwnsThis(aPlayer, false) && (this.mTickTimer > 40) && (this.getTileEntityOffset(0, 0, 0) == this) && (aPlayer.getDistanceSq(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5) < 64) && this.mMetaTileEntity.isAccessAllowed(aPlayer); - } - - @Override - public void validate() { - super.validate(); - this.mTickTimer = 0; - } - - @Override - public void invalidate() { - this.tileEntityInvalid = false; - if (this.canAccessData()) { - this.mMetaTileEntity.onRemoval(); - this.mMetaTileEntity.setBaseMetaTileEntity(null); - } - super.invalidate(); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - final ItemStack stack = this.getStackInSlot(slot); - if (stack != null) { - this.setInventorySlotContents(slot, null); - } - return stack; - } - - @Override - public void onMachineBlockUpdate() { - if (this.canAccessData()) { - this.mMetaTileEntity.onMachineBlockUpdate(); - } - } - - @Override - public int getProgress() { - return this.canAccessData() ? this.mMetaTileEntity.getProgresstime() : 0; - } - - @Override - public int getMaxProgress() { - return this.canAccessData() ? this.mMetaTileEntity.maxProgresstime() : 0; - } - - @Override - public boolean increaseProgress(final int aProgressAmountInTicks) { - return this.canAccessData() ? this.mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false; - } - - @Override - public boolean hasThingsToDo() { - return this.getMaxProgress() > 0; - } - - @Override - public void enableWorking() { - if (!this.mWorks) { - this.mWorkUpdate = true; - } - this.mWorks = true; - } - - @Override - public void disableWorking() { - this.mWorks = false; - } - - @Override - public boolean isAllowedToWork() { - return this.mWorks; - } - - @Override - public boolean hasWorkJustBeenEnabled() { - return this.mWorkUpdate; - } - - @Override - public byte getWorkDataValue() { - return this.mWorkData; - } - - @Override - public void setWorkDataValue(final byte aValue) { - this.mWorkData = aValue; - } - - @Override - public int getMetaTileID() { - return this.mID; - } - - @Override - public int setMetaTileID(final short aID) { - return this.mID = aID; - } - - @Override - public boolean isActive() { - return this.mActive; - } - - @Override - public void setActive(final boolean aActive) { - this.mActive = aActive; - } - - @Override - public long getTimer() { - return this.mTickTimer; - } - - @Override - public boolean decreaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } - return this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || this.decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (this.decreaseStoredSteam(aEnergy, true))); - } - - @Override - public boolean increaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { - if (!this.canAccessData()) { - return false; - } - if ((this.getStoredEU() < this.getEUCapacity()) || aIgnoreTooMuchEnergy) { - this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy); - return true; - } - return false; - } - - @Override - public boolean inputEnergyFrom(final byte aSide) { - if (aSide == 6) { - return true; - } - if (this.isServerSide()) { - return ((aSide >= 0) && (aSide < 6) ? this.mActiveEUInputs[aSide] : false) && !this.mReleaseEnergy; - } - return this.isEnergyInputSide(aSide); - } - - @Override - public boolean outputsEnergyTo(final byte aSide) { - if (aSide == 6) { - return true; - } - if (this.isServerSide()) { - return ((aSide >= 0) && (aSide < 6) ? this.mActiveEUOutputs[aSide] : false) || this.mReleaseEnergy; - } - return this.isEnergyOutputSide(aSide); - } - - @Override - public long getOutputAmperage() { - if (this.canAccessData() && this.mMetaTileEntity.isElectric()) { - return this.mMetaTileEntity.maxAmperesOut(); - } - return 0; - } - - @Override - public long getOutputVoltage() { - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { - return this.mMetaTileEntity.maxEUOutput(); - } - return 0; - } - - @Override - public long getInputAmperage() { - if (this.canAccessData() && this.mMetaTileEntity.isElectric()) { - return this.mMetaTileEntity.maxAmperesIn(); - } - return 0; - } - - @Override - public long getInputVoltage() { - if (this.canAccessData() && this.mMetaTileEntity.isElectric()) { - return this.mMetaTileEntity.maxEUInput(); - } - return Integer.MAX_VALUE; - } - - @Override - public boolean increaseStoredSteam(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { - if (!this.canAccessData()) { - return false; - } - if ((this.mMetaTileEntity.getSteamVar() < this.getSteamCapacity()) || aIgnoreTooMuchEnergy) { - this.setStoredSteam(this.mMetaTileEntity.getSteamVar() + aEnergy); - return true; - } - return false; - } - - @Override - public String[] getDescription() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getDescription(); - } - return new String[0]; - } - - @Override - public boolean isValidSlot(final int aIndex) { - if (this.canAccessData()) { - return this.mMetaTileEntity.isValidSlot(aIndex); - } - return false; - } - - @Override - public long getUniversalEnergyStored() { - return Math.max(this.getStoredEU(), this.getStoredSteam()); - } - - @Override - public long getUniversalEnergyCapacity() { - return Math.max(this.getEUCapacity(), this.getSteamCapacity()); - } - - @Override - public long getStoredEU() { - if (this.canAccessData()) { - return Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()); - } - return 0; - } - - @Override - public long getEUCapacity() { - if (this.canAccessData()) { - return this.mMetaTileEntity.maxEUStore(); - } - return 0; - } - - @Override - public long getStoredSteam() { - if (this.canAccessData()) { - return Math.min(this.mMetaTileEntity.getSteamVar(), this.getSteamCapacity()); - } - return 0; - } - - @Override - public long getSteamCapacity() { - if (this.canAccessData()) { - return this.mMetaTileEntity.maxSteamStore(); - } - return 0; - } - - private boolean isEnergyInputSide(final byte aSide) { - if ((aSide >= 0) && (aSide < 6)) { - if (!this.getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { - return false; - } - if (this.isInvalid() || this.mReleaseEnergy) { - return false; - } - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) { - return this.mMetaTileEntity.isInputFacing(aSide); - } - } - return false; - } - - private boolean isEnergyOutputSide(final byte aSide) { - if ((aSide >= 0) && (aSide < 6)) { - if (!this.getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { - return false; - } - if (this.isInvalid() || this.mReleaseEnergy) { - return this.mReleaseEnergy; - } - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { - return this.mMetaTileEntity.isOutputFacing(aSide); - } - } - return false; - } - - protected boolean hasValidMetaTileEntity() { - return (this.mMetaTileEntity != null) && (this.mMetaTileEntity.getBaseMetaTileEntity() == this); - } - - protected boolean canAccessData() { - return !this.isDead && this.hasValidMetaTileEntity(); - } - - public boolean setStoredEU(long aEnergy) { - if (!this.canAccessData()) { - return false; - } - if (aEnergy < 0) { - aEnergy = 0; - } - this.mMetaTileEntity.setEUVar(aEnergy); - return true; - } - - public boolean setStoredSteam(long aEnergy) { - if (!this.canAccessData()) { - return false; - } - if (aEnergy < 0) { - aEnergy = 0; - } - this.mMetaTileEntity.setSteamVar(aEnergy); - return true; - } - - public boolean decreaseStoredEU(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } - if (((this.mMetaTileEntity.getEUVar() - aEnergy) >= 0) || aIgnoreTooLessEnergy) { - this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy); - if (this.mMetaTileEntity.getEUVar() < 0) { - this.setStoredEU(0); - return false; - } - return true; - } - return false; - } - - public boolean decreaseStoredSteam(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } - if (((this.mMetaTileEntity.getSteamVar() - aEnergy) >= 0) || aIgnoreTooLessEnergy) { - this.setStoredSteam(this.mMetaTileEntity.getSteamVar() - aEnergy); - if (this.mMetaTileEntity.getSteamVar() < 0) { - this.setStoredSteam(0); - return false; - } - return true; - } - return false; - } - - public boolean playerOwnsThis(final EntityPlayer aPlayer, final boolean aCheckPrecicely) { - if (!this.canAccessData()) { - return false; - } - if (aCheckPrecicely || this.privateAccess() || this.mOwnerName.equals("")) { - if (this.mOwnerName.equals("") && this.isServerSide()) { - this.setOwnerName(aPlayer.getDisplayName()); - } else if (this.privateAccess() && !aPlayer.getDisplayName().equals("Player") && !this.mOwnerName.equals("Player") && !this.mOwnerName.equals(aPlayer.getDisplayName())) { - return false; - } - } - return true; - } - - public boolean privateAccess() { - if (!this.canAccessData()) { - return this.mLockUpgrade; - } - return this.mLockUpgrade || this.mMetaTileEntity.ownerControl(); - } - - public void doEnergyExplosion() { - if ((this.getUniversalEnergyCapacity() > 0) && (this.getUniversalEnergyStored() >= (this.getUniversalEnergyCapacity() / 5))) { - this.doExplosion(this.oOutput * (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4 : this.getUniversalEnergyStored() >= (this.getUniversalEnergyCapacity() / 2) ? 2 : 1)); - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "electricproblems"); - } - } - - @Override - public void doExplosion(final long aAmount) { - if (this.canAccessData()) { - // This is only for Electric Machines - if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { - try { - this.mReleaseEnergy = true; - IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, this.getStoredEU() / V[5]), this); - } catch (final Exception e) {/* Fun Fact: all these "do nothing" Comments you see in my Code, are just there to let Eclipse shut up about the intended empty Brackets, but I need eclipse to yell at me in some of the regular Cases where I forget to add Code */} - } - this.mReleaseEnergy = false; - // Normal Explosion Code - this.mMetaTileEntity.onExplosion(); - this.mMetaTileEntity.doExplosion(aAmount); - } - } - - @Override - public ArrayList<ItemStack> getDrops() { - final ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.mID); - final NBTTagCompound tNBT = new NBTTagCompound(); - if ((this.mRecipeStuff != null) && !this.mRecipeStuff.hasNoTags()) { - tNBT.setTag("GT.CraftingComponents", this.mRecipeStuff); - } - if (this.mMuffler) { - tNBT.setBoolean("mMuffler", this.mMuffler); - } - if (this.mLockUpgrade) { - tNBT.setBoolean("mLockUpgrade", this.mLockUpgrade); - } - if (this.mSteamConverter) { - tNBT.setBoolean("mSteamConverter", this.mSteamConverter); - } - if (this.mColor > 0) { - tNBT.setByte("mColor", this.mColor); - } - if (this.mOtherUpgrades > 0) { - tNBT.setByte("mOtherUpgrades", this.mOtherUpgrades); - } - if (this.mStrongRedstone > 0) { - tNBT.setByte("mStrongRedstone", this.mStrongRedstone); - } - for (byte i = 0; i < this.mCoverSides.length; i++) { - if (this.mCoverSides[i] != 0) { - tNBT.setIntArray("mCoverData", this.mCoverData); - tNBT.setIntArray("mCoverSides", this.mCoverSides); - break; - } - } - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.setItemNBT(tNBT); - } - if (!tNBT.hasNoTags()) { - rStack.setTagCompound(tNBT); - } - return new ArrayList<>(Arrays.asList(rStack)); - } - - public int getUpgradeCount() { - return (this.mMuffler ? 1 : 0) + (this.mLockUpgrade ? 1 : 0) + (this.mSteamConverter ? 1 : 0) + this.mOtherUpgrades; - } - - @Override - public boolean onRightclick(final EntityPlayer aPlayer, final byte aSide, final float aX, final float aY, final float aZ) { - if (this.isClientSide()) { - if (this.getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { - return true; - } - if (!this.getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { - return false; - } - } - if (this.isServerSide()) { - if (!this.privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(this.getOwnerName())) { - final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if ((this.getColorization() >= 0) && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { - tCurrentItem.func_150996_a(Items.bucket); - this.setColorization((byte) (this.getColorization() >= 16 ? -2 : -1)); - return true; - } - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if (this.mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { - GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { - this.setCoverDataAtSide(aSide, this.getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); - this.mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - this.mInputDisabled = !this.mInputDisabled; - if (this.mInputDisabled) { - this.mOutputDisabled = !this.mOutputDisabled; - } - GT_Utility.sendChatToPlayer(aPlayer, "Auto-Input: " + (this.mInputDisabled ? "Disabled" : "Enabled") + " Auto-Output: " + (this.mOutputDisabled ? "Disabled" : "Enabled")); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - if (this.mWorks) { - this.disableWorking(); - } else { - this.enableWorking(); - } - GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (this.isAllowedToWork() ? "Enabled" : "Disabled")); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { - this.mStrongRedstone ^= (1 << tSide); - GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((this.mStrongRedstone & (1 << tSide)) != 0 ? "Strong" : "Weak")); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - - if (this.getCoverIDAtSide(aSide) == 0) { - if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide, new GT_ItemStack(tCurrentItem), this) && this.mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) { - this.setCoverItemAtSide(aSide, tCurrentItem); - if (!aPlayer.capabilities.isCreativeMode) { - tCurrentItem.stackSize--; - } - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - } else { - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - this.dropCover(aSide, aSide, false); - } - return true; - } - } - } - - if (this.getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) { - return true; - } - - if (!this.getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { - return false; - } - - if (this.isUpgradable() && (aPlayer.inventory.getCurrentItem() != null)) {/* - if (ItemList.Upgrade_SteamEngine.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (addSteamEngineUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - }*/ - if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (this.addMufflerUpgrade()) { - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - if (!aPlayer.capabilities.isCreativeMode) { - aPlayer.inventory.getCurrentItem().stackSize--; - } - } - return true; - } - if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (this.isUpgradable() && !this.mLockUpgrade) { - this.mLockUpgrade = true; - this.setOwnerName(aPlayer.getDisplayName()); - GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, this.xCoord, this.yCoord, this.zCoord); - if (!aPlayer.capabilities.isCreativeMode) { - aPlayer.inventory.getCurrentItem().stackSize--; - } - } - return true; - } - } - } - } - - try { - if (this.hasValidMetaTileEntity()) { - return this.mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); - } - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - - return true; - } - - @Override - public void onLeftclick(final EntityPlayer aPlayer) { - try { - if ((aPlayer != null) && this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.onLeftclick(this, aPlayer); - } - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - @Override - public boolean isDigitalChest() { - if (this.canAccessData()) { - return this.mMetaTileEntity.isDigitalChest(); - } - return false; - } - - @Override - public ItemStack[] getStoredItemData() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getStoredItemData(); - } - return null; - } - - @Override - public void setItemCount(final int aCount) { - if (this.canAccessData()) { - this.mMetaTileEntity.setItemCount(aCount); - } - } - - @Override - public int getMaxItemCount() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getMaxItemCount(); - } - return 0; - } - - /** - * Can put aStack into Slot - */ - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - return this.canAccessData() && this.mMetaTileEntity.isItemValidForSlot(aIndex, aStack); - } - - /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. - */ - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - if (this.canAccessData() && (this.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), -1, this) || this.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), -1, this))) { - return this.mMetaTileEntity.getAccessibleSlotsFromSide(aSide); - } - return new int[0]; - } - - /** - * Can put aStack into Slot at Side - */ - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled) && this.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), aIndex, this) && this.mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); - } - - /** - * Can pull aStack out of Slot from Side - */ - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled) && this.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), aIndex, this) && this.mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); - } - - @Override - public boolean isUpgradable() { - return this.canAccessData() && (this.getUpgradeCount() < 8); - } - - @Override - public byte getInternalInputRedstoneSignal(final byte aSide) { - return (byte) (this.getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, this.getInputRedstoneSignal(aSide), this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this) & 15); - } - - @Override - public byte getInputRedstoneSignal(final byte aSide) { - return (byte) (this.worldObj.getIndirectPowerLevelTo(this.getOffsetX(aSide, 1), this.getOffsetY(aSide, 1), this.getOffsetZ(aSide, 1), aSide) & 15); - } - - @Override - public byte getOutputRedstoneSignal(final byte aSide) { - return this.getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this) ? this.mSidedRedstone[aSide] : 0; - // return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0); - } - - @Override - public void setInternalOutputRedstoneSignal(final byte aSide, final byte aStrength) { - if (!this.getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { - this.setOutputRedstoneSignal(aSide, aStrength); - } - } - - @Override - public void setOutputRedstoneSignal(final byte aSide, byte aStrength) { - aStrength = (byte) Math.min(Math.max(0, aStrength), 15); - if ((aSide >= 0) && (aSide < 6) && (this.mSidedRedstone[aSide] != aStrength)) { - this.mSidedRedstone[aSide] = aStrength; - this.issueBlockUpdate(); - } - } - - @Override - public boolean isSteamEngineUpgradable() { - return this.isUpgradable() && !this.hasSteamEngineUpgrade() && (this.getSteamCapacity() > 0); - } - - @Override - public boolean addSteamEngineUpgrade() { - if (this.isSteamEngineUpgradable()) { - this.issueBlockUpdate(); - this.mSteamConverter = true; - return true; - } - return false; - } - - @Override - public boolean hasSteamEngineUpgrade() { - if (this.canAccessData() && this.mMetaTileEntity.isSteampowered()) { - return true; - } - return this.mSteamConverter; - } - - @Override - public boolean hasMufflerUpgrade() { - return this.mMuffler; - } - - @Override - public boolean isMufflerUpgradable() { - return this.isUpgradable() && !this.hasMufflerUpgrade(); - } - - @Override - public boolean addMufflerUpgrade() { - if (this.isMufflerUpgradable()) { - return this.mMuffler = true; - } - return false; - } - - @Override - public boolean hasInventoryBeenModified() { - return this.mInventoryChanged; - } - - @Override - public void setGenericRedstoneOutput(final boolean aOnOff) { - this.mRedstone = aOnOff; - } - - @Override - public int getErrorDisplayID() { - return this.mDisplayErrorCode; - } - - @Override - public void setErrorDisplayID(final int aErrorID) { - this.mDisplayErrorCode = aErrorID; - } - - @Override - public IMetaTileEntity getMetaTileEntity() { - return this.hasValidMetaTileEntity() ? this.mMetaTileEntity : null; - } - - @Override - public void setMetaTileEntity(final IMetaTileEntity aMetaTileEntity) { - this.mMetaTileEntity = (MetaTileEntity) aMetaTileEntity; - } - - @Override - public GT_CoverBehavior getCoverBehaviorAtSide(final byte aSide) { - return (aSide >= 0) && (aSide < this.mCoverBehaviors.length) ? this.mCoverBehaviors[aSide] : GregTech_API.sNoBehavior; - } - - @Override - public void setCoverIDAtSide(final byte aSide, final int aID) { - if ((aSide >= 0) && (aSide < 6)) { - this.mCoverSides[aSide] = aID; - this.mCoverData[aSide] = 0; - this.mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); - this.issueCoverUpdate(aSide); - this.issueBlockUpdate(); - } - } - - @Override - public void setCoverItemAtSide(final byte aSide, final ItemStack aCover) { - GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); - } - - @Override - public int getCoverIDAtSide(final byte aSide) { - if ((aSide >= 0) && (aSide < 6)) { - return this.mCoverSides[aSide]; - } - return 0; - } - - @Override - public ItemStack getCoverItemAtSide(final byte aSide) { - return GT_Utility.intToStack(this.getCoverIDAtSide(aSide)); - } - - @Override - public boolean canPlaceCoverIDAtSide(final byte aSide, final int aID) { - return this.getCoverIDAtSide(aSide) == 0; - } - - @Override - public boolean canPlaceCoverItemAtSide(final byte aSide, final ItemStack aCover) { - return this.getCoverIDAtSide(aSide) == 0; - } - - @Override - public void setCoverDataAtSide(final byte aSide, final int aData) { - if ((aSide >= 0) && (aSide < 6)) { - this.mCoverData[aSide] = aData; - } - } - - @Override - public int getCoverDataAtSide(final byte aSide) { - if ((aSide >= 0) && (aSide < 6)) { - return this.mCoverData[aSide]; - } - return 0; - } - - public byte getLightValue() { - return this.mLightValue; - } - - @Override - public void setLightValue(final byte aLightValue) { - this.mLightValue = (byte) (aLightValue & 15); - } - - @Override - public long getAverageElectricInput() { - int rEU = 0; - for (final int tEU : this.mAverageEUInput) { - rEU += tEU; - } - return rEU / this.mAverageEUInput.length; - } - - @Override - public long getAverageElectricOutput() { - int rEU = 0; - for (final int tEU : this.mAverageEUOutput) { - rEU += tEU; - } - return rEU / this.mAverageEUOutput.length; - } - - @Override - public boolean dropCover(final byte aSide, final byte aDroppedSide, final boolean aForced) { - if (this.getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, this.getCoverIDAtSide(aSide), this.mCoverData[aSide], this, aForced) || aForced) { - final ItemStack tStack = this.getCoverBehaviorAtSide(aSide).getDrop(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this); - if (tStack != null) { - tStack.setTagCompound(null); - final EntityItem tEntity = new EntityItem(this.worldObj, this.getOffsetX(aDroppedSide, 1) + 0.5, this.getOffsetY(aDroppedSide, 1) + 0.5, this.getOffsetZ(aDroppedSide, 1) + 0.5, tStack); - tEntity.motionX = 0; - tEntity.motionY = 0; - tEntity.motionZ = 0; - this.worldObj.spawnEntityInWorld(tEntity); - } - this.setCoverIDAtSide(aSide, 0); - if (this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - this.setOutputRedstoneSignal(aSide, (byte) 0); - } else { - this.setOutputRedstoneSignal(aSide, (byte) 15); - } - return true; - } - return false; - } - - @Override - public String getOwnerName() { - if (GT_Utility.isStringInvalid(this.mOwnerName)) { - return "Player"; - } - return this.mOwnerName; - } - - @Override - public String setOwnerName(final String aName) { - if (GT_Utility.isStringInvalid(aName)) { - return this.mOwnerName = "Player"; - } - return this.mOwnerName = aName; - } - - @Override - public byte getComparatorValue(final byte aSide) { - return this.canAccessData() ? this.mMetaTileEntity.getComparatorValue(aSide) : 0; - } - - @Override - public byte getStrongOutputRedstoneSignal(final byte aSide) { - return (aSide >= 0) && (aSide < 6) && ((this.mStrongRedstone & (1 << aSide)) != 0) ? (byte) (this.mSidedRedstone[aSide] & 15) : 0; - } - - @Override - public void setStrongOutputRedstoneSignal(final byte aSide, final byte aStrength) { - this.mStrongRedstone |= (1 << aSide); - this.setOutputRedstoneSignal(aSide, aStrength); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - if (this.canAccessData()) { - this.mInventoryChanged = true; - return this.mMetaTileEntity.decrStackSize(aIndex, aAmount); - } - return null; - } - - @Override - public long injectEnergyUnits(final byte aSide, final long aVoltage, long aAmperage) { - if (!this.canAccessData() || !this.mMetaTileEntity.isElectric() || !this.inputEnergyFrom(aSide) || (aAmperage <= 0) || (aVoltage <= 0) || (this.getStoredEU() >= this.getEUCapacity()) || (this.mMetaTileEntity.maxAmperesIn() <= this.mAcceptedAmperes)) { - return 0; - } - if (aVoltage > this.getInputVoltage()) { - this.doExplosion(aVoltage); - return 0; - } - if (this.increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(this.mMetaTileEntity.maxAmperesIn() - this.mAcceptedAmperes, 1 + ((this.getEUCapacity() - this.getStoredEU()) / aVoltage)))), true)) { - this.mAverageEUInput[this.mAverageEUInputIndex] += aVoltage * aAmperage; - this.mAcceptedAmperes += aAmperage; - return aAmperage; - } - return 0; - } - - @Override - public boolean drainEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - if (!this.canAccessData() || !this.mMetaTileEntity.isElectric() || !this.outputsEnergyTo(aSide) || ((this.getStoredEU() - (aVoltage * aAmperage)) < this.mMetaTileEntity.getMinimumStoredEU())) { - return false; - } - if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { - this.mAverageEUOutput[this.mAverageEUOutputIndex] += aVoltage * aAmperage; - return true; - } - return false; - } - - @Override - public boolean acceptsRotationalEnergy(final byte aSide) { - if (!this.canAccessData() || (this.getCoverIDAtSide(aSide) != 0)) { - return false; - } - return this.mMetaTileEntity.acceptsRotationalEnergy(aSide); - } - - @Override - public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) { - if (!this.canAccessData() || (this.getCoverIDAtSide(aSide) != 0)) { - return false; - } - return this.mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); - } - - @Override - public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { - if ((this.mTickTimer > 5) && this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled) && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) { - return this.mMetaTileEntity.fill(aSide, aFluid, doFill); - } - return 0; - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) { - if ((this.mTickTimer > 5) && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled) && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), this.mMetaTileEntity.getFluid() == null ? null : this.mMetaTileEntity.getFluid().getFluid(), this)))) { - return this.mMetaTileEntity.drain(aSide, maxDrain, doDrain); - } - return null; - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - if ((this.mTickTimer > 5) && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled) && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) { - return this.mMetaTileEntity.drain(aSide, aFluid, doDrain); - } - return null; - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - if ((this.mTickTimer > 5) && this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled) && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) { - return this.mMetaTileEntity.canFill(aSide, aFluid); - } - return false; - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - if ((this.mTickTimer > 5) && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled) && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) { - return this.mMetaTileEntity.canDrain(aSide, aFluid); - } - return false; - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - if (this.canAccessData() && ((aSide == ForgeDirection.UNKNOWN) || (this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this.getCoverDataAtSide((byte) aSide.ordinal()), null, this)))) { - return this.mMetaTileEntity.getTankInfo(aSide); - } - return new FluidTankInfo[]{}; - } - - public double getOutputEnergyUnitsPerTick() { - return this.oOutput; - } - - public boolean isTeleporterCompatible(final ForgeDirection aSide) { - return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); - } - - public double demandedEnergyUnits() { - if (this.mReleaseEnergy || !this.canAccessData() || !this.mMetaTileEntity.isEnetInput()) { - return 0; - } - return this.getEUCapacity() - this.getStoredEU(); - } - - public double injectEnergyUnits(final ForgeDirection aDirection, final double aAmount) { - return this.injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount; - } - - public boolean acceptsEnergyFrom(final TileEntity aEmitter, final ForgeDirection aDirection) { - return this.inputEnergyFrom((byte) aDirection.ordinal()); - } - - public boolean emitsEnergyTo(final TileEntity aReceiver, final ForgeDirection aDirection) { - return this.outputsEnergyTo((byte) aDirection.ordinal()); - } - - public double getOfferedEnergy() { - return (this.canAccessData() && ((this.getStoredEU() - this.mMetaTileEntity.getMinimumStoredEU()) >= this.oOutput)) ? Math.max(0, this.oOutput) : 0; - } - - public void drawEnergy(final double amount) { - this.mAverageEUOutput[this.mAverageEUOutputIndex] += amount; - this.decreaseStoredEU((int) amount, true); - } - - public int injectEnergy(final ForgeDirection aForgeDirection, final int aAmount) { - return this.injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount; - } - - public int addEnergy(final int aEnergy) { - if (!this.canAccessData()) { - return 0; - } - if (aEnergy > 0) { - this.increaseStoredEnergyUnits(aEnergy, true); - } else { - this.decreaseStoredEU(-aEnergy, true); - } - return (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getEUVar()); - } - - public boolean isAddedToEnergyNet() { - return false; - } - - public int demandsEnergy() { - if (this.mReleaseEnergy || !this.canAccessData() || !this.mMetaTileEntity.isEnetInput()) { - return 0; - } - return this.getCapacity() - this.getStored(); - } - - public int getCapacity() { - return (int) Math.min(Integer.MAX_VALUE, this.getEUCapacity()); - } - - public int getStored() { - return (int) Math.min(Integer.MAX_VALUE, Math.min(this.getStoredEU(), this.getCapacity())); - } - - public void setStored(final int aEU) { - if (this.canAccessData()) { - this.setStoredEU(aEU); - } - } - - public int getMaxSafeInput() { - return (int) Math.min(Integer.MAX_VALUE, this.getInputVoltage()); - } - - public int getMaxEnergyOutput() { - if (this.mReleaseEnergy) { - return Integer.MAX_VALUE; - } - return this.getOutput(); - } - - public int getOutput() { - return (int) Math.min(Integer.MAX_VALUE, this.oOutput); - } - - public int injectEnergy(final Direction aDirection, final int aAmount) { - return this.injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount; - } - - public boolean isTeleporterCompatible(final Direction aSide) { - return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); - } - - public boolean acceptsEnergyFrom(final TileEntity aReceiver, final Direction aDirection) { - return this.inputEnergyFrom((byte) aDirection.toSideValue()); - } - - public boolean emitsEnergyTo(final TileEntity aReceiver, final Direction aDirection) { - return this.outputsEnergyTo((byte) aDirection.toSideValue()); - } - - @Override - public boolean isInvalidTileEntity() { - return this.isInvalid(); - } - - @Override - public boolean addStackToSlot(final int aIndex, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return true; - } - if ((aIndex < 0) || (aIndex >= this.getSizeInventory())) { - return false; - } - final ItemStack tStack = this.getStackInSlot(aIndex); - if (GT_Utility.isStackInvalid(tStack)) { - this.setInventorySlotContents(aIndex, aStack); - return true; - } - aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) && ((tStack.stackSize + aStack.stackSize) <= Math.min(aStack.getMaxStackSize(), this.getInventoryStackLimit()))) { - tStack.stackSize += aStack.stackSize; - return true; - } - return false; - } - - @Override - public boolean addStackToSlot(final int aIndex, final ItemStack aStack, final int aAmount) { - return this.addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); - } - - @Override - public byte getColorization() { - return (byte) (this.mColor - 1); - } - - @Override - public byte setColorization(byte aColor) { - if ((aColor > 15) || (aColor < -1)) { - aColor = -1; - } - if (this.canAccessData()) { - this.mMetaTileEntity.onColorChangeServer(aColor); - } - return this.mColor = (byte) (aColor + 1); - } - - @Override - public float getBlastResistance(final byte aSide) { - return this.canAccessData() ? Math.max(0, this.getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F; - } - - @Override - public boolean isUniversalEnergyStored(final long aEnergyAmount) { - if (this.getUniversalEnergyStored() >= aEnergyAmount) { - return true; - } - this.mHasEnoughEnergy = false; - return false; - } - - @Override - public String[] getInfoData() { - { - if (this.canAccessData()) { - return this.getMetaTileEntity().getInfoData(); - } - return new String[]{}; - } - } - - @Override - public void markDirty() { - super.markDirty(); - this.mInventoryChanged = true; - } - - @Override - public int getLightOpacity() { - return this.mMetaTileEntity == null ? this.getLightValue() > 0 ? 0 : 255 : this.mMetaTileEntity.getLightOpacity(); - } - - @Override - public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ, final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) { - this.mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { - return this.mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, final Entity collider) { - this.mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - - - public ITexture[] getTexture(final Block arg0, final byte aSide) { - final ITexture rIcon = this.getCoverTexture(aSide); - if (rIcon != null) { - return new ITexture[]{rIcon}; - } - if (this.hasValidMetaTileEntity()) { - return this.mMetaTileEntity.getTexture(this, aSide, this.mFacing, (byte) (this.mColor - 1), this.mActive, this.getOutputRedstoneSignal(aSide) > 0); - } - return Textures.BlockIcons.ERROR_RENDERING; - } - - public ITexture[] getTexture(final byte aSide) { - final ITexture rIcon = this.getCoverTexture(aSide); - if (rIcon != null) { - return new ITexture[]{rIcon}; - } - if (this.hasValidMetaTileEntity()) { - return this.mMetaTileEntity.getTexture(this, aSide, this.mFacing, (byte) (this.mColor - 1), this.mActive, this.getOutputRedstoneSignal(aSide) > 0); - } - return Textures.BlockIcons.ERROR_RENDERING; - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java deleted file mode 100644 index 4f18d76ea5..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java +++ /dev/null @@ -1,663 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * Extend this Class to add a new MetaPipe - * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) - * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity - * <p/> - * Call the Constructor like the following example inside the Load Phase, to register it. - * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" - */ -public abstract class GregtechMetaPipeEntity_BaseSuperConductor implements IMetaTileEntity { - /** - * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! - */ - public final ItemStack[] mInventory; - /** - * This variable tells, which directions the Block is connected to. It is a Bitmask. - */ - public byte mConnections = 0; - /** - * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. - */ - public String mName; - public boolean doTickProfilingInThisTick = true; - /** - * accessibility to this Field is no longer given, see below - */ - private IGregTechTileEntity mBaseMetaTileEntity; - - /** - * This registers your Machine at the List. - * Use only ID's larger than 2048, because i reserved these ones. - * See also the List in the API, as it has a Description containing all the reservations. - * - * @param aID the ID - * @example for Constructor overload. - * <p/> - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { - * super(aID, mName, mNameRegional); - * } - */ - public GregtechMetaPipeEntity_BaseSuperConductor(final int aID, final String aBasicName, final String aRegionalName, final int aInvSlotCount) { - if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) { - throw new IllegalAccessError("This Constructor has to be called in the load Phase"); - } - if (GregTech_API.METATILEENTITIES[aID] == null) { - GregTech_API.METATILEENTITIES[aID] = this; - } else { - throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); - } - this.mName = aBasicName.replaceAll(" ", "_").toLowerCase(); - this.setBaseMetaTileEntity(new BaseMetaPipeEntity()); - this.getBaseMetaTileEntity().setMetaTileID((short) aID); - GT_LanguageManager.addStringLocalization("gt.blockmachines." + this.mName + ".name", aRegionalName); - this.mInventory = new ItemStack[aInvSlotCount]; - - if (GT.isClientSide()) { - final ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); - tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); - } - } - - /** - * This is the normal Constructor. - */ - public GregtechMetaPipeEntity_BaseSuperConductor(final String aName, final int aInvSlotCount) { - this.mInventory = new ItemStack[aInvSlotCount]; - this.mName = aName; - } - - /** - * For Pipe Rendering - */ - public abstract float getThickNess(); - - /** - * For Pipe Rendering - */ - public abstract boolean renderInside(byte aSide); - - @Override - public IGregTechTileEntity getBaseMetaTileEntity() { - return this.mBaseMetaTileEntity; - } - - @Override - public void setBaseMetaTileEntity(final IGregTechTileEntity aBaseMetaTileEntity) { - if ((this.mBaseMetaTileEntity != null) && (aBaseMetaTileEntity == null)) { - this.mBaseMetaTileEntity.getMetaTileEntity().inValidate(); - this.mBaseMetaTileEntity.setMetaTileEntity(null); - } - this.mBaseMetaTileEntity = aBaseMetaTileEntity; - if (this.mBaseMetaTileEntity != null) { - this.mBaseMetaTileEntity.setMetaTileEntity(this); - } - } - - @Override - public ItemStack getStackForm(final long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID()); - } - - @Override - public void onServerStart() {/*Do nothing*/} - - @Override - public void onWorldSave(final File aSaveDirectory) {/*Do nothing*/} - - @Override - public void onWorldLoad(final File aSaveDirectory) {/*Do nothing*/} - - @Override - public void onConfigLoad(final GT_Config aConfig) {/*Do nothing*/} - - @Override - public void setItemNBT(final NBTTagCompound aNBT) {/*Do nothing*/} - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister aBlockIconRegister) {/*Do nothing*/} - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return true; - } - - @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) {/*Do nothing*/} - - @Override - public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - return false; - } - - @Override - public void onExplosion() {/*Do nothing*/} - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {/*Do nothing*/} - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {/*Do nothing*/} - - @Override - public void inValidate() {/*Do nothing*/} - - @Override - public void onRemoval() {/*Do nothing*/} - - @Override - public void initDefaultModes(final NBTTagCompound aNBT) {/*Do nothing*/} - - /** - * When a GUI is opened - */ - public void onOpenGUI() {/*Do nothing*/} - - /** - * When a GUI is closed - */ - public void onCloseGUI() {/*Do nothing*/} - - /** - * a Player rightclicks the Machine - * Sneaky rightclicks are not getting passed to this! - */ - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, final byte aSide, final float aX, final float aY, final float aZ) { - return false; - } - - @Override - public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {/*Do nothing*/} - - @Override - public void onValueUpdate(final byte aValue) {/*Do nothing*/} - - @Override - public byte getUpdateData() { - return 0; - } - - @Override - public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public void stopSoundLoop(final byte aValue, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public final void sendSound(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex); - } - } - - @Override - public final void sendLoopStart(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex); - } - } - - @Override - public final void sendLoopEnd(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex); - } - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return false; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean setStackToZeroInsteadOfNull(final int aIndex) { - return false; - } - - @Override - public ArrayList<String> getSpecialDebugInfo(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, final int aLogLevel, final ArrayList<String> aList) { - return aList; - } - - @Override - public boolean isLiquidInput(final byte aSide) { - return true; - } - - @Override - public boolean isLiquidOutput(final byte aSide) { - return true; - } - - /** - * gets the contained Liquid - */ - @Override - public FluidStack getFluid() { - return null; - } - - /** - * tries to fill this Tank - */ - @Override - public int fill(final FluidStack resource, final boolean doFill) { - return 0; - } - - /** - * tries to empty this Tank - */ - @Override - public FluidStack drain(final int maxDrain, final boolean doDrain) { - return null; - } - - /** - * Tank pressure - */ - public int getTankPressure() { - return 0; - } - - /** - * Liquid Capacity - */ - @Override - public int getCapacity() { - return 0; - } - - /** - * Progress this machine has already made - */ - public int getProgresstime() { - return 0; - } - - /** - * Progress this Machine has to do to produce something - */ - public int maxProgresstime() { - return 0; - } - - /** - * Increases the Progress, returns the overflown Progress. - */ - public int increaseProgress(final int aProgress) { - return 0; - } - - @Override - public void onMachineBlockUpdate() {/*Do nothing*/} - - @Override - public void receiveClientEvent(final byte aEventID, final byte aValue) {/*Do nothing*/} - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public byte getComparatorValue(final byte aSide) { - return 0; - } - - @Override - public boolean acceptsRotationalEnergy(final byte aSide) { - return false; - } - - @Override - public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) { - return false; - } - - @Override - public String getSpecialVoltageToolTip() { - return null; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public String[] getInfoData() { - return new String[]{}; - } - - public boolean isDigitalChest() { - return false; - } - - public ItemStack[] getStoredItemData() { - return null; - } - - public void setItemCount(final int aCount) {/*Do nothing*/} - - public int getMaxItemCount() { - return 0; - } - - @Override - public int getSizeInventory() { - return this.mInventory.length; - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - if ((aIndex >= 0) && (aIndex < this.mInventory.length)) { - return this.mInventory[aIndex]; - } - return null; - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - if ((aIndex >= 0) && (aIndex < this.mInventory.length)) { - this.mInventory[aIndex] = aStack; - } - } - - @Override - public String getInventoryName() { - if (GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()] != null) { - return GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()].getMetaName(); - } - return ""; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - return this.getBaseMetaTileEntity().isValidSlot(aIndex); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final ItemStack tStack = this.getStackInSlot(aIndex); - ItemStack rStack = GT_Utility.copy(tStack); - if (tStack != null) { - if (tStack.stackSize <= aAmount) { - if (this.setStackToZeroInsteadOfNull(aIndex)) { - tStack.stackSize = 0; - } else { - this.setInventorySlotContents(aIndex, null); - } - } else { - rStack = tStack.splitStack(aAmount); - if ((tStack.stackSize == 0) && !this.setStackToZeroInsteadOfNull(aIndex)) { - this.setInventorySlotContents(aIndex, null); - } - } - } - return rStack; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final ArrayList<Integer> tList = new ArrayList<>(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity(); - final boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity); - for (int i = 0; i < this.getSizeInventory(); i++) { - if (this.isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity))) { - tList.add(i); - } - } - final int[] rArray = new int[tList.size()]; - for (int i = 0; i < rArray.length; i++) { - rArray[i] = tList.get(i); - } - return rArray; - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.isValidSlot(aIndex) && (aStack != null) && (aIndex < this.mInventory.length) && ((this.mInventory[aIndex] == null) || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex])) && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.isValidSlot(aIndex) && (aStack != null) && (aIndex < this.mInventory.length) && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - return this.drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - if ((this.getCapacity() <= 0) && !this.getBaseMetaTileEntity().hasSteamEngineUpgrade()) { - return new FluidTankInfo[]{}; - } - return new FluidTankInfo[]{this.getInfo()}; - } - - public int fill_default(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { - return this.fill(aFluid, doFill); - } - - @Override - public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { - return this.fill_default(aSide, aFluid, doFill); - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - if ((this.getFluid() != null) && (aFluid != null) && this.getFluid().isFluidEqual(aFluid)) { - return this.drain(aFluid.amount, doDrain); - } - return null; - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) { - return this.drain(maxDrain, doDrain); - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public FluidTankInfo getInfo() { - return new FluidTankInfo(this); - } - - @Override - public String getMetaName() { - return this.mName; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int i) { - return null; - } - - @Override - public boolean doTickProfilingMessageDuringThisTick() { - return this.doTickProfilingInThisTick; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return false; - } - - @Override - public boolean connectsToItemPipe(final byte aSide) { - return false; - } - - @Override - public void openInventory() { - // - } - - @Override - public void closeInventory() { - // - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public float getExplosionResistance(final byte aSide) { - return 10.0F; - } - - @Override - public ItemStack[] getRealInventory() { - return this.mInventory; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() { - // - } - - @Override - public void onColorChangeServer(final byte aColor) { - // - } - - @Override - public void onColorChangeClient(final byte aColor) { - // - } - - public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInInventory(final Block aBlock, final int aMeta, final RenderBlocks aRenderer) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInWorld(final IBlockAccess aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final RenderBlocks aRenderer) { - return false; - } - - @Override - public void doExplosion(final long aExplosionPower) { - final float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < (V[4] * 2) ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; - final int tX = this.getBaseMetaTileEntity().getXCoord(), tY = this.getBaseMetaTileEntity().getYCoord(), tZ = this.getBaseMetaTileEntity().getZCoord(); - final World tWorld = this.getBaseMetaTileEntity().getWorld(); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) { - tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); - } - } - - @Override - public int getLightOpacity() { - return 0; - } - - @Override - public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ, final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) { - final AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if ((axisalignedbb1 != null) && inputAABB.intersectsWith(axisalignedbb1)) { - outputAABB.add(axisalignedbb1); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - } - - @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, final Entity collider) { - // - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - // - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java deleted file mode 100644 index bf22009b67..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java +++ /dev/null @@ -1,71 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.GT; - -import gregtech.api.interfaces.ITexture; -import gtPlusPlus.core.lib.CORE; - -public abstract class GregtechMetaTileEntityLossless extends MetaTileEntityLossless { - /** - * Value between [0 - 9] to describe the Tier of this Machine. - */ - public final byte mTier; - - /** - * A simple Description. - */ - public final String mDescription; - - /** - * Contains all Textures used by this Block. - */ - public final ITexture[][][] mTextures; - - public GregtechMetaTileEntityLossless(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aInvSlotCount); - this.mTier = (byte)Math.max(0, Math.min(aTier, 9)); - this.mDescription = aDescription; - - // must always be the last call! - if (GT.isClientSide()) { - this.mTextures = this.getTextureSet(aTextures); - } else { - this.mTextures = null; - } - } - - public GregtechMetaTileEntityLossless(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aInvSlotCount); - this.mTier = (byte)aTier; - this.mDescription = aDescription; - this.mTextures = aTextures; - - } - - @Override - public byte getTileEntityBaseType() { - return (byte)(Math.min(3, this.mTier<=0?0:1+((this.mTier-1) / 4))); - } - - @Override - public long getInputTier() { - return this.mTier; - } - - @Override - public long getOutputTier() { - return this.mTier; - } - - @Override - public String[] getDescription() { - return new String[] {this.mDescription, CORE.GT_Tooltip}; - } - - /** - * Used Client Side to get a Texture Set for this Block. - * Called after setting the Tier and the Description so that those two are accessible. - * @param aTextures is the optional Array you can give to the Constructor. - */ - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java deleted file mode 100644 index 75c638c4ea..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java +++ /dev/null @@ -1,265 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually - */ -public abstract class GregtechMetaTileEntityLosslessBasicTank extends GregtechMetaTileEntityLosslessTieredMachineBlock { - - public FluidStack mFluid; - - /** - * @param aInvSlotCount should be 3 - */ - public GregtechMetaTileEntityLosslessBasicTank(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GregtechMetaTileEntityLosslessBasicTank(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex != this.getStackDisplaySlot(); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - if (this.mFluid != null) { - aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - public abstract boolean doesFillContainers(); - - public abstract boolean doesEmptyContainers(); - - public abstract boolean canTankBeFilled(); - - public abstract boolean canTankBeEmptied(); - - public abstract boolean displaysItemStack(); - - public abstract boolean displaysStackSize(); - - public int getInputSlot() { - return 0; - } - - public int getOutputSlot() { - return 1; - } - - public int getStackDisplaySlot() { - return 2; - } - - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return true; - } - - public boolean isFluidChangingAllowed() { - return true; - } - - public FluidStack getFillableStack() { - return this.mFluid; - } - - public FluidStack setFillableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - public FluidStack getDrainableStack() { - return this.mFluid; - } - - public FluidStack setDrainableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - public FluidStack getDisplayedFluid() { - return this.getDrainableStack(); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.isFluidChangingAllowed() && (this.getFillableStack() != null) && (this.getFillableStack().amount <= 0)) { - this.setFillableStack(null); - } - - if (this.displaysItemStack() && (this.getStackDisplaySlot() >= 0) && (this.getStackDisplaySlot() < this.mInventory.length)) { - if (this.getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot()], true, true)) { - this.mInventory[this.getStackDisplaySlot()] = null; - } - } else { - this.mInventory[this.getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(this.getDisplayedFluid(), this.displaysStackSize()); - } - } - - if (this.doesEmptyContainers()) { - final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true); - if ((tFluid != null) && this.isFluidInputAllowed(tFluid)) { - if (this.getFillableStack() == null) { - if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(this.getFillableStack()) && ((tFluid.amount + this.getFillableStack().amount) <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - } - } - - if (this.doesFillContainers()) { - final ItemStack tOutput = GT_Utility.fillFluidContainer(this.getDrainableStack(), this.mInventory[this.getInputSlot()], false, true); - if ((tOutput != null) && aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tOutput, 1)) { - final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - if (tFluid != null) { - this.getDrainableStack().amount -= tFluid.amount; - } - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - } - } - } - } - } - - @Override - public FluidStack getFluid() { - return this.getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; - } - - @Override - public int fill(final FluidStack aFluid, final boolean doFill) { - if ((aFluid == null) || (aFluid.getFluid().getID() <= 0) || (aFluid.amount <= 0) || !this.canTankBeFilled() || !this.isFluidInputAllowed(aFluid)) { - return 0; - } - - if ((this.getFillableStack() == null) || (this.getFillableStack().getFluid().getID() <= 0)) { - if (aFluid.amount <= this.getCapacity()) { - if (doFill) { - this.setFillableStack(aFluid.copy()); - this.getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - this.setFillableStack(aFluid.copy()); - this.getFillableStack().amount = this.getCapacity(); - this.getBaseMetaTileEntity().markDirty(); - } - return this.getCapacity(); - } - - if (!this.getFillableStack().isFluidEqual(aFluid)) { - return 0; - } - - final int space = this.getCapacity() - this.getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - this.getFillableStack().amount += aFluid.amount; - this.getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - this.getFillableStack().amount = this.getCapacity(); - } - return space; - } - - @Override - public FluidStack drain(final int maxDrain, final boolean doDrain) { - if ((this.getDrainableStack() == null) || !this.canTankBeEmptied()) { - return null; - } - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - this.getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (this.getDrainableStack().amount < used) { - used = this.getDrainableStack().amount; - } - - if (doDrain) { - this.getDrainableStack().amount -= used; - this.getBaseMetaTileEntity().markDirty(); - } - - final FluidStack drained = this.getDrainableStack().copy(); - drained.amount = used; - - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - this.getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aIndex == this.getOutputSlot(); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aIndex == this.getInputSlot(); - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java deleted file mode 100644 index df33ec4ae1..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java +++ /dev/null @@ -1,71 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.GT; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.MetaTileEntity; - -public abstract class GregtechMetaTileEntityLosslessTieredMachineBlock extends MetaTileEntity { - /** - * Value between [0 - 9] to describe the Tier of this Machine. - */ - public final byte mTier; - - /** - * A simple Description. - */ - public final String mDescription; - - /** - * Contains all Textures used by this Block. - */ - public final ITexture[][][] mTextures; - - public GregtechMetaTileEntityLosslessTieredMachineBlock(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aInvSlotCount); - this.mTier = (byte) Math.max(0, Math.min(aTier, 9)); - this.mDescription = aDescription; - - // must always be the last call! - if (GT.isClientSide()) { - this.mTextures = this.getTextureSet(aTextures); - } else { - this.mTextures = null; - } - } - - public GregtechMetaTileEntityLosslessTieredMachineBlock(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aInvSlotCount); - this.mTier = (byte) aTier; - this.mDescription = aDescription; - this.mTextures = aTextures; - } - - @Override - public byte getTileEntityBaseType() { - return (byte) (Math.min(3, this.mTier <= 0 ? 0 : 1 + ((this.mTier - 1) / 4))); - } - - @Override - public long getInputTier() { - return this.mTier; - } - - @Override - public long getOutputTier() { - return this.mTier; - } - - @Override - public String[] getDescription() { - return new String[]{this.mDescription}; - } - - /** - * Used Client Side to get a Texture Set for this Block. - * Called after setting the Tier and the Description so that those two are accessible. - * - * @param aTextures is the optional Array you can give to the Constructor. - */ - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java deleted file mode 100644 index 8af73b2024..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java +++ /dev/null @@ -1,889 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * Extend this Class to add a new MetaMachine - * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) - * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity - * <p/> - * Call the Constructor like the following example inside the Load Phase, to register it. - * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" - */ -public abstract class MetaTileEntityLossless implements IMetaTileEntity { - /** - * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. - */ - public final String mName; - /** - * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! - */ - public final ItemStack[] mInventory; - public boolean doTickProfilingInThisTick = true; - /** - * accessibility to this Field is no longer given, see below - */ - private IGregTechTileEntity mBaseMetaTileEntity; - - /** - * This registers your Machine at the List. - * Use only ID's larger than 2048, because i reserved these ones. - * See also the List in the API, as it has a Description containing all the reservations. - * - * @param aID the ID - * @example for Constructor overload. - * <p/> - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { - * super(aID, mName, mNameRegional); - * } - */ - public MetaTileEntityLossless(final int aID, final String aBasicName, final String aRegionalName, final int aInvSlotCount) { - if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) { - throw new IllegalAccessError("This Constructor has to be called in the load Phase"); - } - if (GregTech_API.METATILEENTITIES[aID] == null) { - GregTech_API.METATILEENTITIES[aID] = this; - } else { - throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); - } - this.mName = aBasicName.replaceAll(" ", "_").toLowerCase(); - this.setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity()); - this.getBaseMetaTileEntity().setMetaTileID((short) aID); - GT_LanguageManager.addStringLocalization("gt.blockmachines." + this.mName + ".name", aRegionalName); - this.mInventory = new ItemStack[aInvSlotCount]; - - if (GT.isClientSide()) { - final ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); - tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); - } - } - - /** - * This is the normal Constructor. - */ - public MetaTileEntityLossless(final String aName, final int aInvSlotCount) { - this.mInventory = new ItemStack[aInvSlotCount]; - this.mName = aName; - } - - @Override - public IGregTechTileEntity getBaseMetaTileEntity() { - return this.mBaseMetaTileEntity; - } - - @Override - public void setBaseMetaTileEntity(final IGregTechTileEntity aBaseMetaTileEntity) { - if ((this.mBaseMetaTileEntity != null) && (aBaseMetaTileEntity == null)) { - this.mBaseMetaTileEntity.getMetaTileEntity().inValidate(); - this.mBaseMetaTileEntity.setMetaTileEntity(null); - } - this.mBaseMetaTileEntity = aBaseMetaTileEntity; - if (this.mBaseMetaTileEntity != null) { - this.mBaseMetaTileEntity.setMetaTileEntity(this); - } - } - - @Override - public ItemStack getStackForm(final long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID()); - } - - public String getLocalName() { - return GT_LanguageManager.getTranslation("gt.blockmachines." + this.mName + ".name"); - } - - @Override - public void onServerStart() {/*Do nothing*/} - - @Override - public void onWorldSave(final File aSaveDirectory) {/*Do nothing*/} - - @Override - public void onWorldLoad(final File aSaveDirectory) {/*Do nothing*/} - - @Override - public void onConfigLoad(final GT_Config aConfig) {/*Do nothing*/} - - @Override - public void setItemNBT(final NBTTagCompound aNBT) {/*Do nothing*/} - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister aBlockIconRegister) {/*Do nothing*/} - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aStack) { - return true; - } - - @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) {/*Do nothing*/} - - @Override - public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - if (this.getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { - this.getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); - return true; - } - return false; - } - - @Override - public void onExplosion() {/*Do nothing*/} - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {/*Do nothing*/} - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {/*Do nothing*/} - - @Override - public void inValidate() {/*Do nothing*/} - - @Override - public void onRemoval() {/*Do nothing*/} - - @Override - public void initDefaultModes(final NBTTagCompound aNBT) {/*Do nothing*/} - - /** - * When a GUI is opened - */ - public void onOpenGUI() {/*Do nothing*/} - - /** - * When a GUI is closed - */ - public void onCloseGUI() {/*Do nothing*/} - - /** - * a Player rightclicks the Machine - * Sneaky rightclicks are not getting passed to this! - */ - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - return false; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, final byte aSide, final float aX, final float aY, final float aZ) { - return this.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {/*Do nothing*/} - - @Override - public void onValueUpdate(final byte aValue) {/*Do nothing*/} - - @Override - public byte getUpdateData() { - return 0; - } - - @Override - public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public void stopSoundLoop(final byte aValue, final double aX, final double aY, final double aZ) {/*Do nothing*/} - - @Override - public final void sendSound(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex); - } - } - - @Override - public final void sendLoopStart(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex); - } - } - - @Override - public final void sendLoopEnd(final byte aIndex) { - if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) { - this.getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex); - } - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isElectric() { - return true; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isPneumatic() { - return false; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isSteampowered() { - return false; - } - - /** - * @return true if this Device emits Energy at all - */ - public boolean isEnetOutput() { - return false; - } - - /** - * @return true if this Device consumes Energy at all - */ - public boolean isEnetInput() { - return false; - } - - /** - * @return the amount of EU, which can be stored in this Device. Default is 0 EU. - */ - public long maxEUStore() { - return 0; - } - - /** - * @return the amount of EU/t, which can be accepted by this Device before it explodes. - */ - public long maxEUInput() { - return 0; - } - - /** - * @return the amount of EU/t, which can be outputted by this Device. - */ - public long maxEUOutput() { - return 0; - } - - /** - * @return the amount of E-net Impulses of the maxEUOutput size, which can be outputted by this Device. - * Default is 1 Pulse, this shouldn't be set to smaller Values than 1, as it won't output anything in that Case! - */ - public long maxAmperesOut() { - return 1; - } - - /** - * How many Amperes this Block can suck at max. Surpassing this value won't blow it up. - */ - public long maxAmperesIn() { - return 1; - } - - /** - * @return true if that Side is an Output. - */ - public boolean isOutputFacing(final byte aSide) { - return false; - } - - /** - * @return true if that Side is an Input. - */ - public boolean isInputFacing(final byte aSide) { - return false; - } - - /** - * @return true if Transformer Upgrades increase Packet Amount. - */ - public boolean isTransformingLowEnergy() { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return false; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean setStackToZeroInsteadOfNull(final int aIndex) { - return false; - } - - /** - * This is used to get the internal Energy. I use this for the IDSU. - */ - public long getEUVar() { - return ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredEnergy; - } - - /** - * This is used to set the internal Energy to the given Parameter. I use this for the IDSU. - */ - public void setEUVar(final long aEnergy) { - ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredEnergy = aEnergy; - } - - /** - * This is used to get the internal Steam Energy. - */ - public long getSteamVar() { - return ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredSteam; - } - - /** - * This is used to set the internal Steam Energy to the given Parameter. - */ - public void setSteamVar(final long aSteam) { - ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredSteam = aSteam; - } - - /** - * @return the amount of Steam, which can be stored in this Device. Default is 0 EU. - */ - public long maxSteamStore() { - return 0; - } - - /** - * @return the amount of EU, which this Device stores before starting to emit Energy. - * useful if you don't want to emit stored Energy until a certain Level is reached. - */ - public long getMinimumStoredEU() { - return 512; - } - - /** - * Determines the Tier of the Machine, used for de-charging Tools. - */ - public long getInputTier() { - return GT_Utility.getTier(this.getBaseMetaTileEntity().getInputVoltage()); - } - - /** - * Determines the Tier of the Machine, used for charging Tools. - */ - public long getOutputTier() { - return GT_Utility.getTier(this.getBaseMetaTileEntity().getOutputVoltage()); - } - - /** - * gets the first RechargerSlot - */ - public int rechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of RechargerSlots - */ - public int rechargerSlotCount() { - return 0; - } - - /** - * gets the first DechargerSlot - */ - public int dechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of DechargerSlots - */ - public int dechargerSlotCount() { - return 0; - } - - /** - * gets if this is protected from other Players per default or not - */ - public boolean ownerControl() { - return false; - } - - @Override - public ArrayList<String> getSpecialDebugInfo(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, final int aLogLevel, final ArrayList<String> aList) { - return aList; - } - - @Override - public boolean isLiquidInput(final byte aSide) { - return true; - } - - @Override - public boolean isLiquidOutput(final byte aSide) { - return true; - } - - /** - * gets the contained Liquid - */ - @Override - public FluidStack getFluid() { - return null; - } - - /** - * tries to fill this Tank - */ - @Override - public int fill(final FluidStack resource, final boolean doFill) { - return 0; - } - - /** - * tries to empty this Tank - */ - @Override - public FluidStack drain(final int maxDrain, final boolean doDrain) { - return null; - } - - /** - * Tank pressure - */ - public int getTankPressure() { - return 0; - } - - /** - * Liquid Capacity - */ - @Override - public int getCapacity() { - return 0; - } - - @Override - public void onMachineBlockUpdate() {/*Do nothing*/} - - @Override - public void receiveClientEvent(final byte aEventID, final byte aValue) {/*Do nothing*/} - - @Override - public boolean isSimpleMachine() { - return false; - } - - /** - * If this accepts up to 4 Overclockers - */ - public boolean isOverclockerUpgradable() { - return false; - } - - /** - * If this accepts Transformer Upgrades - */ - public boolean isTransformerUpgradable() { - return false; - } - - /** - * Progress this machine has already made - */ - public int getProgresstime() { - return 0; - } - - /** - * Progress this Machine has to do to produce something - */ - public int maxProgresstime() { - return 0; - } - - /** - * Increases the Progress, returns the overflown Progress. - */ - public int increaseProgress(final int aProgress) { - return 0; - } - - /** - * If this TileEntity makes use of Sided Redstone behaviors. - * Determines only, if the Output Redstone Array is getting filled with 0 for true, or 15 for false. - */ - public boolean hasSidedRedstoneOutputBehavior() { - return false; - } - - /** - * When the Facing gets changed. - */ - public void onFacingChange() {/*Do nothing*/} - - /** - * if the IC2 Teleporter can drain from this. - */ - public boolean isTeleporterCompatible() { - return this.isEnetOutput() && (this.getBaseMetaTileEntity().getOutputVoltage() >= 128) && (this.getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000); - } - - /** - * Gets the Output for the comparator on the given Side - */ - @Override - public byte getComparatorValue(final byte aSide) { - return 0; - } - - @Override - public boolean acceptsRotationalEnergy(final byte aSide) { - return false; - } - - @Override - public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) { - return false; - } - - @Override - public String getSpecialVoltageToolTip() { - return null; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public String[] getInfoData() { - return new String[]{}; - } - - public boolean isDigitalChest() { - return false; - } - - public ItemStack[] getStoredItemData() { - return null; - } - - public void setItemCount(final int aCount) {/*Do nothing*/} - - public int getMaxItemCount() { - return 0; - } - - @Override - public int getSizeInventory() { - return this.mInventory.length; - } - - @Override - public ItemStack getStackInSlot(final int aIndex) { - if ((aIndex >= 0) && (aIndex < this.mInventory.length)) { - return this.mInventory[aIndex]; - } - return null; - } - - @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - if ((aIndex >= 0) && (aIndex < this.mInventory.length)) { - this.mInventory[aIndex] = aStack; - } - } - - @Override - public String getInventoryName() { - if (GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()] != null) { - return GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()].getMetaName(); - } - return ""; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - return this.getBaseMetaTileEntity().isValidSlot(aIndex); - } - - @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final ItemStack tStack = this.getStackInSlot(aIndex); - ItemStack rStack = GT_Utility.copy(tStack); - if (tStack != null) { - if (tStack.stackSize <= aAmount) { - if (this.setStackToZeroInsteadOfNull(aIndex)) { - tStack.stackSize = 0; - } else { - this.setInventorySlotContents(aIndex, null); - } - } else { - rStack = tStack.splitStack(aAmount); - if ((tStack.stackSize == 0) && !this.setStackToZeroInsteadOfNull(aIndex)) { - this.setInventorySlotContents(aIndex, null); - } - } - } - return rStack; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final ArrayList<Integer> tList = new ArrayList<>(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity(); - final boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity); - for (int i = 0; i < this.getSizeInventory(); i++) { - if (this.isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity))) { - tList.add(i); - } - } - final int[] rArray = new int[tList.size()]; - for (int i = 0; i < rArray.length; i++) { - rArray[i] = tList.get(i); - } - return rArray; - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.isValidSlot(aIndex) && (aStack != null) && (aIndex < this.mInventory.length) && ((this.mInventory[aIndex] == null) || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex])) && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - return this.isValidSlot(aIndex) && (aStack != null) && (aIndex < this.mInventory.length) && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); - } - - @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - return this.drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - if ((this.getCapacity() <= 0) && !this.getBaseMetaTileEntity().hasSteamEngineUpgrade()) { - return new FluidTankInfo[]{}; - } - return new FluidTankInfo[]{this.getInfo()}; - } - - public int fill_default(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { - return this.fill(aFluid, doFill); - } - - @Override - public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { - if (this.getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && (aFluid.amount > 1)) { - final int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2, this.getBaseMetaTileEntity().getSteamCapacity() - this.getBaseMetaTileEntity().getStoredSteam())); - if (tSteam > 0) { - if (doFill) { - this.getBaseMetaTileEntity().increaseStoredSteam(tSteam, true); - } - return tSteam * 2; - } - } else { - return this.fill_default(aSide, aFluid, doFill); - } - return 0; - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - if ((this.getFluid() != null) && (aFluid != null) && this.getFluid().isFluidEqual(aFluid)) { - return this.drain(aFluid.amount, doDrain); - } - return null; - } - - @Override - public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) { - return this.drain(maxDrain, doDrain); - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public FluidTankInfo getInfo() { - return new FluidTankInfo(this); - } - - @Override - public String getMetaName() { - return this.mName; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int i) { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean doTickProfilingMessageDuringThisTick() { - return this.doTickProfilingInThisTick; - } - - @Override - public void markDirty() { - // - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return false; - } - - @Override - public void openInventory() { - // - } - - @Override - public void closeInventory() { - // - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public boolean connectsToItemPipe(final byte aSide) { - return false; - } - - @Override - public float getExplosionResistance(final byte aSide) { - return 10.0F; - } - - @Override - public ItemStack[] getRealInventory() { - return this.mInventory; - } - - @Override - public void onColorChangeServer(final byte aColor) { - // - } - - @Override - public void onColorChangeClient(final byte aColor) { - // - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInInventory(final Block aBlock, final int aMeta, final RenderBlocks aRenderer) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInWorld(final IBlockAccess aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final RenderBlocks aRenderer) { - return false; - } - - @Override - public void doExplosion(final long aExplosionPower) { - final float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < (V[4] * 2) ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; - final int tX = this.getBaseMetaTileEntity().getXCoord(), tY = this.getBaseMetaTileEntity().getYCoord(), tZ = this.getBaseMetaTileEntity().getZCoord(); - final World tWorld = this.getBaseMetaTileEntity().getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) { - tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); - } - } - - @Override - public int getLightOpacity() { - return ((GregtechBaseMetaTileEntityLossless) this.getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255; - } - - @Override - public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ, final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) { - final AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if ((axisalignedbb1 != null) && inputAABB.intersectsWith(axisalignedbb1)) { - outputAABB.add(axisalignedbb1); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - } - - @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, final Entity collider) { - // - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - // - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java deleted file mode 100644 index 89ed69e247..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java +++ /dev/null @@ -1,104 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators; - -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_Recipe; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaSuperConductorNodeBase; - -public class GregtechMetaTileEntitySuperCondensor -extends GregtechMetaSuperConductorNodeBase { - - public int mEfficiency; - - public GregtechMetaTileEntitySuperCondensor(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Nitrogen/Helium", new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntitySuperCondensor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySuperCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } - - @Override - public int getCapacity() { - return 64000; - } - - public void onConfigLoad() { - this.mEfficiency = 100; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java index fa2d028276..1fea675c2e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java @@ -56,9 +56,9 @@ public class GregtechConduits { wireFactory("RedstoneAlloy", 32, 30645, 0, 2, 1); } - superConductorFactory(GT_Materials.Superconductor, 524288, 30660, 0, 0, 8); + //superConductorFactory(GT_Materials.Superconductor, 524288, 30660, 0, 0, 8); if (LoadedMods.Thaumcraft){ - superConductorFactory(GT_Materials.Void, 512, 30661, 0, 0, 8); + //superConductorFactory(GT_Materials.Void, 512, 30661, 0, 0, 8); } @@ -189,16 +189,16 @@ public class GregtechConduits { V = 0; } //makeWires(T, ID, 2L, 4L, 2L, GT_Values.V[V], true, false); - makeSuperConductors(T, ID, insulatedLoss, uninsulatedLoss, Amps, GT_Values.V[V], true, false); + //makeSuperConductors(T, ID, insulatedLoss, uninsulatedLoss, Amps, GT_Values.V[V], true, false); //makeWires(T, ID, bEC ? 2L : 2L, bEC ? 4L : 4L, 2L, gregtech.api.enums.GT_Values.V[V], true, false); } - private static void makeSuperConductors(final GT_Materials aMaterial, final int aStartID, final long aLossInsulated, final long aLoss, final long aAmperage, final long aVoltage, final boolean aInsulatable, final boolean aAutoInsulated) + /*private static void makeSuperConductors(final GT_Materials aMaterial, final int aStartID, final long aLossInsulated, final long aLoss, final long aAmperage, final long aVoltage, final boolean aInsulatable, final boolean aAutoInsulated) { Utils.LOG_WARNING("Gregtech5u Content | Registered "+aMaterial.name() +" as a new Super Conductor."); registerOre(GregtechOrePrefixes.type2, aMaterial, new GregtechMetaPipeEntity_SuperConductor(aStartID + 5, "wire." + aMaterial.name().toLowerCase() + ".16", "16x " + aMaterial.mDefaultLocalName + " Wire", 1.0F, aMaterial, aLoss, 16L * aAmperage, aVoltage, false, !aAutoInsulated).getStackForm(1L)); - } + }*/ private static boolean registerOre(final GregtechOrePrefixes aPrefix, final Object aMaterial, final ItemStack aStack) { return GT_OreDictUnificator.registerOre(aPrefix.get(aMaterial), aStack); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java index 35b7050300..913b13718f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java @@ -2,13 +2,12 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntitySuperCondensor; public class GregtechSuperConductionPoint { public static void run() { if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { - Utils.LOG_INFO("Gregtech5u Content | Registering Super Conductor Input Node."); + //Utils.LOG_INFO("Gregtech5u Content | Registering Super Conductor Input Node."); run1(); } @@ -16,8 +15,8 @@ public class GregtechSuperConductionPoint { private static void run1() { // Steam Condensors - GregtechItemList.SuperConductorInputNode.set(new GregtechMetaTileEntitySuperCondensor(811, - "superconductor.01.input.single", "Power Phase Shifting Station", 8).getStackForm(1L)); + //GregtechItemList.SuperConductorInputNode.set(new GregtechMetaTileEntitySuperCondensor(811, + // "superconductor.01.input.single", "Power Phase Shifting Station", 8).getStackForm(1L)); } } |