From cbe0e497be8e466c380a5b4fa781b314ede9ada3 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 6 Nov 2016 19:32:27 +1000 Subject: Revert "$ Cleaned up the entire project." This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966. --- .../base/GregtechMetaPipeEntityBase_Cable.java | 559 +-- .../base/GregtechMetaTileEntity.java | 85 +- .../base/GregtechMeta_MultiBlockBase.java | 1849 ++++----- .../GregtechDoubleFuelGeneratorBase.java | 601 ++- .../base/generators/GregtechMetaBoilerBase.java | 625 ++- .../generators/GregtechMetaSolarGenerator.java | 376 +- .../GregtechRocketFuelGeneratorBase.java | 558 ++- .../GregtechBaseMetaTileEntityLossless.java | 4189 +++++++++----------- .../GregtechMetaPipeEntity_BaseSuperConductor.java | 1312 +++--- .../lossless/GregtechMetaTileEntityLossless.java | 85 +- .../GregtechMetaTileEntityLosslessBasicTank.java | 494 ++- ...chMetaTileEntityLosslessTieredMachineBlock.java | 110 +- .../base/lossless/MetaTileEntityLossless.java | 1779 ++++----- .../base/machines/GregtechMetaSafeBlockBase.java | 483 +-- 14 files changed, 5881 insertions(+), 7224 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index 7bcd29dad0..e9947464be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -1,17 +1,17 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; - -import cofh.api.energy.IEnergyReceiver; +import static gregtech.api.enums.GT_Values.VN; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; 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.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; @@ -21,6 +21,11 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import ic2.api.energy.tile.IEnergySink; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -30,301 +35,269 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import cofh.api.energy.IEnergyReceiver; public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements IMetaTileEntityCable { - public final float mThickNess; - public final GT_Materials mMaterial; - public final long mCableLossPerMeter, mAmperage, mVoltage; - public final boolean mInsulated, mCanShock; - public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, - mTransferredVoltageLast20 = 0; - public long mRestRF; - public short mOverheat; - public final int mWireHeatingTicks; + public final float mThickNess; + public final GT_Materials mMaterial; + public final long mCableLossPerMeter, mAmperage, mVoltage; + public final boolean mInsulated, mCanShock; + public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; + public long mRestRF; + public short mOverheat; + public final int mWireHeatingTicks; - public GregtechMetaPipeEntityBase_Cable(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) { + public GregtechMetaPipeEntityBase_Cable(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = aCableLossPerMeter; - this.mWireHeatingTicks = this.getGT5Var(); + mThickNess = aThickNess; + mMaterial = aMaterial; + mAmperage = aAmperage; + mVoltage = aVoltage; + mInsulated = aInsulated; + mCanShock = aCanShock; + mCableLossPerMeter = aCableLossPerMeter; + mWireHeatingTicks = getGT5Var(); } - public GregtechMetaPipeEntityBase_Cable(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) { + public GregtechMetaPipeEntityBase_Cable(String aName, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aName, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = aCableLossPerMeter; - this.mWireHeatingTicks = this.getGT5Var(); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; + mThickNess = aThickNess; + mMaterial = aMaterial; + mAmperage = aAmperage; + mVoltage = aVoltage; + mInsulated = aInsulated; + mCanShock = aCanShock; + mCableLossPerMeter = aCableLossPerMeter; + mWireHeatingTicks = getGT5Var(); } - - @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 String[] getDescription() { - return new String[] { - "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " (" - + GT_Values.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" - }; - } - - private int getGT5Var() { - final Class clazz = GT_Mod.gregtechproxy.getClass(); - final String lookingForValue = "mWireHeatingTicks"; + + private int getGT5Var(){ + Class clazz = GT_Mod.gregtechproxy.getClass(); + String lookingForValue = "mWireHeatingTicks"; int temp = 4; Field field; - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - field = clazz.getClass().getField(lookingForValue); - final Class clazzType = field.getType(); - if (clazzType.toString().equals("int")) { - temp = field.getInt(clazz); - } - else { - temp = 4; - } + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + try { + field = clazz.getClass().getField(lookingForValue); + Class clazzType = field.getType(); + if (clazzType.toString().equals("int")){ + temp = (field.getInt(clazz)); } - catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - // - PLEASE REPORT THIS."); - Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); - Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + else { temp = 4; } + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; + } } return temp; } @Override - public int getProgresstime() { - return (int) this.mTransferredAmperage * 64; + public byte getTileEntityBaseType() { + return (byte) (mInsulated ? 9 : 8); } @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) - }; - } + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntityBase_Cable(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + if (!mInsulated) + return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], 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)) - }; + float tThickNess = getThickNess(); + if (tThickNess < 0.37F) + return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], 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(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], 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(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], 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(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], 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)) - }; + return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; } @Override - public float getThickNess() { - return this.mThickNess; + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { + if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) + GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20); } @Override - public byte getTileEntityBaseType() { - return (byte) (this.mInsulated ? 9 : 8); + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + if (!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 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()))); + public boolean isSimpleMachine() { + return true; } @Override - public boolean isFacingValid(final byte aFacing) { + public boolean isFacingValid(byte aFacing) { return false; } @Override - public boolean isSimpleMachine() { + public boolean isValidSlot(int aIndex) { return true; } @Override - public boolean isValidSlot(final int aIndex) { - return true; + public final boolean renderInside(byte aSide) { + return false; } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - // + public int getProgresstime() { + return (int) mTransferredAmperage * 64; } @Override public int maxProgresstime() { - return (int) this.mAmperage * 64; + return (int) mAmperage * 64; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial, - this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) + return 0; + return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList(Arrays.asList((TileEntity) getBaseMetaTileEntity()))); } @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); + public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList aAlreadyPassedTileEntityList) { + long rUsedAmperes = 0; + aVoltage -= mCableLossPerMeter; + if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) + if (i != aSide && (mConnections & (1 << i)) != 0 && getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, getBaseMetaTileEntity().getCoverIDAtSide(i), getBaseMetaTileEntity().getCoverDataAtSide(i), getBaseMetaTileEntity())) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(i); + if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { + aAlreadyPassedTileEntityList.add(tTileEntity); + if (tTileEntity instanceof IEnergyConnected) { + if (getBaseMetaTileEntity().getColorization() >= 0) { + byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + if (tColor >= 0 && tColor != 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) { + ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) getBaseMetaTileEntity(), tDirection)) { + if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) + rUsedAmperes++; + } + } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { + ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + 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 (mRestRF == 0) { + int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) rfOut, false); + rUsedAmperes++; + mRestRF = rfOut - RFtrans; + } else { + int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) mRestRF, false); + mRestRF = mRestRF - RFtrans; + } + } + if (GregTech_API.mRFExplosions && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) { + if (rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut); + } + } + } + } + + + mTransferredAmperage += rUsedAmperes; + mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage); + mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage); + + + if (aVoltage > mVoltage || mTransferredAmperage > mAmperage){ + //GT 5.09 + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if(mOverheat>mWireHeatingTicks * 100){ + getBaseMetaTileEntity().setToFire(); + } + else{ + mOverheat +=100; + } + return aAmperage; + } + //GT 5.08 + else { + getBaseMetaTileEntity().setToFire(); + return aAmperage; + } } + + return rUsedAmperes; } @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - this.mTransferredAmperage = 0; - if (this.mOverheat > 0) { - this.mOverheat--; - } + mTransferredAmperage = 0; + if(mOverheat>0)mOverheat--; if (aTick % 20 == 0) { - this.mTransferredVoltageLast20 = 0; - this.mTransferredAmperageLast20 = 0; - this.mConnections = 0; + mTransferredVoltageLast20 = 0; + mTransferredAmperageLast20 = 0; + 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 (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)) { + 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; - } + 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; + if (tTileEntity instanceof IEnergyConnected && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { + 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; + 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))) { + mConnections |= (1 << i); continue; } } - if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom( - (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - this.mConnections |= 1 << i; + if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { + mConnections |= (1 << i); continue; } - if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver - && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { - this.mConnections |= 1 << i; + if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { + mConnections |= (1 << i); continue; } /* - * if (tTileEntity instanceof IEnergyEmitter && - * ((IEnergyEmitter)tTileEntity).emitsEnergyTo(( - * TileEntity)aBaseMetaTileEntity, - * ForgeDirection.getOrientation(j))) { mConnections |= - * (1< 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); - } - } - } - } - } - } - } + public String[] getDescription() { + return new String[]{ + "Max Voltage: " + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: " + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: " + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt" + }; + } - this.mTransferredAmperage += rUsedAmperes; - this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); - this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); + @Override + public float getThickNess() { + return mThickNess; + } - if (aVoltage > this.mVoltage || this.mTransferredAmperage > this.mAmperage) { - // GT 5.09 - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (this.mOverheat > this.mWireHeatingTicks * 100) { - this.getBaseMetaTileEntity().setToFire(); - } - else { - this.mOverheat += 100; - } - return aAmperage; - } - // GT 5.08 - else { - this.getBaseMetaTileEntity().setToFire(); - return aAmperage; - } - } + @Override + public void saveNBTData(NBTTagCompound aNBT) { + // + } - return rUsedAmperes; + @Override + public void loadNBTData(NBTTagCompound aNBT) { + // } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java index 45c298d769..cd91d05970 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import gregtech.api.enums.GT_Values; +import static gregtech.api.enums.GT_Values.GT; import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.MetaTileEntity; import gtPlusPlus.core.lib.CORE; @@ -9,70 +9,59 @@ public abstract class GregtechMetaTileEntity extends MetaTileEntity { /** * Value between [0 - 9] to describe the Tier of this Machine. */ - public final byte mTier; - + public final byte mTier; + /** * A simple Description. */ - public final String mDescription; - + public final String mDescription; + /** * Contains all Textures used by this Block. */ - public final ITexture[][][] mTextures; - - public GregtechMetaTileEntity(final int aID, final String aName, final String aNameRegional, final int aTier, - final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { + public final ITexture[][][] mTextures; + + public GregtechMetaTileEntity(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); - this.mTier = (byte) Math.max(0, Math.min(aTier, 9)); - this.mDescription = aDescription; - + mTier = (byte)Math.max(0, Math.min(aTier, 9)); + mDescription = aDescription; + // must always be the last call! - if (GT_Values.GT.isClientSide()) { - this.mTextures = this.getTextureSet(aTextures); - } - else { - this.mTextures = null; - } + if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; } - - public GregtechMetaTileEntity(final String aName, final int aTier, final int aInvSlotCount, - final String aDescription, final ITexture[][][] aTextures) { + + public GregtechMetaTileEntity(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aInvSlotCount); - this.mTier = (byte) aTier; - this.mDescription = aDescription; - this.mTextures = aTextures; - + mTier = (byte)aTier; + mDescription = aDescription; + mTextures = aTextures; + } - + @Override - public String[] getDescription() { - return new String[] { - this.mDescription, CORE.GT_Tooltip - }; + public byte getTileEntityBaseType() { + return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4))); } - - @Override + + @Override public long getInputTier() { - return this.mTier; - } - - @Override + return mTier; + } + + @Override public long getOutputTier() { - return this.mTier; + return mTier; + } + + @Override + public String[] getDescription() { + return new String[] {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. + * 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); - - @Override - public byte getTileEntityBaseType() { - return (byte) Math.min(3, this.mTier <= 0 ? 0 : 1 + (this.mTier - 1) / 4); - } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 7a2397cf02..a6121f783d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1,22 +1,37 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import java.util.ArrayList; - +import static gregtech.api.enums.GT_Values.V; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -25,1022 +40,832 @@ import net.minecraftforge.fluids.FluidStack; public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity { - public static boolean disableMaintenance; - public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) { - return aMetaTileEntity.getBaseMetaTileEntity() != null - && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity - && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); - } - public boolean mMachine = false, mWrench = false, - mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = true, mCrowbar = false, - mRunningOnLoad = false; - public int mPollution = 0, mProgresstime = 0, - mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, - mEfficiency = 0; - public ItemStack[] mOutputItems = null; - public FluidStack[] mOutputFluids = null; - public ArrayList mInputHatches = new ArrayList(); - public ArrayList mOutputHatches = new ArrayList(); - public ArrayList mInputBusses = new ArrayList(); - public ArrayList mOutputBusses = new ArrayList(); - public ArrayList mDynamoHatches = new ArrayList(); - public ArrayList mMufflerHatches = new ArrayList(); - public ArrayList mEnergyHatches = new ArrayList(); - - public ArrayList mMaintenanceHatches = new ArrayList(); - - public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 2); - GregtechMeta_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "MultiBlockMachines.disableMaintenance", false); - } - - public GregtechMeta_MultiBlockBase(final String aName) { - super(aName, 2); - GregtechMeta_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "MultiBlockMachines.disableMaintenance", false); - } - - /** - * Called whenever the Machine aborted a Process, useful for Sound Effects - */ - public void abortProcess() { - // - } - - public boolean addDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - return false; - } - - public boolean addEnergyInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - return false; - } - - public boolean addEnergyOutput(final long aEU) { - if (aEU <= 0) { - return true; - } - for (final GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { - return true; - } - } - } - return false; - } - - private void addFluidOutputs(final FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - if (this.mOutputHatches.size() > i && this.mOutputHatches.get(i) != null && mOutputFluids2[i] != null - && GregtechMeta_MultiBlockBase.isValidMetaTileEntity(this.mOutputHatches.get(i))) { - this.mOutputHatches.get(i).fill(mOutputFluids2[i], true); - } - } - - } - - public boolean addInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - return false; - } - - public boolean addMaintenanceToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - return false; - } - - public boolean addMufflerToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - return false; - } - - public boolean addOutput(final FluidStack aLiquid) { - if (aLiquid == null) { - return false; - } - final FluidStack tLiquid = aLiquid.copy(); - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) - ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { - final int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) { - return tHatch.fill(tLiquid, true) >= tLiquid.amount; - } - else if (tAmount > 0) { - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - } - } - return false; - } - - public boolean addOutput(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - aStack = GT_Utility.copy(aStack); - // FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); - // if (aLiquid == null) { - for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) { - return true; - } - } - } - } - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) { - return true; - } - } - } - // }else { - // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - // if (isValidMetaTileEntity(tHatch) && - // GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) - // { - // int tAmount = tHatch.fill(aLiquid, false); - // if (tAmount >= aLiquid.amount) { - // return tHatch.fill(aLiquid, true) >= aLiquid.amount; - // } - // } - // } - // } - return false; - } - - public boolean addOutputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - return false; - } - - public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - return false; - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - /** - * Checks the Machine. You have to assign the MetaTileEntities for the - * Hatches here. - */ - public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); - - /** - * Checks the Recipe - */ - public abstract boolean checkRecipe(ItemStack aStack); - - public boolean depleteInput(final FluidStack aLiquid) { - if (aLiquid == null) { - return false; - } - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { - tLiquid = tHatch.drain(aLiquid.amount, false); - if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { - tLiquid = tHatch.drain(aLiquid.amount, true); - return tLiquid != null && tLiquid.amount >= aLiquid.amount; - } - } - } - } - return false; - } - - /** - * Checks if this is a Correct Machine Part for this kind of Machine - * (Turbine Rotor for example) - */ - // public abstract boolean isCorrectMachinePart(ItemStack aStack); - - public boolean depleteInput(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - final FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); - if (aLiquid != null) { - return this.depleteInput(aLiquid); - } - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - } - return false; - } - - public boolean doRandomMaintenanceDamage() { - if (this.getRepairStatus() == 0) { - this.stopMachine(); - return false; - } - if (this.mRuntime++ > 1000) { - this.mRuntime = 0; - if (this.getBaseMetaTileEntity().getRandomNumber(6000) == 0) { - switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { - case 0: - this.mWrench = false; - break; - case 1: - this.mScrewdriver = false; - break; - case 2: - this.mSoftHammer = false; - break; - case 3: - this.mHardHammer = false; - break; - case 4: - this.mSolderingTool = true; - break; - case 5: - this.mCrowbar = false; - break; - } - } - if (this.mInventory[1] != null && this.getBaseMetaTileEntity().getRandomNumber(2) == 0 - && !this.mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { - if (this.mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { - final NBTTagCompound tNBT = this.mInventory[1].getTagCompound(); - if (tNBT != null) { - NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); - if (!tNBT.getBoolean("mDis")) { - tNBT2 = new NBTTagCompound(); - final Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[1]); - final ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); - final int i = this.mInventory[1].getItemDamage(); - if (i == 170) { - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - else if (i == 172) { - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - else if (i == 174) { - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - else if (i == 176) { - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - tNBT.setTag("GT.CraftingComponents", tNBT2); - tNBT.setBoolean("mDis", true); - this.mInventory[1].setTagCompound(tNBT); - - } - } - - ((GT_MetaGenerated_Tool) this.mInventory[1].getItem()).doDamage(this.mInventory[1], - (long) Math.min(this.mEUt / 5, Math.pow(this.mEUt, 0.7))); - if (this.mInventory[1].stackSize == 0) { - this.mInventory[1] = null; - } - } - } - } - return true; - } - - public boolean drainEnergyInput(final long aEU) { - if (aEU <= 0) { - return true; - } - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) { - return true; - } - } - } - return false; - } - - /** - * Called whenever the Machine successfully finished a Process, useful for - * Sound Effects - */ - public void endProcess() { - // - } - - /** - * Gets the damage to the ItemStack, usually 0 or 1. - */ - // public abstract int getDamageToComponent(ItemStack aStack); - - public void explodeMultiblock() { - this.mInventory[1] = null; - for (final MetaTileEntity tTileEntity : this.mInputBusses) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mOutputBusses) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mInputHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mOutputHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - this.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]); - } - - /** - * If it explodes when the Component has to be replaced. - */ - public abstract boolean explodesOnComponentBreak(ItemStack aStack); - - /** - * Gets the Amount of possibly outputted Items for loading the Output Stack - * Array from NBT. This should be the largest Amount that can ever happen - * legitimately. - */ - public abstract int getAmountOfOutputs(); - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "MultiblockDisplay.png"); - } - - public int getIdealStatus() { - return 6; - } - - @Override - public String[] getInfoData() { - return new String[] { - "Progress:", this.mProgresstime / 20 + "secs", this.mMaxProgresstime / 20 + "secs", "Efficiency:", - this.mEfficiency / 100.0F + "%", "Problems:", "" + (this.getIdealStatus() - this.getRepairStatus()) - }; - } - - /** - * Gets the maximum Efficiency that spare Part can get (0 - 10000) - */ - public abstract int getMaxEfficiency(ItemStack aStack); - - public long getMaxInputVoltage() { - long rVoltage = 0; - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); - } - } - return rVoltage; - } - - /** - * Gets the pollution this Device outputs to a Muffler per tick (10000 = one - * Pullution Block) - */ - public abstract int getPollutionPerTick(ItemStack aStack); - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - public GT_Recipe_Map getRecipeMap() { - return null; - } - - public int getRepairStatus() { - return (this.mWrench ? 1 : 0) + (this.mScrewdriver ? 1 : 0) + (this.mSoftHammer ? 1 : 0) - + (this.mHardHammer ? 1 : 0) + (this.mSolderingTool ? 1 : 0) + (this.mCrowbar ? 1 : 0); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - public ArrayList get