aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authorKiwi <42833050+Kiwi233@users.noreply.github.com>2020-05-24 08:28:19 +0800
committerGitHub <noreply@github.com>2020-05-24 08:28:19 +0800
commitf0bce85d3faf040d87a22d83250ae2d9767c3642 (patch)
treeed60c1d975c8b06a27cae03d148714f7bb9e9805 /src/main/java/gregtech/api/metatileentity/implementations
parentac7282a30ef161101cabc921e52db5c5d7e0096c (diff)
parentd6c19a9b6434c8a4c59ea8452603f85cfd2ad208 (diff)
downloadGT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.gz
GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.bz2
GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.zip
Merge pull request #1 from GTNewHorizons/experimental
5/24
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java1221
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java1315
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java7
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java62
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java322
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java71
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java53
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java44
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java84
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java23
12 files changed, 1725 insertions, 1493 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
index 5d672547d8..3373b142c4 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
@@ -1,625 +1,596 @@
-package gregtech.api.metatileentity.implementations;
-
-import cofh.api.energy.IEnergyReceiver;
-import com.google.common.collect.Sets;
-import gregtech.GT_Mod;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.Dyes;
-import gregtech.api.enums.Materials;
-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.ICoverable;
-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;
-import gregtech.api.util.GT_CoverBehavior;
-import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_Utility;
-import gregtech.common.GT_Client;
-import gregtech.common.covers.GT_Cover_SolarPanel;
-import gregtech.loaders.postload.PartP2PGTPower;
-import ic2.api.energy.EnergyNet;
-import ic2.api.energy.tile.IEnergyEmitter;
-import ic2.api.energy.tile.IEnergySink;
-import ic2.api.energy.tile.IEnergySource;
-import ic2.api.energy.tile.IEnergyTile;
-import ic2.api.reactor.IReactorChamber;
-import micdoodle8.mods.galacticraft.api.power.EnergySource;
-import micdoodle8.mods.galacticraft.api.power.EnergySource.EnergySourceAdjacent;
-import micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC;
-import micdoodle8.mods.galacticraft.api.transmission.NetworkType;
-import micdoodle8.mods.galacticraft.api.transmission.tile.IConnector;
-import micdoodle8.mods.galacticraft.core.energy.EnergyConfigHandler;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-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;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import appeng.api.parts.IPartHost;
-
-import static gregtech.api.enums.GT_Values.VN;
-
-public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable {
- public final float mThickNess;
- public final Materials mMaterial;
- public final long mCableLossPerMeter, mAmperage, mVoltage;
- public final boolean mInsulated, mCanShock;
- public int mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,mTransferredAmperageLast20OK=0,mTransferredAmperageOK=0;
- public long mTransferredVoltageLast20 = 0, mTransferredVoltage = 0,mTransferredVoltageLast20OK=0,mTransferredVoltageOK=0;
- public long mRestRF;
- public int mOverheat;
- public static short mMaxOverheat=(short) (GT_Mod.gregtechproxy.mWireHeatingTicks * 100);
-
- private int[] lastAmperage;
- private long lastWorldTick;
-
- public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
- super(aID, aName, aNameRegional, 0);
- mThickNess = aThickNess;
- mMaterial = aMaterial;
- mAmperage = aAmperage;
- mVoltage = aVoltage;
- mInsulated = aInsulated;
- mCanShock = aCanShock;
- mCableLossPerMeter = aCableLossPerMeter;
- }
-
- public GT_MetaPipeEntity_Cable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
- super(aName, 0);
- mThickNess = aThickNess;
- mMaterial = aMaterial;
- mAmperage = aAmperage;
- mVoltage = aVoltage;
- mInsulated = aInsulated;
- mCanShock = aCanShock;
- mCableLossPerMeter = aCableLossPerMeter;
- }
-
- @Override
- public byte getTileEntityBaseType() {
- return (byte) (mInsulated ? 9 : 8);
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaPipeEntity_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], Dyes.getModulation(aColorIndex, mMaterial.mRGBa) )};
- if (aConnected) {
- float tThickNess = getThickNess();
- if (tThickNess < 0.124F)
- return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
- if (tThickNess < 0.374F)//0.375 x1
- 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.499F)//0.500 x2
- 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.624F)//0.625 x4
- 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.749F)//0.750 x8
- return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
- if (tThickNess < 0.874F)//0.825 x12
- 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))};
- }
-
- @Override
- public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
- if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity))
- GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
- }
-
- @Override
- public boolean isSimpleMachine() {
- return true;
- }
-
- @Override
- public boolean isFacingValid(byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isValidSlot(int aIndex) {
- return true;
- }
-
- @Override
- public final boolean renderInside(byte aSide) {
- return false;
- }
-
- @Override
- public int getProgresstime() {
- return (int) mTransferredAmperage * 64;
- }
-
- @Override
- public int maxProgresstime() {
- return (int) mAmperage * 64;
- }
-
- private void pullFromIc2EnergySources(IGregTechTileEntity aBaseMetaTileEntity) {
- if(!GT_Mod.gregtechproxy.ic2EnergySourceCompat) return;
-
- for( byte aSide = 0 ; aSide < 6 ; aSide++) if(isConnectedAtSide(aSide)) {
- final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(aSide);
- final TileEntity tEmitter;
- if (tTileEntity instanceof IReactorChamber)
- tEmitter = (TileEntity) ((IReactorChamber) tTileEntity).getReactor();
- else tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
- EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
-
- if (tEmitter instanceof IEnergySource) {
- final GT_CoverBehavior coverBehavior = aBaseMetaTileEntity.getCoverBehaviorAtSide(aSide);
- final int coverId = aBaseMetaTileEntity.getCoverIDAtSide(aSide),
- coverData = aBaseMetaTileEntity.getCoverDataAtSide(aSide);
- final ForgeDirection tDirection = ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide));
-
- if (((IEnergySource) tEmitter).emitsEnergyTo((TileEntity) aBaseMetaTileEntity, tDirection) &&
- coverBehavior.letsEnergyIn(aSide, coverId, coverData, aBaseMetaTileEntity)) {
- final long tEU = (long) ((IEnergySource) tEmitter).getOfferedEnergy();
-
- if (transferElectricity(aSide, tEU, 1, Sets.newHashSet((TileEntity) aBaseMetaTileEntity)) > 0)
- ((IEnergySource) tEmitter).drawEnergy(tEU);
- }
- }
- }
- }
-
- @Override
- public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
- if (!isConnectedAtSide(aSide) && aSide != 6)
- return 0;
- if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
- return 0;
- return transferElectricity(aSide, aVoltage, aAmperage, Sets.newHashSet((TileEntity) getBaseMetaTileEntity()));
- }
-
- @Override
- @Deprecated
- public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
- return transferElectricity(aSide, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList));
- }
-
- @Override
- public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) {
- if (!isConnectedAtSide(aSide) && aSide != 6) return 0;
-
- long rUsedAmperes = 0;
- final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
-
- aVoltage -= mCableLossPerMeter;
- if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++)
- if (i != aSide && isConnectedAtSide(i) && baseMetaTile.getCoverBehaviorAtSide(i).letsEnergyOut(i, baseMetaTile.getCoverIDAtSide(i), baseMetaTile.getCoverDataAtSide(i), baseMetaTile)) {
- final TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(i);
-
- if (tTileEntity != null && aAlreadyPassedSet.add(tTileEntity)) {
- final byte tSide = GT_Utility.getOppositeSide(i);
- final IGregTechTileEntity tBaseMetaTile = tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity) : null;
- final IMetaTileEntity tMeta = tBaseMetaTile != null ? tBaseMetaTile.getMetaTileEntity() : null;
-
- if (tMeta instanceof IMetaTileEntityCable) {
- if (tBaseMetaTile.getCoverBehaviorAtSide(tSide).letsEnergyIn(tSide, tBaseMetaTile.getCoverIDAtSide(tSide), tBaseMetaTile.getCoverDataAtSide(tSide), tBaseMetaTile) && ((IGregTechTileEntity) tTileEntity).getTimer() > 50) {
- rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).transferElectricity(tSide, aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedSet);
- }
- } else {
- rUsedAmperes += insertEnergyInto(tTileEntity, tSide, aVoltage, aAmperage - rUsedAmperes);
- }
-
- }
- }
- mTransferredVoltage = Math.max(mTransferredVoltage, aVoltage);
- mTransferredAmperage += rUsedAmperes;
- mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage);
- mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage);
- if (aVoltage > mVoltage) {
- mOverheat += Math.max(100, 100 * GT_Utility.getTier(aVoltage) - GT_Utility.getTier(mVoltage));
- }
- if (mTransferredAmperage > mAmperage) return aAmperage;
-
- // Always return amount of used amperes, used on overheat
- return rUsedAmperes;
- }
-
- private long insertEnergyInto(TileEntity tTileEntity, byte tSide, long aVoltage, long aAmperage) {
- if (aAmperage == 0 || tTileEntity == null) return 0;
-
- final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
- final ForgeDirection tDirection = ForgeDirection.getOrientation(tSide);
-
- if (tTileEntity instanceof IEnergyConnected) {
- return ((IEnergyConnected) tTileEntity).injectEnergyUnits(tSide, aVoltage, aAmperage);
- }
-
- // AE2 Compat
- if (GT_Mod.gregtechproxy.mAE2Integration && tTileEntity instanceof appeng.tile.powersink.IC2) {
- if (((appeng.tile.powersink.IC2) tTileEntity).acceptsEnergyFrom((TileEntity) baseMetaTile, tDirection)) {
- long rUsedAmperes = 0;
- while (aAmperage > rUsedAmperes && ((appeng.tile.powersink.IC2)tTileEntity).getDemandedEnergy() > 0 && ((appeng.tile.powersink.IC2)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) <= aVoltage)
- rUsedAmperes++;
-
- return rUsedAmperes;
- }
- return 0;
- }
-
- // GC Compat
- if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC) {
- if (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER)) {
- EnergySource eSource = new EnergySourceAdjacent(tDirection);
-
- float tSizeToReceive = aVoltage * EnergyConfigHandler.IC2_RATIO, tStored = ((IEnergyHandlerGC)tTileEntity).getEnergyStoredGC(eSource);
- if (tSizeToReceive >= tStored || tSizeToReceive <= ((IEnergyHandlerGC)tTileEntity).getMaxEnergyStoredGC(eSource) - tStored) {
- float tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false);
- if (tReceived > 0) {
- tSizeToReceive -= tReceived;
- while (tSizeToReceive > 0) {
- tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false);
- if (tReceived < 1) break;
- tSizeToReceive -= tReceived;
- }
- return 1;
- }
- }
- }
- return 0;
- }
-
- // IC2 Compat
- {
- final TileEntity tIc2Acceptor = (tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
- EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
-
- if (tIc2Acceptor instanceof IEnergySink && ((IEnergySink) tIc2Acceptor).acceptsEnergyFrom((TileEntity) baseMetaTile, tDirection)) {
- long rUsedAmperes = 0;
- while (aAmperage > rUsedAmperes && ((IEnergySink) tIc2Acceptor).getDemandedEnergy() > 0 && ((IEnergySink) tIc2Acceptor).injectEnergy(tDirection, aVoltage, aVoltage) <= aVoltage)
- rUsedAmperes++;
- return rUsedAmperes;
- }
- }
-
- // RF Compat
- if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
- final IEnergyReceiver rfReceiver = (IEnergyReceiver) tTileEntity;
- long rfOUT = aVoltage * GregTech_API.mEUtoRF / 100, rUsedAmperes = 0;
- int rfOut = rfOUT > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) rfOUT;
-
- if (rfReceiver.receiveEnergy(tDirection, rfOut, true) == rfOut) {
- rfReceiver.receiveEnergy(tDirection, rfOut, false);
- rUsedAmperes++;
- }
- else if (rfReceiver.receiveEnergy(tDirection, rfOut, true) > 0) {
- if (mRestRF == 0) {
- int RFtrans = rfReceiver.receiveEnergy(tDirection, (int) rfOut, false);
- rUsedAmperes++;
- mRestRF = rfOut - RFtrans;
- } else {
- int RFtrans = rfReceiver.receiveEnergy(tDirection, (int) mRestRF, false);
- mRestRF = mRestRF - RFtrans;
- }
- }
- if (GregTech_API.mRFExplosions && rfReceiver.getMaxEnergyStored(tDirection) < rfOut * 600) {
- if (rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
- }
- return rUsedAmperes;
- }
-
- return 0;
- }
-
-
- @Override
- public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
- if(aBaseMetaTileEntity.isServerSide()) {
- lastAmperage = new int[16];
- lastWorldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime() - 1;//sets initial value -1 since it is in the same tick as first on post tick
- }
- }
-
- @Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- if (aBaseMetaTileEntity.isServerSide()) {
- if (GT_Mod.gregtechproxy.ic2EnergySourceCompat) pullFromIc2EnergySources(aBaseMetaTileEntity);
-
-
- { //amp handler
- long worldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime();
- int tickDiff = (int) (worldTick - lastWorldTick);
- lastWorldTick = worldTick;
-
- if (tickDiff >= 16) for (int i = 0; i <= 14; i++) lastAmperage[i] = 0;
- else {
- System.arraycopy(lastAmperage, tickDiff, lastAmperage, 0, 16 - tickDiff);
- for (int i = 14; i >= 0; i--) {
- if (--tickDiff > 0) lastAmperage[i] = 0;
- else break;
- }
- }
-
- lastAmperage[15] = mTransferredAmperage;
-
- if (lastAmperage[15] > mAmperage) {
- int i = 0;
- for (; i <= 14; i++) {
- if (lastAmperage[i] < mAmperage) {
- lastAmperage[15] -= (int) mAmperage - lastAmperage[i];
- lastAmperage[i] = (int)mAmperage;
- if (lastAmperage[15] <= mAmperage) break;
- }
- }
- if (lastAmperage[15] > mAmperage) {
- mOverheat += 100 * (lastAmperage[15] - mAmperage);
- lastAmperage[15] = (int) mAmperage;
- } else if (lastAmperage[15] < mAmperage) {
- lastAmperage[i] = lastAmperage[15];
- lastAmperage[15] = (int) mAmperage;
- }
- }
- }
-
- if(mOverheat>=mMaxOverheat) {
- //TODO someday
- //int newMeta=aBaseMetaTileEntity.getMetaTileID()-6;
- //if(mInsulated &&
- // GregTech_API.METATILEENTITIES[newMeta] instanceof GT_MetaPipeEntity_Cable &&
- // ((GT_MetaPipeEntity_Cable)GregTech_API.METATILEENTITIES[newMeta]).mMaterial==mMaterial &&
- // ((GT_MetaPipeEntity_Cable)GregTech_API.METATILEENTITIES[newMeta]).mAmperage<=mAmperage){
- // aBaseMetaTileEntity.setOnFire();
- // aBaseMetaTileEntity.setMetaTileEntity(GregTech_API.METATILEENTITIES[newMeta]);
- // return;
- //}else{
- aBaseMetaTileEntity.setToFire();
- //}
- }else if (mOverheat>0) mOverheat--;
-
- mTransferredVoltageOK=mTransferredVoltage;
- mTransferredVoltage=0;
- mTransferredAmperageOK=mTransferredAmperage;
- mTransferredAmperage = 0;
-
- if (aTick % 20 == 0) {
- mTransferredVoltageLast20OK=mTransferredVoltageLast20;
- mTransferredVoltageLast20 = 0;
- mTransferredAmperageLast20OK=mTransferredAmperageLast20;
- mTransferredAmperageLast20 = 0;
- if (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections) checkConnections();
- }
- } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
- }
-
- @Override
- public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) {
- if(isConnectedAtSide(aWrenchingSide)) {
- disconnect(aWrenchingSide);
- GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
- }else if(!GT_Mod.gregtechproxy.costlyCableConnection){
- if (connect(aWrenchingSide) > 0)
- GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
- }
- return true;
- }
- return false;
- }
-
- public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) {
- if (isConnectedAtSide(aWrenchingSide)) {
- disconnect(aWrenchingSide);
- GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
- } else if (!GT_Mod.gregtechproxy.costlyCableConnection || GT_ModHandler.consumeSolderingMaterial(aPlayer)) {
- if (connect(aWrenchingSide) > 0)
- GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity);
- }
-
- @Override
- public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity);
- }
-
-
- @Override
- public boolean canConnect(byte aSide, TileEntity tTileEntity) {
- final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
- final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
- final byte tSide = GT_Utility.getOppositeSide(aSide);
- final ForgeDirection tDir = ForgeDirection.getOrientation(tSide);
-
- // GT Machine handling
- if ((tTileEntity instanceof IEnergyConnected) &&
- (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false)))
- return true;
-
- // Solar Panel Compat
- if (coverBehavior instanceof GT_Cover_SolarPanel) return true;
-
- // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) --> Not needed
-
- // GC Compat
- if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC && (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDir, NetworkType.POWER)))
- return true;
-
- // AE2-p2p Compat
- if (GT_Mod.gregtechproxy.mAE2Integration) {
- if (tTileEntity instanceof IEnergySource && tTileEntity instanceof IPartHost && ((IPartHost)tTileEntity).getPart(tDir) instanceof PartP2PGTPower && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir))
- return true;
- if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir))
- return true;
- }
-
- // IC2 Compat
- {
- final TileEntity ic2Energy;
-
- if (tTileEntity instanceof IReactorChamber)
- ic2Energy = (TileEntity) ((IReactorChamber) tTileEntity).getReactor();
- else
- ic2Energy = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
- EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
-
- // IC2 Sink Compat
- if ((ic2Energy instanceof IEnergySink) && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir))
- return true;
-
- // IC2 Source Compat
- if (GT_Mod.gregtechproxy.ic2EnergySourceCompat && (ic2Energy instanceof IEnergySource)) {
- if (((IEnergySource) ic2Energy).emitsEnergyTo((TileEntity) baseMetaTile, tDir)) {
- return true;
- }
- }
- }
- // RF Output Compat
- if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(tDir))
- return true;
-
- // RF Input Compat
- if (GregTech_API.mInputRF && (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter) tTileEntity).emitsEnergyTo((TileEntity)baseMetaTile, tDir)))
- return true;
-
-
- return false;
- }
-
- @Override
- public boolean getGT6StyleConnection() {
- // Yes if GT6 Cables are enabled
- return GT_Mod.gregtechproxy.gt6Cable;
- }
-
-
- @Override
- public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return false;
- }
-
- @Override
- public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return false;
- }
-
- @Override
- public String[] getDescription() {
- return new String[]{
- "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"
- };
- }
-
- @Override
- public float getThickNess() {
- if(GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F;
- return mThickNess;
- }
-
- @Override
- public void saveNBTData(NBTTagCompound aNBT) {
- if (GT_Mod.gregtechproxy.gt6Cable)
- aNBT.setByte("mConnections", mConnections);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound aNBT) {
- if (GT_Mod.gregtechproxy.gt6Cable) {
- mConnections = aNBT.getByte("mConnections");
- }
- }
-
- @Override
- public boolean isGivingInformation() {
- return true;
- }
-
- @Override
- public String[] getInfoData() {
- return new String[]{
- //EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET,
- "Heat: "+
- EnumChatFormatting.RED+ mOverheat +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW+ mMaxOverheat + EnumChatFormatting.RESET,
- "Max Load (1t):",
- EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageOK) + EnumChatFormatting.RESET +" A / "+
- EnumChatFormatting.YELLOW + Long.toString(mAmperage) + EnumChatFormatting.RESET +" A",
- "Max EU/p (1t):",
- EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageOK) + EnumChatFormatting.RESET +" EU / "+
- EnumChatFormatting.YELLOW + Long.toString(mVoltage) + EnumChatFormatting.RESET +" EU",
- "Max Load (20t): "+
- EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageLast20OK) + EnumChatFormatting.RESET +" A",
- "Max EU/p (20t): "+
- EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageLast20OK) + EnumChatFormatting.RESET +" EU"
- };
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
- if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0)
- return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
- else
- return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
-
- private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
- float tSpace = (1f - mThickNess)/2;
- float tSide0 = tSpace;
- float tSide1 = 1f - tSpace;
- float tSide2 = tSpace;
- float tSide3 = 1f - tSpace;
- float tSide4 = tSpace;
- float tSide5 = 1f - tSpace;
-
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
-
- byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
- if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
- if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
- if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
- if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
- if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
- if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
-
- return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
- }
-
- @Override
- public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
- super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
- if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
- AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
- }
- }
-}
+package gregtech.api.metatileentity.implementations;
+
+import cofh.api.energy.IEnergyReceiver;
+import com.google.common.collect.Sets;
+import cpw.mods.fml.common.Loader;
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.Materials;
+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.ICoverable;
+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;
+import gregtech.api.util.GT_GC_Compat;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Client;
+import gregtech.common.covers.GT_Cover_SolarPanel;
+import gregtech.loaders.postload.PartP2PGTPower;
+import ic2.api.energy.EnergyNet;
+import ic2.api.energy.tile.IEnergyEmitter;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.energy.tile.IEnergySource;
+import ic2.api.energy.tile.IEnergyTile;
+import ic2.api.reactor.IReactorChamber;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import appeng.api.parts.IPartHost;
+
+import static gregtech.api.enums.GT_Values.VN;
+
+public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable {
+ public final float mThickNess;
+ public final Materials mMaterial;
+ public final long mCableLossPerMeter, mAmperage, mVoltage;
+ public final boolean mInsulated, mCanShock;
+ public int mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,mTransferredAmperageLast20OK=0,mTransferredAmperageOK=0;
+ public long mTransferredVoltageLast20 = 0, mTransferredVoltage = 0,mTransferredVoltageLast20OK=0,mTransferredVoltageOK=0;
+ public long mRestRF;
+ public int mOverheat;
+ public static short mMaxOverheat=(short) (GT_Mod.gregtechproxy.mWireHeatingTicks * 100);
+
+ private int[] lastAmperage;
+ private long lastWorldTick;
+
+ public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
+ super(aID, aName, aNameRegional, 0);
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
+ }
+
+ public GT_MetaPipeEntity_Cable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
+ super(aName, 0);
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
+ }
+
+ @Override
+ public byte getTileEntityBaseType() {
+ return (byte) (mInsulated ? 9 : 8);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaPipeEntity_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], Dyes.getModulation(aColorIndex, mMaterial.mRGBa) )};
+ if (aConnected) {
+ float tThickNess = getThickNess();
+ if (tThickNess < 0.124F)
+ return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.374F)//0.375 x1
+ 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.499F)//0.500 x2
+ 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.624F)//0.625 x4
+ 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.749F)//0.750 x8
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.874F)//0.825 x12
+ 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))};
+ }
+
+ @Override
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity))
+ GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ @Override
+ public final boolean renderInside(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public int getProgresstime() {
+ return (int) mTransferredAmperage * 64;
+ }
+
+ @Override
+ public int maxProgresstime() {
+ return (int) mAmperage * 64;
+ }
+
+ @Override
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!isConnectedAtSide(aSide) && aSide != 6)
+ return 0;
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ return 0;
+ return transferElectricity(aSide, aVoltage, aAmperage, Sets.newHashSet((TileEntity) getBaseMetaTileEntity()));
+ }
+
+ @Override
+ @Deprecated
+ public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
+ return transferElectricity(aSide, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList));
+ }
+
+ @Override
+ public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) {
+ if (!isConnectedAtSide(aSide) && aSide != 6) return 0;
+
+ long rUsedAmperes = 0;
+ final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
+ byte i = (byte)((((aSide/2)*2)+2)%6); //this bit of trickery makes sure a direction goes to the next cardinal pair. IE, NS goes to E, EW goes to U, UD goes to N. It's a lame way to make sure locally connected machines on a wire get EU first.
+ aVoltage -= mCableLossPerMeter;
+
+ if (aVoltage > 0) for (byte j = 0; j < 6 && aAmperage > rUsedAmperes; j++, i=(byte)((i+1)%6) )
+ if (i != aSide && isConnectedAtSide(i) && baseMetaTile.getCoverBehaviorAtSide(i).letsEnergyOut(i, baseMetaTile.getCoverIDAtSide(i), baseMetaTile.getCoverDataAtSide(i), baseMetaTile)) {
+ final TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(i);
+
+ if (tTileEntity != null && aAlreadyPassedSet.add(tTileEntity)) {
+ final byte tSide = GT_Utility.getOppositeSide(i);
+ final IGregTechTileEntity tBaseMetaTile = tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity) : null;
+ final IMetaTileEntity tMeta = tBaseMetaTile != null ? tBaseMetaTile.getMetaTileEntity() : null;
+
+ if (tMeta instanceof IMetaTileEntityCable) {
+ if (tBaseMetaTile.getCoverBehaviorAtSide(tSide).letsEnergyIn(tSide, tBaseMetaTile.getCoverIDAtSide(tSide), tBaseMetaTile.getCoverDataAtSide(tSide), tBaseMetaTile) && ((IGregTechTileEntity) tTileEntity).getTimer() > 50) {
+ rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).transferElectricity(tSide, aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedSet);
+ }
+ } else {
+ rUsedAmperes += insertEnergyInto(tTileEntity, tSide, aVoltage, aAmperage - rUsedAmperes);
+ }
+
+ }
+ }
+ mTransferredVoltage = Math.max(mTransferredVoltage, aVoltage);
+ mTransferredAmperage += rUsedAmperes;
+ mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage);
+ mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage);
+ if (aVoltage > mVoltage) {
+ mOverheat += Math.max(100, 100 * GT_Utility.getTier(aVoltage) - GT_Utility.getTier(mVoltage));
+ }
+ if (mTransferredAmperage > mAmperage) return aAmperage;
+
+ // Always return amount of used amperes, used on overheat
+ return rUsedAmperes;
+ }
+
+
+
+ private long insertEnergyInto(TileEntity tTileEntity, byte tSide, long aVoltage, long aAmperage) {
+ if (aAmperage == 0 || tTileEntity == null) return 0;
+
+ final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
+ final ForgeDirection tDirection = ForgeDirection.getOrientation(tSide);
+
+ if (tTileEntity instanceof IEnergyConnected) {
+ return ((IEnergyConnected) tTileEntity).injectEnergyUnits(tSide, aVoltage, aAmperage);
+ }
+
+ // AE2 Compat
+ if (GT_Mod.gregtechproxy.mAE2Integration && tTileEntity instanceof appeng.tile.powersink.IC2) {
+ if (((appeng.tile.powersink.IC2) tTileEntity).acceptsEnergyFrom((TileEntity) baseMetaTile, tDirection)) {
+ long rUsedAmperes = 0;
+ while (aAmperage > rUsedAmperes && ((appeng.tile.powersink.IC2)tTileEntity).getDemandedEnergy() > 0 && ((appeng.tile.powersink.IC2)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) <= aVoltage)
+ rUsedAmperes++;
+
+ return rUsedAmperes;
+ }
+ return 0;
+ }
+
+ if (Loader.isModLoaded("GalacticraftCore")) {
+ long gc = GT_GC_Compat.insertEnergyInto(tTileEntity, aVoltage, tDirection);
+ if (gc != 2)
+ return gc;
+ }
+
+ // IC2 Compat
+ {
+ final TileEntity tIc2Acceptor = (tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
+ EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
+
+ if (tIc2Acceptor instanceof IEnergySink && ((IEnergySink) tIc2Acceptor).acceptsEnergyFrom((TileEntity) baseMetaTile, tDirection)) {
+ long rUsedAmperes = 0;
+ while (aAmperage > rUsedAmperes && ((IEnergySink) tIc2Acceptor).getDemandedEnergy() > 0 && ((IEnergySink) tIc2Acceptor).injectEnergy(tDirection, aVoltage, aVoltage) <= aVoltage)
+ rUsedAmperes++;
+ return rUsedAmperes;
+ }
+ }
+
+ // RF Compat
+ if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
+ final IEnergyReceiver rfReceiver = (IEnergyReceiver) tTileEntity;
+ long rfOUT = aVoltage * GregTech_API.mEUtoRF / 100, rUsedAmperes = 0;
+ int rfOut = rfOUT > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) rfOUT;
+
+ if (rfReceiver.receiveEnergy(tDirection, rfOut, true) == rfOut) {
+ rfReceiver.receiveEnergy(tDirection, rfOut, false);
+ rUsedAmperes++;
+ }
+ else if (rfReceiver.receiveEnergy(tDirection, rfOut, true) > 0) {
+ if (mRestRF == 0) {
+ int RFtrans = rfReceiver.receiveEnergy(tDirection, (int) rfOut, false);
+ rUsedAmperes++;
+ mRestRF = rfOut - RFtrans;
+ } else {
+ int RFtrans = rfReceiver.receiveEnergy(tDirection, (int) mRestRF, false);
+ mRestRF = mRestRF - RFtrans;
+ }
+ }
+ if (GregTech_API.mRFExplosions && rfReceiver.getMaxEnergyStored(tDirection) < rfOut * 600) {
+ if (rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
+ }
+ return rUsedAmperes;
+ }
+
+ return 0;
+ }
+
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
+ if(aBaseMetaTileEntity.isServerSide()) {
+ lastAmperage = new int[16];
+ lastWorldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime() - 1;//sets initial value -1 since it is in the same tick as first on post tick
+ }
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+
+ { //amp handler
+ long worldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime();
+ int tickDiff = (int) (worldTick - lastWorldTick);
+ lastWorldTick = worldTick;
+
+ if (tickDiff >= 16) for (int i = 0; i <= 14; i++) lastAmperage[i] = 0;
+ else {
+ System.arraycopy(lastAmperage, tickDiff, lastAmperage, 0, 16 - tickDiff);
+ for (int i = 14; i >= 0; i--) {
+ if (--tickDiff > 0) lastAmperage[i] = 0;
+ else break;
+ }
+ }
+
+ lastAmperage[15] = mTransferredAmperage;
+
+ if (lastAmperage[15] > mAmperage) {
+ int i = 0;
+ for (; i <= 14; i++) {
+ if (lastAmperage[i] < mAmperage) {
+ lastAmperage[15] -= (int) mAmperage - lastAmperage[i];
+ lastAmperage[i] = (int)mAmperage;
+ if (lastAmperage[15] <= mAmperage) break;
+ }
+ }
+ if (lastAmperage[15] > mAmperage) {
+ mOverheat += 100 * (lastAmperage[15] - mAmperage);
+ lastAmperage[15] = (int) mAmperage;
+ } else if (lastAmperage[15] < mAmperage) {
+ lastAmperage[i] = lastAmperage[15];
+ lastAmperage[15] = (int) mAmperage;
+ }
+ }
+ }
+
+ if(mOverheat>=mMaxOverheat) {
+ //TODO someday
+ //int newMeta=aBaseMetaTileEntity.getMetaTileID()-6;
+ //if(mInsulated &&
+ // GregTech_API.METATILEENTITIES[newMeta] instanceof GT_MetaPipeEntity_Cable &&
+ // ((GT_MetaPipeEntity_Cable)GregTech_API.METATILEENTITIES[newMeta]).mMaterial==mMaterial &&
+ // ((GT_MetaPipeEntity_Cable)GregTech_API.METATILEENTITIES[newMeta]).mAmperage<=mAmperage){
+ // aBaseMetaTileEntity.setOnFire();
+ // aBaseMetaTileEntity.setMetaTileEntity(GregTech_API.METATILEENTITIES[newMeta]);
+ // return;
+ //}else{
+ aBaseMetaTileEntity.setToFire();
+ //}
+ }else if (mOverheat>0) mOverheat--;
+
+ mTransferredVoltageOK=mTransferredVoltage;
+ mTransferredVoltage=0;
+ mTransferredAmperageOK=mTransferredAmperage;
+ mTransferredAmperage = 0;
+
+ if (aTick % 20 == 0) {
+ mTransferredVoltageLast20OK=mTransferredVoltageLast20;
+ mTransferredVoltageLast20 = 0;
+ mTransferredAmperageLast20OK=mTransferredAmperageLast20;
+ mTransferredAmperageLast20 = 0;
+ if (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections) checkConnections();
+ }
+ } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
+ }
+
+ @Override
+ public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) {
+ if(isConnectedAtSide(aWrenchingSide)) {
+ disconnect(aWrenchingSide);
+ GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
+ }else if(!GT_Mod.gregtechproxy.costlyCableConnection){
+ if (connect(aWrenchingSide) > 0)
+ GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) {
+ if (isConnectedAtSide(aWrenchingSide)) {
+ disconnect(aWrenchingSide);
+ GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
+ } else if (!GT_Mod.gregtechproxy.costlyCableConnection || GT_ModHandler.consumeSolderingMaterial(aPlayer)) {
+ if (connect(aWrenchingSide) > 0)
+ GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+ @Override
+ public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+
+ @Override
+ public boolean canConnect(byte aSide, TileEntity tTileEntity) {
+ final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
+ final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
+ final byte tSide = GT_Utility.getOppositeSide(aSide);
+ final ForgeDirection tDir = ForgeDirection.getOrientation(tSide);
+
+ // GT Machine handling
+ if ((tTileEntity instanceof IEnergyConnected) &&
+ (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false)))
+ return true;
+
+ // Solar Panel Compat
+ if (coverBehavior instanceof GT_Cover_SolarPanel) return true;
+
+ // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) --> Not needed
+ if (Loader.isModLoaded("GalacticraftCore") && GT_GC_Compat.canConnect(tTileEntity,tDir))
+ return true;
+
+ // AE2-p2p Compat
+ if (GT_Mod.gregtechproxy.mAE2Integration) {
+ if (tTileEntity instanceof IEnergySource && tTileEntity instanceof IPartHost && ((IPartHost)tTileEntity).getPart(tDir) instanceof PartP2PGTPower && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir))
+ return true;
+ if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir))
+ return true;
+ }
+
+ // IC2 Compat
+ {
+ final TileEntity ic2Energy;
+
+ if (tTileEntity instanceof IReactorChamber)
+ ic2Energy = (TileEntity) ((IReactorChamber) tTileEntity).getReactor();
+ else
+ ic2Energy = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
+ EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
+
+ // IC2 Sink Compat
+ if ((ic2Energy instanceof IEnergySink) && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir))
+ return true;
+
+ // IC2 Source Compat
+ if (GT_Mod.gregtechproxy.ic2EnergySourceCompat && (ic2Energy instanceof IEnergySource)) {
+ if (((IEnergySource) ic2Energy).emitsEnergyTo((TileEntity) baseMetaTile, tDir)) {
+ return true;
+ }
+ }
+ }
+ // RF Output Compat
+ if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(tDir))
+ return true;
+
+ // RF Input Compat
+ if (GregTech_API.mInputRF && (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter) tTileEntity).emitsEnergyTo((TileEntity)baseMetaTile, tDir)))
+ return true;
+
+
+ return false;
+ }
+
+ @Override
+ public boolean getGT6StyleConnection() {
+ // Yes if GT6 Cables are enabled
+ return GT_Mod.gregtechproxy.gt6Cable;
+ }
+
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{
+ "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"
+ };
+ }
+
+ @Override
+ public float getThickNess() {
+ if(GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F;
+ return mThickNess;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ if (GT_Mod.gregtechproxy.gt6Cable)
+ aNBT.setByte("mConnections", mConnections);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ if (GT_Mod.gregtechproxy.gt6Cable) {
+ mConnections = aNBT.getByte("mConnections");
+ }
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[]{
+ //EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET,
+ "Heat: "+
+ EnumChatFormatting.RED+ mOverheat +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW+ mMaxOverheat + EnumChatFormatting.RESET,
+ "Max Load (1t):",
+ EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageOK) + EnumChatFormatting.RESET +" A / "+
+ EnumChatFormatting.YELLOW + Long.toString(mAmperage) + EnumChatFormatting.RESET +" A",
+ "Max EU/p (1t):",
+ EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageOK) + EnumChatFormatting.RESET +" EU / "+
+ EnumChatFormatting.YELLOW + Long.toString(mVoltage) + EnumChatFormatting.RESET +" EU",
+ "Max Load (20t): "+
+ EnumChatFormatting.GREEN + Integer.toString(mTransferredAmperageLast20OK) + EnumChatFormatting.RESET +" A",
+ "Max EU/p (20t): "+
+ EnumChatFormatting.GREEN + Long.toString(mTransferredVoltageLast20OK) + EnumChatFormatting.RESET +" EU"
+ };
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0)
+ return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
+ else
+ return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+
+ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ float tSpace = (1f - mThickNess)/2;
+ float tSide0 = tSpace;
+ float tSide1 = 1f - tSpace;
+ float tSide2 = tSpace;
+ float tSide3 = 1f - tSpace;
+ float tSide4 = tSpace;
+ float tSide5 = 1f - tSpace;
+
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
+
+ byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
+ if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
+ if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
+ if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
+ if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
+ if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
+ if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
+
+ return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
+ if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
+ AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
+ }
+ }
+
+ @Override
+ public boolean shouldJoinIc2Enet() {
+ if (!GT_Mod.gregtechproxy.ic2EnergySourceCompat) return false;
+
+ if (mConnections != 0) {
+ final IGregTechTileEntity baseMeta = getBaseMetaTileEntity();
+ for( byte aSide = 0 ; aSide < 6 ; aSide++) if(isConnectedAtSide(aSide)) {
+ final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(aSide);
+ final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity :
+ EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord);
+
+ if (tEmitter instanceof IEnergyEmitter)
+ return true;
+
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
index e128c8c842..0767bd0081 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
@@ -1,657 +1,658 @@
-package gregtech.api.metatileentity.implementations;
-
-import gregtech.GT_Mod;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.interfaces.tileentity.ICoverable;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.BaseMetaPipeEntity;
-import gregtech.api.metatileentity.MetaPipeEntity;
-import gregtech.api.objects.GT_RenderedTexture;
-import gregtech.api.util.GT_CoverBehavior;
-import gregtech.api.util.GT_Log;
-import gregtech.api.util.GT_Utility;
-import gregtech.common.GT_Client;
-import gregtech.common.covers.GT_Cover_Drain;
-import gregtech.common.covers.GT_Cover_FluidRegulator;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-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;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.FluidTankInfo;
-import net.minecraftforge.fluids.IFluidHandler;
-import org.apache.commons.lang3.tuple.MutableTriple;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static gregtech.api.enums.GT_Values.D1;
-import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
-
-public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
- public final float mThickNess;
- public final Materials mMaterial;
- public final int mCapacity, mHeatResistance, mPipeAmount;
- public final boolean mGasProof;
- public final FluidStack[] mFluids;
- public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0;
- /**
- * Bitmask for whether disable fluid input form each side.
- */
- public byte mDisableInput = 0;
-
- public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) {
- this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1);
- }
-
- public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) {
- super(aID, aName, aNameRegional, 0, false);
- mThickNess = aThickNess;
- mMaterial = aMaterial;
- mCapacity = aCapacity;
- mGasProof = aGasProof;
- mHeatResistance = aHeatResistance;
- mPipeAmount = aFluidTypes;
- mFluids = new FluidStack[mPipeAmount];
- addInfo(aID);
- }
-
- @Deprecated
- public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) {
- this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1);
- }
-
- public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) {
- super(aName, 0);
- mThickNess = aThickNess;
- mMaterial = aMaterial;
- mCapacity = aCapacity;
- mGasProof = aGasProof;
- mHeatResistance = aHeatResistance;
- mPipeAmount = aFluidTypes;
- mFluids = new FluidStack[mPipeAmount];
- }
-
- @Override
- public byte getTileEntityBaseType() {
- return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaPipeEntity_Fluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof, mPipeAmount);
- }
-
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
- float tThickNess = getThickNess();
- if (mDisableInput == 0) return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))};
- byte tMask = 0;
- byte[][] sRestrictionArray = new byte[][]{
- {2, 3, 5, 4},
- {2, 3, 4, 5},
- {1, 0, 4, 5},
- {1, 0, 4, 5},
- {1, 0, 2, 3},
- {1, 0, 2, 3}
- };
- if (aSide >= 0 && aSide < 6) for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i;
- return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)};
- }
-
- protected static final ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, byte aColorIndex) {
- if (aPipeAmount >= 9) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aPipeAmount >= 4) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aThickNess < 0.124F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aThickNess < 0.374F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aThickNess < 0.499F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aThickNess < 0.749F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- if (aThickNess < 0.874F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
- }
-
- protected static final ITexture getRestrictorTexture(byte aMask) {
- switch (aMask) {
- case 1: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UP);
- case 2: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DOWN);
- case 3: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UD);
- case 4: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_LEFT);
- case 5: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UL);
- case 6: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DL);
- case 7: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NR);
- case 8: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_RIGHT);
- case 9: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UR);
- case 10: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DR);
- case 11: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NL);
- case 12: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_LR);
- case 13: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_ND);
- case 14: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NU);
- case 15: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR);
- default: return null;
- }
- }
-
- @Override
- public void onValueUpdate(byte aValue) {
- mDisableInput = aValue;
- }
-
- @Override
- public byte getUpdateData() {
- return mDisableInput;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return true;
- }
-
- @Override
- public boolean isFacingValid(byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isValidSlot(int aIndex) {
- return false;
- }
-
- @Override
- public final boolean renderInside(byte aSide) {
- return false;
- }
-
- @Override
- public int getProgresstime() {
- return getFluidAmount();
- }
-
- @Override
- public int maxProgresstime() {
- return getCapacity();
- }
-
- @Override
- public void saveNBTData(NBTTagCompound aNBT) {
- for (int i = 0; i < mPipeAmount; i++)
- if (mFluids[i] != null)
- aNBT.setTag("mFluid"+(i==0?"":i), mFluids[i].writeToNBT(new NBTTagCompound()));
- aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom);
- if (GT_Mod.gregtechproxy.gt6Pipe) {
- aNBT.setByte("mConnections", mConnections);
- aNBT.setByte("mDisableInput", mDisableInput);
- }
- }
-
- @Override
- public void loadNBTData(NBTTagCompound aNBT) {
- for (int i = 0; i < mPipeAmount; i++)
- mFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"+(i==0?"":i)));
- mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom");
- if (GT_Mod.gregtechproxy.gt6Pipe) {
- mConnections = aNBT.getByte("mConnections");
- mDisableInput = aNBT.getByte("mDisableInput");
- }
- }
-
- @Override
- public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
- if ((((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) {
- for (FluidStack tFluid : mFluids) {
- if (tFluid != null) {
- int tTemperature = tFluid.getFluid().getTemperature(tFluid);
- if (tTemperature > 320 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) {
- GT_Utility.applyHeatDamage((EntityLivingBase) aEntity, (tTemperature - 300) / 50.0F); break;
- } else if (tTemperature < 260 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) {
- GT_Utility.applyFrostDamage((EntityLivingBase) aEntity, (270 - tTemperature) / 25.0F); break;
- }
- }
- }
- }
- }
-
- @Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) {
- mLastReceivedFrom &= 63;
- if (mLastReceivedFrom == 63) {
- mLastReceivedFrom = 0;
- }
-
- if (!GT_Mod.gregtechproxy.gt6Pipe || mCheckConnections) checkConnections();
-
- boolean shouldDistribute = (oLastReceivedFrom == mLastReceivedFrom);
- for (int i = 0, j = aBaseMetaTileEntity.getRandomNumber(mPipeAmount); i < mPipeAmount; i++) {
- int index = (i + j) % mPipeAmount;
- if (mFluids[index] != null && mFluids[index].amount <= 0) mFluids[index] = null;
- if (mFluids[index] == null) continue;
-
- if (checkEnvironment(index, aBaseMetaTileEntity)) return;
-
- if (shouldDistribute) {
- distributeFluid(index, aBaseMetaTileEntity);
- mLastReceivedFrom = 0;
- }
- }
-
- oLastReceivedFrom = mLastReceivedFrom;
-
- } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
- }
-
- private boolean checkEnvironment(int index, IGregTechTileEntity aBaseMetaTileEntity) {
- // Check for hot liquids that melt the pipe or gasses that escape and burn/freeze people
- final FluidStack tFluid = mFluids[index];
-
- if (tFluid != null && tFluid.amount > 0) {
- int tTemperature = tFluid.getFluid().getTemperature(tFluid);
- if (tTemperature > mHeatResistance) {
- if (aBaseMetaTileEntity.getRandomNumber(100) == 0) {
- // Poof
- GT_Log.exp.println("Set Pipe to Fire due to to low heat resistance at "+aBaseMetaTileEntity.getXCoord()+ " | "+aBaseMetaTileEntity.getYCoord()+ " | "+aBaseMetaTileEntity.getZCoord()+ " DIMID: "+aBaseMetaTileEntity.getWorld().provider.dimensionId);
- aBaseMetaTileEntity.setToFire();
- return true;
- }
- // Mmhmm, Fire
- aBaseMetaTileEntity.setOnFire();
- GT_Log.exp.println("Set Blocks around Pipe to Fire due to to low heat resistance at "+aBaseMetaTileEntity.getXCoord()+ " | "+aBaseMetaTileEntity.getYCoord()+ " | "+aBaseMetaTileEntity.getZCoord()+ " DIMID: "+aBaseMetaTileEntity.getWorld().provider.dimensionId);
-
- }
- if (!mGasProof && tFluid.getFluid().isGaseous(tFluid)) {
- tFluid.amount -= 5;
- sendSound((byte) 9);
- if (tTemperature > 320) {
- try {
- for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
- GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- } else if (tTemperature < 260) {
- try {
- for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
- GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F);
- }
- } catch (Throwable e) {
- if (D1) e.printStackTrace(GT_Log.err);
- }
- }
- }
- if (tFluid.amount <= 0) mFluids[index] = null;
- }
- return false;
- }
-
- private void distributeFluid(int index, IGregTechTileEntity aBaseMetaTileEntity) {
- final FluidStack tFluid = mFluids[index];
- if (tFluid == null) return;
-
- // Tank, From, Amount to receive
- List<MutableTriple<IFluidHandler, ForgeDirection, Integer>> tTanks = new ArrayList<>();
-
- for (byte aSide, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) {
- // Get a list of tanks accepting fluids, and what side they're on
- aSide = (byte) ((i + j) % 6);
- final byte tSide = GT_Utility.getOppositeSide(aSide);
- final IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aSide);
- final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null;
-
- if (isConnectedAtSide(aSide) && tTank != null && (mLastReceivedFrom & (1 << aSide)) == 0 &&
- getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) &&
- (gTank == null || gTank.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getCoverDataAtSide(tSide), tFluid.getFluid(), gTank)))
- {
- if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) {
- tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0));
- }
- }
- }
-
- // How much of this fluid is available for distribution?
- double tAmount = Math.max(1, Math.min(mCapacity * 10, tFluid.amount)), tNumTanks = tTanks.size();
- FluidStack maxFluid = tFluid.copy();
- maxFluid.amount = Integer.MAX_VALUE;
-
- double availableCapacity = 0;
- // Calculate available capacity for distribution from all tanks
- for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry: tTanks) {
- tEntry.right = tEntry.left.fill(tEntry.middle, maxFluid, false);
- availableCapacity += tEntry.right;
- }
-
- // Now distribute
- for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry: tTanks) {
- if (availableCapacity > tAmount) tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity);
- if (tEntry.right <= 0) continue;
-
- int tFilledAmount = tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false);
-
- if (tFilledAmount > 0) tEntry.left.fill(tEntry.middle, drainFromIndex(tFilledAmount, true, index), true);
- }
-
- }
-
- @Override
- public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (GT_Mod.gregtechproxy.gt6Pipe) {
- byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
- byte tMask = (byte) (1 << tSide);
- if (aPlayer.isSneaking()) {
- if (isInputDisabledAtSide(tSide)) {
- mDisableInput &= ~tMask;
- GT_Utility.sendChatToPlayer(aPlayer, trans("212", "Input enabled"));
- if (!isConnectedAtSide(tSide))
- connect(tSide);
- } else {
- mDisableInput |= tMask;
- GT_Utility.sendChatToPlayer(aPlayer, trans("213", "Input disabled"));
- }
- } else {
- if (!isConnectedAtSide(tSide)) {
- if (connect(tSide) > 0)
- GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
- }
- else {
- disconnect(tSide);
- GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
- }
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity);
- }
-
- @Override
- public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity);
- }
-
- @Override
- public boolean canConnect(byte aSide, TileEntity tTileEntity) {
- if (tTileEntity == null) return false;
-
- final byte tSide = (byte)ForgeDirection.getOrientation(aSide).getOpposite().ordinal();
- final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
- if (baseMetaTile == null) return false;
-
- final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
- final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null;
-
- if (coverBehavior instanceof GT_Cover_Drain) return true;
-
- // Tinker Construct Faucets return a null tank info, so check the class
- if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true;
-
- final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null;
-
- if (fTileEntity != null) {
- FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide));
- if (tInfo != null) {
- if (tInfo.length > 0) return true;
-
- // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern
- if (GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator) return true;
- if (gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator) return true;
-
- }
- }
- return false;
- }
-
- @Override
- public boolean getGT6StyleConnection() {
- // Yes if GT6 pipes are enabled
- return GT_Mod.gregtechproxy.gt6Pipe;
- }
-
- @Override
- public void doSound(byte aIndex, double aX, double aY, double aZ) {
- super.doSound(aIndex, aX, aY, aZ);
- if (aIndex == 9) {
- GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ);
- for (byte i = 0; i < 6; i++)
- getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + XSTR_INSTANCE.nextFloat(), aY - 0.5 + XSTR_INSTANCE.nextFloat(), aZ - 0.5 + XSTR_INSTANCE.nextFloat(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0);
- }
- }
-
- @Override
- public final int getCapacity() {
- return mCapacity * 20 * mPipeAmount;
- }
-
- @Override
- public FluidTankInfo getInfo() {
- for (FluidStack tFluid : mFluids) {
- if (tFluid != null)
- return new FluidTankInfo(tFluid, mCapacity * 20);
- }
- return new FluidTankInfo(null, mCapacity * 20);
- }
-
- @Override
- public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
- if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{};
- ArrayList<FluidTankInfo> tList = new ArrayList<>();
- for (FluidStack tFluid : mFluids)
- tList.add(new FluidTankInfo(tFluid, mCapacity * 20));
- return tList.toArray(new FluidTankInfo[mPipeAmount]);
- }
-
- @Override
- public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return false;
- }
-
- @Override
- public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return false;
- }
-
- @Override
- public final FluidStack getFluid() {
- for (FluidStack tFluid : mFluids) {
- if (tFluid != null)
- return tFluid;
- }
- return null;
- }
-
- @Override
- public final int getFluidAmount() {
- int rAmount = 0;
- for (FluidStack tFluid : mFluids) {
- if (tFluid != null)
- rAmount += tFluid.amount;
- }
- return rAmount;
- }
-
- @Override
- public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
- if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0;
-
- int index = -1;
- for (int i = 0; i < mPipeAmount; i++) {
- if (mFluids[i] != null && mFluids[i].isFluidEqual(aFluid)) {
- index = i; break;
- }
- else if ((mFluids[i] == null || mFluids[i].getFluid().getID() <= 0) && index < 0) {
- index = i;
- }
- }
-
- return fill_default_intoIndex(aSide, aFluid, doFill, index);
- }
-
- private final int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, boolean doFill, int index) {
- if (index < 0 || index >= mPipeAmount) return 0;
- if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0;
-
- if (mFluids[index] == null || mFluids[index].getFluid().getID() <= 0) {
- if (aFluid.amount * mPipeAmount <= getCapacity()) {
- if (doFill) {
- mFluids[index] = aFluid.copy();
- mLastReceivedFrom |= (1 << aSide.ordinal());
- }
- return aFluid.amount;
- }
- if (doFill) {
- mFluids[index] = aFluid.copy();
- mLastReceivedFrom |= (1 << aSide.ordinal());
- mFluids[index].amount = getCapacity() / mPipeAmount;
- }
- return getCapacity() / mPipeAmount;
- }
-
- if (!mFluids[index].isFluidEqual(aFluid)) return 0;
-
- int space = getCapacity() / mPipeAmount - mFluids[index].amount;
- if (aFluid.amount <= space) {
- if (doFill) {
- mFluids[index].amount += aFluid.amount;
- mLastReceivedFrom |= (1 << aSide.ordinal());
- }
- return aFluid.amount;
- }
- if (doFill) {
- mFluids[index].amount = getCapacity() / mPipeAmount;
- mLastReceivedFrom |= (1 << aSide.ordinal());
- }
- return space;
- }
-
- @Override
- public final FluidStack drain(int maxDrain, boolean doDrain) {
- FluidStack drained = null;
- for (int i = 0; i < mPipeAmount; i++) {
- if ((drained = drainFromIndex(maxDrain, doDrain, i)) != null)
- return drained;
- }
- return null;
- }
-
- private final FluidStack drainFromIndex(int maxDrain, boolean doDrain, int index) {
- if (index < 0 || index >= mPipeAmount) return null;
- if (mFluids[index] == null) return null;
- if (mFluids[index].amount <= 0) {
- mFluids[index] = null;
- return null;
- }
-
- int used = maxDrain;
- if (mFluids[index].amount < used)
- used = mFluids[index].amount;
-
- if (doDrain) {
- mFluids[index].amount -= used;
- }
-
- FluidStack drained = mFluids[index].copy();
- drained.amount = used;
-
- if (mFluids[index].amount <= 0) {
- mFluids[index] = null;
- }
-
- return drained;
- }
-
- @Override
- public int getTankPressure() {
- return getFluidAmount() - (getCapacity() / 2);
- }
-
- @Override
- public String[] getDescription() {
- if (mPipeAmount == 1) {
- return new String[]{
- EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY,
- EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY
- };
- } else {
- return new String[]{
- EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY,
- EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY,
- EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY
- };
- }
- }
-
- @Override
- public float getThickNess() {
- if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F;
- return mThickNess;
- }
-
- @Override
- public boolean isLiquidInput(byte aSide) {
- return !isInputDisabledAtSide(aSide);
- }
-
- @Override
- public boolean isLiquidOutput(byte aSide) {
- return true;
- }
-
- public boolean isInputDisabledAtSide(int aSide) {
- return (mDisableInput & (1 << aSide)) != 0;
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
- if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0)
- return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
- else
- return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
-
- private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
- float tSpace = (1f - mThickNess)/2;
- float tSide0 = tSpace;
- float tSide1 = 1f - tSpace;
- float tSide2 = tSpace;
- float tSide3 = 1f - tSpace;
- float tSide4 = tSpace;
- float tSide5 = 1f - tSpace;
-
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
- if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
-
- byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
- if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
- if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
- if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
- if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
- if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
- if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
-
- return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
- }
-
- @Override
- public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
- super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
- if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
- AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
- }
- }
-}
+package gregtech.api.metatileentity.implementations;
+
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.*;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.BaseMetaPipeEntity;
+import gregtech.api.metatileentity.MetaPipeEntity;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Client;
+import gregtech.common.covers.GT_Cover_Drain;
+import gregtech.common.covers.GT_Cover_FluidRegulator;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+import org.apache.commons.lang3.tuple.MutableTriple;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static gregtech.api.enums.GT_Values.D1;
+import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
+
+public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
+ public final float mThickNess;
+ public final Materials mMaterial;
+ public final int mCapacity, mHeatResistance, mPipeAmount;
+ public final boolean mGasProof;
+ public final FluidStack[] mFluids;
+ public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0;
+ /**
+ * Bitmask for whether disable fluid input form each side.
+ */
+ public byte mDisableInput = 0;
+
+ public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) {
+ this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1);
+ }
+
+ public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) {
+ super(aID, aName, aNameRegional, 0, false);
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mCapacity = aCapacity;
+ mGasProof = aGasProof;
+ mHeatResistance = aHeatResistance;
+ mPipeAmount = aFluidTypes;
+ mFluids = new FluidStack[mPipeAmount];
+ addInfo(aID);
+ }
+
+ @Deprecated
+ public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) {
+ this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1);
+ }
+
+ public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) {
+ super(aName, 0);
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mCapacity = aCapacity;
+ mGasProof = aGasProof;
+ mHeatResistance = aHeatResistance;
+ mPipeAmount = aFluidTypes;
+ mFluids = new FluidStack[mPipeAmount];
+ }
+
+ @Override
+ public byte getTileEntityBaseType() {
+ return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaPipeEntity_Fluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof, mPipeAmount);
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
+ float tThickNess = getThickNess();
+ if (mDisableInput == 0) return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))};
+ byte tMask = 0;
+ byte[][] sRestrictionArray = new byte[][]{
+ {2, 3, 5, 4},
+ {2, 3, 4, 5},
+ {1, 0, 4, 5},
+ {1, 0, 4, 5},
+ {1, 0, 2, 3},
+ {1, 0, 2, 3}
+ };
+ if (aSide >= 0 && aSide < 6) for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i;
+ return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)};
+ }
+
+ protected static final ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, byte aColorIndex) {
+ if (aPipeAmount >= 9) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aPipeAmount >= 4) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aThickNess < 0.124F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aThickNess < 0.374F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aThickNess < 0.499F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aThickNess < 0.749F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ if (aThickNess < 0.874F) return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa));
+ }
+
+ protected static final ITexture getRestrictorTexture(byte aMask) {
+ switch (aMask) {
+ case 1: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UP);
+ case 2: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DOWN);
+ case 3: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UD);
+ case 4: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_LEFT);
+ case 5: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UL);
+ case 6: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DL);
+ case 7: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NR);
+ case 8: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_RIGHT);
+ case 9: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_UR);
+ case 10: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_DR);
+ case 11: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NL);
+ case 12: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_LR);
+ case 13: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_ND);
+ case 14: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR_NU);
+ case 15: return new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR);
+ default: return null;
+ }
+ }
+
+ @Override
+ public void onValueUpdate(byte aValue) {
+ mDisableInput = aValue;
+ }
+
+ @Override
+ public byte getUpdateData() {
+ return mDisableInput;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return false;
+ }
+
+ @Override
+ public final boolean renderInside(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public int getProgresstime() {
+ return getFluidAmount();
+ }
+
+ @Override
+ public int maxProgresstime() {
+ return getCapacity();
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ for (int i = 0; i < mPipeAmount; i++)
+ if (mFluids[i] != null)
+ aNBT.setTag("mFluid"+(i==0?"":i), mFluids[i].writeToNBT(new NBTTagCompound()));
+ aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom);
+ if (GT_Mod.gregtechproxy.gt6Pipe) {
+ aNBT.setByte("mConnections", mConnections);
+ aNBT.setByte("mDisableInput", mDisableInput);
+ }
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ for (int i = 0; i < mPipeAmount; i++)
+ mFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"+(i==0?"":i)));
+ mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom");
+ if (GT_Mod.gregtechproxy.gt6Pipe) {
+ mConnections = aNBT.getByte("mConnections");
+ mDisableInput = aNBT.getByte("mDisableInput");
+ }
+ }
+
+ @Override
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if ((((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) {
+ for (FluidStack tFluid : mFluids) {
+ if (tFluid != null) {
+ int tTemperature = tFluid.getFluid().getTemperature(tFluid);
+ if (tTemperature > 320 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) {
+ GT_Utility.applyHeatDamage((EntityLivingBase) aEntity, (tTemperature - 300) / 50.0F); break;
+ } else if (tTemperature < 260 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) {
+ GT_Utility.applyFrostDamage((EntityLivingBase) aEntity, (270 - tTemperature) / 25.0F); break;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) {
+ mLastReceivedFrom &= 63;
+ if (mLastReceivedFrom == 63) {
+ mLastReceivedFrom = 0;
+ }
+
+ if (!GT_Mod.gregtechproxy.gt6Pipe || mCheckConnections) checkConnections();
+
+ boolean shouldDistribute = (oLastReceivedFrom == mLastReceivedFrom);
+ for (int i = 0, j = aBaseMetaTileEntity.getRandomNumber(mPipeAmount); i < mPipeAmount; i++) {
+ int index = (i + j) % mPipeAmount;
+ if (mFluids[index] != null && mFluids[index].amount <= 0) mFluids[index] = null;
+ if (mFluids[index] == null) continue;
+
+ if (checkEnvironment(index, aBaseMetaTileEntity)) return;
+
+ if (shouldDistribute) {
+ distributeFluid(index, aBaseMetaTileEntity);
+ mLastReceivedFrom = 0;
+ }
+ }
+
+ oLastReceivedFrom = mLastReceivedFrom;
+
+ } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
+ }
+
+ private boolean checkEnvironment(int index, IGregTechTileEntity aBaseMetaTileEntity) {
+ // Check for hot liquids that melt the pipe or gasses that escape and burn/freeze people
+ final FluidStack tFluid = mFluids[index];
+
+ if (tFluid != null && tFluid.amount > 0) {
+ int tTemperature = tFluid.getFluid().getTemperature(tFluid);
+ if (tTemperature > mHeatResistance) {
+ if (aBaseMetaTileEntity.getRandomNumber(100) == 0) {
+ // Poof
+ GT_Log.exp.println("Set Pipe to Fire due to to low heat resistance at "+aBaseMetaTileEntity.getXCoord()+ " | "+aBaseMetaTileEntity.getYCoord()+ " | "+aBaseMetaTileEntity.getZCoord()+ " DIMID: "+aBaseMetaTileEntity.getWorld().provider.dimensionId);
+ aBaseMetaTileEntity.setToFire();
+ return true;
+ }
+ // Mmhmm, Fire
+ aBaseMetaTileEntity.setOnFire();
+ GT_Log.exp.println("Set Blocks around Pipe to Fire due to to low heat resistance at "+aBaseMetaTileEntity.getXCoord()+ " | "+aBaseMetaTileEntity.getYCoord()+ " | "+aBaseMetaTileEntity.getZCoord()+ " DIMID: "+aBaseMetaTileEntity.getWorld().provider.dimensionId);
+
+ }
+ if (!mGasProof && tFluid.getFluid().isGaseous(tFluid)) {
+ tFluid.amount -= 5;
+ sendSound((byte) 9);
+ if (tTemperature > 320) {
+ try {
+ for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
+ GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ } else if (tTemperature < 260) {
+ try {
+ for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
+ GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F);
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
+ }
+ }
+ if (tFluid.amount <= 0) mFluids[index] = null;
+ }
+ return false;
+ }
+
+ private void distributeFluid(int index, IGregTechTileEntity aBaseMetaTileEntity) {
+ final FluidStack tFluid = mFluids[index];
+ if (tFluid == null) return;
+
+ // Tank, From, Amount to receive
+ List<MutableTriple<IFluidHandler, ForgeDirection, Integer>> tTanks = new ArrayList<>();
+
+ for (byte aSide, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) {
+ // Get a list of tanks accepting fluids, and what side they're on
+ aSide = (byte) ((i + j) % 6);
+ final byte tSide = GT_Utility.getOppositeSide(aSide);
+ final IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aSide);
+ final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null;
+
+ if (isConnectedAtSide(aSide) && tTank != null && (mLastReceivedFrom & (1 << aSide)) == 0 &&
+ getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) &&
+ (gTank == null || gTank.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getCoverDataAtSide(tSide), tFluid.getFluid(), gTank)))
+ {
+ if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) {
+ tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0));
+ }
+ }
+ }
+
+ // How much of this fluid is available for distribution?
+ double tAmount = Math.max(1, Math.min(mCapacity * 10, tFluid.amount)), tNumTanks = tTanks.size();
+ FluidStack maxFluid = tFluid.copy();
+ maxFluid.amount = Integer.MAX_VALUE;
+
+ double availableCapacity = 0;
+ // Calculate available capacity for distribution from all tanks
+ for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry: tTanks) {
+ tEntry.right = tEntry.left.fill(tEntry.middle, maxFluid, false);
+ availableCapacity += tEntry.right;
+ }
+
+ // Now distribute
+ for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry: tTanks) {
+ if (availableCapacity > tAmount) tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity); // Distribue fluids based on percentage available space at destination
+ if (tEntry.right == 0) tEntry.right = (int)Math.min(1, tAmount); // If the percent is not enough to give at least 1L, try to give 1L
+ if (tEntry.right <= 0) continue;
+
+ int tFilledAmount = tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false);
+
+ if (tFilledAmount > 0) tEntry.left.fill(tEntry.middle, drainFromIndex(tFilledAmount, true, index), true);
+ }
+
+ }
+
+ @Override
+ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (GT_Mod.gregtechproxy.gt6Pipe) {
+ byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
+ byte tMask = (byte) (1 << tSide);
+ if (aPlayer.isSneaking()) {
+ if (isInputDisabledAtSide(tSide)) {
+ mDisableInput &= ~tMask;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("212", "Input enabled"));
+ if (!isConnectedAtSide(tSide))
+ connect(tSide);
+ } else {
+ mDisableInput |= tMask;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("213", "Input disabled"));
+ }
+ } else {
+ if (!isConnectedAtSide(tSide)) {
+ if (connect(tSide) > 0)
+ GT_Utility.sendChatToPlayer(aPlayer, trans("214", "Connected"));
+ }
+ else {
+ disconnect(tSide);
+ GT_Utility.sendChatToPlayer(aPlayer, trans("215", "Disconnected"));
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity);
+ }
+
+ @Override
+ public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity);
+ }
+
+ @Override
+ public boolean canConnect(byte aSide, TileEntity tTileEntity) {
+ if (tTileEntity == null) return false;
+
+ final byte tSide = (byte)ForgeDirection.getOrientation(aSide).getOpposite().ordinal();
+ final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
+ if (baseMetaTile == null) return false;
+
+ final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
+ final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null;
+
+ if (coverBehavior instanceof GT_Cover_Drain) return true;
+
+ // Tinker Construct Faucets return a null tank info, so check the class
+ if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true;
+
+ final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null;
+
+ if (fTileEntity != null) {
+ FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide));
+ if (tInfo != null) {
+ if (tInfo.length > 0) return true;
+
+ // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern
+ if (GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator) return true;
+ if (gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator) return true;
+
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean getGT6StyleConnection() {
+ // Yes if GT6 pipes are enabled
+ return GT_Mod.gregtechproxy.gt6Pipe;
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {
+ super.doSound(aIndex, aX, aY, aZ);
+ if (aIndex == 9) {
+ GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ);
+ for (byte i = 0; i < 6; i++)
+ getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + XSTR_INSTANCE.nextFloat(), aY - 0.5 + XSTR_INSTANCE.nextFloat(), aZ - 0.5 + XSTR_INSTANCE.nextFloat(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0);
+ }
+ }
+
+ @Override
+ public final int getCapacity() {
+ return mCapacity * 20 * mPipeAmount;
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ for (FluidStack tFluid : mFluids) {
+ if (tFluid != null)
+ return new FluidTankInfo(tFluid, mCapacity * 20);
+ }
+ return new FluidTankInfo(null, mCapacity * 20);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{};
+ ArrayList<FluidTankInfo> tList = new ArrayList<>();
+ for (FluidStack tFluid : mFluids)
+ tList.add(new FluidTankInfo(tFluid, mCapacity * 20));
+ return tList.toArray(new FluidTankInfo[mPipeAmount]);
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public final FluidStack getFluid() {
+ for (FluidStack tFluid : mFluids) {
+ if (tFluid != null)
+ return tFluid;
+ }
+ return null;
+ }
+
+ @Override
+ public final int getFluidAmount() {
+ int rAmount = 0;
+ for (FluidStack tFluid : mFluids) {
+ if (tFluid != null)
+ rAmount += tFluid.amount;
+ }
+ return rAmount;
+ }
+
+ @Override
+ public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0;
+
+ int index = -1;
+ for (int i = 0; i < mPipeAmount; i++) {
+ if (mFluids[i] != null && mFluids[i].isFluidEqual(aFluid)) {
+ index = i; break;
+ }
+ else if ((mFluids[i] == null || mFluids[i].getFluid().getID() <= 0) && index < 0) {
+ index = i;
+ }
+ }
+
+ return fill_default_intoIndex(aSide, aFluid, doFill, index);
+ }
+
+ private final int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, boolean doFill, int index) {
+ if (index < 0 || index >= mPipeAmount) return 0;
+ if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0;
+
+ if (mFluids[index] == null || mFluids[index].getFluid().getID() <= 0) {
+ if (aFluid.amount * mPipeAmount <= getCapacity()) {
+ if (doFill) {
+ mFluids[index] = aFluid.copy();
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return aFluid.amount;
+ }
+ if (doFill) {
+ mFluids[index] = aFluid.copy();
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ mFluids[index].amount = getCapacity() / mPipeAmount;
+ }
+ return getCapacity() / mPipeAmount;
+ }
+
+ if (!mFluids[index].isFluidEqual(aFluid)) return 0;
+
+ int space = getCapacity() / mPipeAmount - mFluids[index].amount;
+ if (aFluid.amount <= space) {
+ if (doFill) {
+ mFluids[index].amount += aFluid.amount;
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return aFluid.amount;
+ }
+ if (doFill) {
+ mFluids[index].amount = getCapacity() / mPipeAmount;
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return space;
+ }
+
+ @Override
+ public final FluidStack drain(int maxDrain, boolean doDrain) {
+ FluidStack drained = null;
+ for (int i = 0; i < mPipeAmount; i++) {
+ if ((drained = drainFromIndex(maxDrain, doDrain, i)) != null)
+ return drained;
+ }
+ return null;
+ }
+
+ private final FluidStack drainFromIndex(int maxDrain, boolean doDrain, int index) {
+ if (index < 0 || index >= mPipeAmount) return null;
+ if (mFluids[index] == null) return null;
+ if (mFluids[index].amount <= 0) {
+ mFluids[index] = null;
+ return null;
+ }
+
+ int used = maxDrain;
+ if (mFluids[index].amount < used)
+ used = mFluids[index].amount;
+
+ if (doDrain) {
+ mFluids[index].amount -= used;
+ }
+
+ FluidStack drained = mFluids[index].copy();
+ drained.amount = used;
+
+ if (mFluids[index].amount <= 0) {
+ mFluids[index] = null;
+ }
+
+ return drained;
+ }
+
+ @Override
+ public int getTankPressure() {
+ return getFluidAmount() - (getCapacity() / 2);
+ }
+
+ @Override
+ public String[] getDescription() {
+ if (mPipeAmount == 1) {
+ return new String[]{
+ EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY,
+ EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY
+ };
+ } else {
+ return new String[]{
+ EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY,
+ EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY,
+ EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY
+ };
+ }
+ }
+
+ @Override
+ public float getThickNess() {
+ if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F;
+ return mThickNess;
+ }
+
+ @Override
+ public boolean isLiquidInput(byte aSide) {
+ return !isInputDisabledAtSide(aSide);
+ }
+
+ @Override
+ public boolean isLiquidOutput(byte aSide) {
+ return true;
+ }
+
+ public boolean isInputDisabledAtSide(int aSide) {
+ return (mDisableInput & (1 << aSide)) != 0;
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0)
+ return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
+ else
+ return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+
+ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ float tSpace = (1f - mThickNess)/2;
+ float tSide0 = tSpace;
+ float tSide1 = 1f - tSpace;
+ float tSide2 = tSpace;
+ float tSide3 = 1f - tSpace;
+ float tSide4 = tSpace;
+ float tSide5 = 1f - tSpace;
+
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
+ if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
+
+ byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
+ if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
+ if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
+ if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
+ if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
+ if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
+ if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
+
+ return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
+ if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
+ AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
index fd04893ec7..7074d63422 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
@@ -33,7 +33,7 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity {
@Override
public byte getTileEntityBaseType() {
- return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
+ return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
}
@Override
@@ -97,4 +97,9 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity {
@Override
public void disconnect(byte aSide) {/* Do nothing*/}
+
+ @Override
+ public boolean isMachineBlockUpdateRecursive() {
+ return true;
+ }
} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
index bba105c95f..650e9a031e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
@@ -64,7 +64,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
@Override
public byte getTileEntityBaseType() {
- return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
+ return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
index c35690b868..1a81e4d570 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
@@ -240,6 +240,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
mChargeableCount++;
}
}
+ count++;
}
@Override
@@ -269,7 +270,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
}
return false;
}
-
+
@Override
public int getInventoryStackLimit() {
return 1;
@@ -309,19 +310,22 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
@Override
public String[] getInfoData() {
- count++;
- if (mMax == 0 || count % 20 == 0) {
+ if (mMax == 0 || (count > 20)) {
long[] tmp = getStoredEnergy();
mStored = tmp[0];
mMax = tmp[1];
+ count = 0;
}
return new String[]{
EnumChatFormatting.BLUE+getLocalName()+EnumChatFormatting.RESET,
"Stored Items:",
EnumChatFormatting.GREEN+GT_Utility.formatNumbers(mStored) +EnumChatFormatting.RESET+ " EU / "+
- EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU"
- };
+ EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU",
+ "Average input:",
+ GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricInput())+" EU/t",
+ "Average output:",
+ GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricOutput())+" EU/t"};
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
index c20b8ad3a8..ccc0fc0af4 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
@@ -1,8 +1,12 @@
package gregtech.api.metatileentity.implementations;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.objects.ItemData;
+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;
@@ -11,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+import net.minecraftforge.fluids.IFluidHandler;
import java.util.Collection;
@@ -153,8 +159,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
@Override
public boolean doesFillContainers() {
- //return getBaseMetaTileEntity().isAllowedToWork();
- return false;
+ return getBaseMetaTileEntity().isAllowedToWork();
+ //return false;
}
@Override
@@ -202,11 +208,11 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
} else {
if (mInventory[getStackDisplaySlot()] == null)
mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
- mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU");
+ mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU");
}
} else {
- int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid);
- if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) {
+ long tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid);
+ if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount >= tConsumed) {
long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
//long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK
if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) {
@@ -215,8 +221,10 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
}
}
}
- if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) {
- int tFuelValue = getFuelValue(mInventory[getInputSlot()]);
+
+ if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || solidFuelOverride(mInventory[getInputSlot()]))) {
+ long tFuelValue = getFuelValue(mInventory[getInputSlot()]);
+ //System.out.println(" tFuelValue : " + tFuelValue );
if (tFuelValue > 0) {
ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]);
if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
@@ -231,7 +239,26 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
if (aBaseMetaTileEntity.isServerSide())
aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU());
}
-
+
+ /**
+ * @param stack the fuel stack
+ * @return if the stack is a solid fuel
+ */
+ public boolean solidFuelOverride(ItemStack stack) {
+ //this could be used for a coal generator for example aswell...
+ ItemData association = GT_OreDictUnificator.getAssociation(stack);
+ //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK, cell, motlen cell or plasma cell, else do vanilla checks
+ return association != null ? !OrePrefixes.cell.equals(association.mPrefix) &&
+ !OrePrefixes.cellMolten.equals(association.mPrefix) &&
+ !OrePrefixes.cellPlasma.equals(association.mPrefix) &&
+ !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true) :
+ stack != null && //when the stack is null its not a solid
+ stack.getItem() != null && //when the item in the stack is null its not a solid
+ !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid...
+ !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid...
+ !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets...
+ }
+
public abstract int getPollution();
public abstract GT_Recipe_Map getRecipes();
@@ -243,20 +270,33 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
}
public int getFuelValue(FluidStack aLiquid) {
+ //System.out.println("Fluid stack check");
if (aLiquid == null || getRecipes() == null) return 0;
FluidStack tLiquid;
Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList;
if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList)
if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null)
- if (aLiquid.isFluidEqual(tLiquid))
- return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100);
+ if (aLiquid.isFluidEqual(tLiquid)){
+ long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid) / 100;
+ if(val> Integer.MAX_VALUE){
+ throw new ArithmeticException("Integer LOOPBACK!");
+ }
+ return (int) val;
+ }
return 0;
}
public int getFuelValue(ItemStack aStack) {
+ //System.out.println("Item stack check");
if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
- if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100);
+ if (tFuel != null){
+ long val=(long)tFuel.mSpecialValue * 10L /*<- 1000mb/100 */ * getEfficiency();
+ if(val> Integer.MAX_VALUE){
+ throw new ArithmeticException("Integer LOOPBACK!");
+ }
+ return (int) val;
+ }
return 0;
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
index bf6293baae..17dbd560a2 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
@@ -1,5 +1,6 @@
package gregtech.api.metatileentity.implementations;
+import cpw.mods.fml.common.Loader;
import gregtech.api.enums.*;
import gregtech.api.gui.GT_Container_BasicMachine;
import gregtech.api.gui.GT_GUIContainer_BasicMachine;
@@ -9,22 +10,19 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_ModHandler.RecipeBits;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import ic2.core.Ic2Items;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
import java.util.Random;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.enums.GT_Values.W;
-import static gregtech.api.enums.GT_Values.ticksBetweenSounds;
+import static gregtech.api.enums.GT_Values.*;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -33,70 +31,77 @@ import static gregtech.api.enums.GT_Values.ticksBetweenSounds;
* Extend this class to make a simple Machine
*/
public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_BasicMachine {
- private final GT_Recipe_Map mRecipes;
+ private final GT_Recipe.GT_Recipe_Map mRecipes;
private final int mTankCapacity, mSpecialEffect;
private final String mSound;
private final boolean mSharedTank, mRequiresFluidForFiltering;
private final byte mGUIParameterA, mGUIParameterB;
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) {
- super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM"))});
- mSharedTank = aSharedTank;
- mTankCapacity = aTankCapacity;
- mSpecialEffect = aSpecialEffect;
- mRequiresFluidForFiltering = aRequiresFluidForFiltering;
- mRecipes = aRecipes;
- mSound = aSound;
- mGUIParameterA = (byte) aGUIParameterA;
- mGUIParameterB = (byte) aGUIParameterB;
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) {
+ super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM")));
+ this.mSharedTank = aSharedTank;
+ this.mTankCapacity = aTankCapacity;
+ this.mSpecialEffect = aSpecialEffect;
+ this.mRequiresFluidForFiltering = aRequiresFluidForFiltering;
+ this.mRecipes = aRecipes;
+ this.mSound = aSound;
+ this.mGUIParameterA = (byte) aGUIParameterA;
+ this.mGUIParameterB = (byte) aGUIParameterB;
//TODO: CHECK
if (aRecipe != null) {
for (int i = 3; i < aRecipe.length; i++) {
- if (aRecipe[i] == X.CIRCUIT) {
- aRecipe[i] = Tier.ELECTRIC[mTier].mManagingObject;
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT) {
+ aRecipe[i] = Tier.ELECTRIC[this.mTier].mManagingObject;
continue;
}
- if (aRecipe[i] == X.BETTER_CIRCUIT) {
- aRecipe[i] = Tier.ELECTRIC[mTier].mBetterManagingObject;
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.BETTER_CIRCUIT) {
+ aRecipe[i] = Tier.ELECTRIC[this.mTier].mBetterManagingObject;
continue;
}
- if (aRecipe[i] == X.HULL) {
- aRecipe[i] = Tier.ELECTRIC[mTier].mHullObject;
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL) {
+ aRecipe[i] = Tier.ELECTRIC[this.mTier].mHullObject;
continue;
}
- if (aRecipe[i] == X.WIRE) {
- aRecipe[i] = Tier.ELECTRIC[mTier].mConductingObject;
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE) {
+ aRecipe[i] = Tier.ELECTRIC[this.mTier].mConductingObject;
continue;
}
- if (aRecipe[i] == X.WIRE4) {
- aRecipe[i] = Tier.ELECTRIC[mTier].mLargerConductingObject;
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4) {
+ aRecipe[i] = Tier.ELECTRIC[this.mTier].mLargerConductingObject;
continue;
}
- if (aRecipe[i] == X.GLASS) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.GLASS) {
+ switch (this.mTier) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ aRecipe[i] = new ItemStack(Blocks.glass, 1, W);
+ break;
+ case 4:
+ case 5:
case 6:
case 7:
case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- aRecipe[i] = Ic2Items.reinforcedGlass;
- break;
+ if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums?
+ aRecipe[i] = "blockGlass"+VN[aTier];
+ break;
+ }
default:
- aRecipe[i] = new ItemStack(Blocks.glass, 1, W);
+ if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums?
+ aRecipe[i] = "blockGlass"+VN[8];
+ } else {
+ aRecipe[i] = Ic2Items.reinforcedGlass;
+ }
break;
}
continue;
}
- if (aRecipe[i] == X.PLATE) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.plate.get(Materials.Steel);
@@ -119,9 +124,6 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = OrePrefixes.plate.get(Materials.HSSE);
break;
- case 8:
- aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium);
- break;
default:
aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium);
break;
@@ -129,8 +131,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.PIPE) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PIPE) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze);
@@ -157,14 +159,14 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
aRecipe[i] = OrePrefixes.pipeLarge.get(Materials.Ultimate);
break;
default:
- aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Ultimate);
+ aRecipe[i] = OrePrefixes.pipeHuge.get(Materials.Ultimate);
break;
}
continue;
}
- if (aRecipe[i] == X.COIL_HEATING) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_HEATING) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper);
@@ -190,6 +192,9 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 8:
aRecipe[i] = OrePrefixes.wireGt02.get(Materials.NaquadahAlloy);
break;
+ case 9:
+ aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy);
+ break;
default:
aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy);
break;
@@ -197,8 +202,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.COIL_HEATING_DOUBLE) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_HEATING_DOUBLE) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper);
@@ -224,6 +229,9 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 8:
aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy);
break;
+ case 9:
+ aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy);
+ break;
default:
aRecipe[i] = OrePrefixes.wireGt16.get(Materials.NaquadahAlloy);
break;
@@ -231,8 +239,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.STICK_DISTILLATION) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_DISTILLATION) {
+ switch (this.mTier) {
default:
aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze);
break;
@@ -240,8 +248,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.STICK_MAGNETIC) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_MAGNETIC) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic);
@@ -265,8 +273,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.STICK_ELECTROMAGNETIC) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_ELECTROMAGNETIC) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron);
@@ -285,10 +293,10 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.COIL_ELECTRIC) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_ELECTRIC) {
+ switch (this.mTier) {
case 0:
- aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Tin);
+ aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Lead);
break;
case 1:
aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin);
@@ -303,23 +311,23 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper);
break;
case 5:
- aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper);
+ aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper);
break;
case 6:
aRecipe[i] = OrePrefixes.wireGt04.get(Materials.YttriumBariumCuprate);
break;
case 7:
- aRecipe[i] = OrePrefixes.wireGt08.get(Materials.SuperconductorUHV);
+ aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Iridium);
break;
default:
- aRecipe[i] = OrePrefixes.wireGt16.get(Materials.SuperconductorUHV);
+ aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Osmium);
break;
}
continue;
}
- if (aRecipe[i] == X.ROBOT_ARM) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Robot_Arm_LV;
@@ -342,15 +350,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Robot_Arm_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Robot_Arm_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Robot_Arm_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Robot_Arm_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.PUMP) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PUMP) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Electric_Pump_LV;
@@ -373,15 +387,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Electric_Pump_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Electric_Pump_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Electric_Pump_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Electric_Pump_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.ROTOR) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROTOR) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin);
@@ -411,8 +431,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
continue;
}
- if (aRecipe[i] == X.MOTOR) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Electric_Motor_LV;
@@ -435,15 +455,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Electric_Motor_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Electric_Motor_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Electric_Motor_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Electric_Motor_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.PISTON) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Electric_Piston_LV;
@@ -466,15 +492,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Electric_Piston_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Electric_Piston_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Electric_Piston_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Electric_Piston_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.CONVEYOR) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CONVEYOR) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Conveyor_Module_LV;
@@ -497,15 +529,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Conveyor_Module_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Conveyor_Module_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Conveyor_Module_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Conveyor_Module_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.EMITTER) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.EMITTER) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Emitter_LV;
@@ -528,15 +566,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Emitter_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Emitter_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Emitter_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Emitter_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.SENSOR) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.SENSOR) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Sensor_LV;
@@ -559,15 +603,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Sensor_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Sensor_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Sensor_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Sensor_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] == X.FIELD_GENERATOR) {
- switch (mTier) {
+ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.FIELD_GENERATOR) {
+ switch (this.mTier) {
case 0:
case 1:
aRecipe[i] = ItemList.Field_Generator_LV;
@@ -590,50 +640,56 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
case 7:
aRecipe[i] = ItemList.Field_Generator_ZPM;
break;
- default:
+ case 8:
aRecipe[i] = ItemList.Field_Generator_UV;
break;
+ case 9:
+ aRecipe[i] = ItemList.Field_Generator_UHV;
+ break;
+ default:
+ aRecipe[i] = ItemList.Field_Generator_UEV;
+ break;
}
continue;
}
- if (aRecipe[i] instanceof X)
+ if (aRecipe[i] instanceof GT_MetaTileEntity_BasicMachine_GT_Recipe.X)
throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier);
}
- if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), RecipeBits.DISMANTLEABLE | RecipeBits.BUFFERED | RecipeBits.NOT_REMOVABLE | RecipeBits.REVERSIBLE, aRecipe)) {
+ if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, aRecipe)) {
throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName());
}
}
}
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName);
- mSharedTank = aSharedTank;
- mTankCapacity = aTankCapacity;
- mSpecialEffect = aSpecialEffect;
- mRequiresFluidForFiltering = aRequiresFluidForFiltering;
- mRecipes = aRecipes;
- mSound = aSound;
- mGUIParameterA = (byte) aGUIParameterA;
- mGUIParameterB = (byte) aGUIParameterB;
+ this.mSharedTank = aSharedTank;
+ this.mTankCapacity = aTankCapacity;
+ this.mSpecialEffect = aSpecialEffect;
+ this.mRequiresFluidForFiltering = aRequiresFluidForFiltering;
+ this.mRecipes = aRecipes;
+ this.mSound = aSound;
+ this.mGUIParameterA = (byte) aGUIParameterA;
+ this.mGUIParameterB = (byte) aGUIParameterB;
}
- public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String[] aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
+ public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) {
super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName);
- mSharedTank = aSharedTank;
- mTankCapacity = aTankCapacity;
- mSpecialEffect = aSpecialEffect;
- mRequiresFluidForFiltering = aRequiresFluidForFiltering;
- mRecipes = aRecipes;
- mSound = aSound;
- mGUIParameterA = (byte) aGUIParameterA;
- mGUIParameterB = (byte) aGUIParameterB;
+ this.mSharedTank = aSharedTank;
+ this.mTankCapacity = aTankCapacity;
+ this.mSpecialEffect = aSpecialEffect;
+ this.mRequiresFluidForFiltering = aRequiresFluidForFiltering;
+ this.mRecipes = aRecipes;
+ this.mSound = aSound;
+ this.mGUIParameterA = (byte) aGUIParameterA;
+ this.mGUIParameterB = (byte) aGUIParameterB;
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaTileEntity_BasicMachine_GT_Recipe(mName, mTier, mDescriptionArray, mRecipes, mInputSlotCount, mOutputItems == null ? 0 : mOutputItems.length, mTankCapacity, mAmperage, mGUIParameterA, mGUIParameterB, mTextures, mGUIName, mNEIName, mSound, mSharedTank, mRequiresFluidForFiltering, mSpecialEffect);
+ return new GT_MetaTileEntity_BasicMachine_GT_Recipe(this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length, this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSound, this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect);
}
@Override
@@ -643,22 +699,32 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "", mGUIParameterA, mGUIParameterB);
+ return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName, GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", this.mGUIParameterA, this.mGUIParameterB);
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false;
- if (mInventory[aIndex] != null) return true;
- switch (mInputSlotCount) {
+ if (this.mInventory[aIndex] != null) return true;
+ switch (this.mInputSlotCount) {
case 0:
return false;
case 1:
- return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), new ItemStack[]{aStack});
+ return this.getFillableStack() == null ? !this.mRequiresFluidForFiltering && this.getRecipeList().containsInput(aStack) : null != this.getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, this.getSpecialSlot(), new ItemStack[]{aStack});
case 2:
- return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0) != null && getInputAt(1) != null) || (getInputAt(0) == null && getInputAt(1) == null ? getRecipeList().containsInput(aStack) : (getRecipeList().containsInput(aStack) && null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[]{aStack, getInputAt(1)} : new ItemStack[]{getInputAt(0), aStack})))));
- default:
- return getRecipeList().containsInput(aStack);
+ return (!this.mRequiresFluidForFiltering || this.getFillableStack() != null) && (((this.getInputAt(0) != null && this.getInputAt(1) != null) || (this.getInputAt(0) == null && this.getInputAt(1) == null ? this.getRecipeList().containsInput(aStack) : (this.getRecipeList().containsInput(aStack) && null != this.getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, this.getSpecialSlot(), aIndex == this.getInputSlot() ? new ItemStack[]{aStack, this.getInputAt(1)} : new ItemStack[]{this.getInputAt(0), aStack})))));
+ default:{
+ int tID = this.getBaseMetaTileEntity().getMetaTileID();
+ if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) {//assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev
+ if (GT_Utility.isStackValid(aStack))
+ for (int oreID : OreDictionary.getOreIDs(aStack)) {
+ if (OreDictionary.getOreName(oreID).contains("circuit"))
+ return true;
+ }
+ }
+ return this.getRecipeList().containsInput(aStack);
+ }
+
}
}
@@ -667,7 +733,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPreTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) {
- switch (mSpecialEffect) {
+ switch (this.mSpecialEffect) {
case 0:
break;
case 1:
@@ -681,27 +747,27 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
}
@Override
- public GT_Recipe_Map getRecipeList() {
- return mRecipes;
+ public GT_Recipe.GT_Recipe_Map getRecipeList() {
+ return this.mRecipes;
}
@Override
public int getCapacity() {
- return mTankCapacity;
+ return this.mTankCapacity;
}
@Override
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
super.startSoundLoop(aIndex, aX, aY, aZ);
- if (aIndex == 1 && GT_Utility.isStringValid(mSound)) GT_Utility.doSoundAtClient(mSound, 100, 1.0F, aX, aY, aZ);
+ if (aIndex == 1 && GT_Utility.isStringValid(this.mSound)) GT_Utility.doSoundAtClient(this.mSound, 100, 1.0F, aX, aY, aZ);
}
@Override
public void startProcess() {
- BaseMetaTileEntity myMetaTileEntity = ((BaseMetaTileEntity)getBaseMetaTileEntity());
+ BaseMetaTileEntity myMetaTileEntity = ((BaseMetaTileEntity) this.getBaseMetaTileEntity());
// Added to throttle sounds. To reduce lag, this is on the server side so BlockUpdate packets aren't sent.
if (myMetaTileEntity.mTickTimer > (myMetaTileEntity.mLastSoundTick+ticksBetweenSounds)) {
- if (GT_Utility.isStringValid(mSound)) sendLoopStart((byte) 1);
+ if (GT_Utility.isStringValid(this.mSound)) this.sendLoopStart((byte) 1);
// Does not have overflow protection, but they are longs.
myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer;
}
@@ -709,18 +775,18 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
@Override
public FluidStack getFillableStack() {
- return mSharedTank ? getDrainableStack() : super.getFillableStack();
+ return this.mSharedTank ? this.getDrainableStack() : super.getFillableStack();
}
@Override
public FluidStack setFillableStack(FluidStack aFluid) {
- return mSharedTank ? setDrainableStack(aFluid) : super.setFillableStack(aFluid);
+ return this.mSharedTank ? this.setDrainableStack(aFluid) : super.setFillableStack(aFluid);
}
@Override
protected boolean displaysOutputFluid() {
- return !mSharedTank;
+ return !this.mSharedTank;
}
- public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC}
+ public enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
index d57aff8fc9..6d99a24347 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
@@ -6,8 +6,14 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import net.minecraft.nbt.NBTTagCompound;
+/**
+ * Handles texture changes internally. No special calls are necessary other than updateTexture in add***ToMachineList.
+ */
public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTank {
- @Deprecated //Use texture changing method
+ /**
+ * Uses new texture changing methods to avoid limitations of byte as texture index...
+ */
+ @Deprecated
public byte mMachineBlock = 0;
private byte mTexturePage = 0;
private byte actualTexture = 0;
@@ -43,19 +49,30 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- int textureIndex=actualTexture|(mTexturePage<<7);//Shift seven since one page is 128 textures!
- int texturePointer=(byte)(actualTexture&0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside
- return aSide != aFacing ?
- textureIndex > 0 ?
- new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]} :
- new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} :
- textureIndex > 0 ?
- aActive ?
- getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) :
- getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) :
- aActive ?
- getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) :
- getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ int textureIndex = actualTexture | (mTexturePage << 7);//Shift seven since one page is 128 textures!
+ int texturePointer = (byte) (actualTexture & 0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside
+ try {
+ if (aSide != aFacing) {
+ if (textureIndex > 0)
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]};
+ else
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ } else {
+ if (textureIndex > 0) {
+ if (aActive)
+ return getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]);
+ else
+ return getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]);
+ } else {
+ if (aActive)
+ return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ else
+ return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ }
+ }
+ } catch (NullPointerException npe) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[0][0]};
+ }
}
@Override
@@ -77,21 +94,23 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
}
/**
- *
- * @param textureIndex
- * Index between 0-127.
- * Add 128 per page, if texture index is not on first page.
- *
+ * Sets texture with page and index, called on add to machine list
+ * @param id (page<<7)+index of the texture
*/
-
- public final void updateTexture(int textureIndex){
- onValueUpdate((byte) textureIndex);
- onTexturePageUpdate((byte) (textureIndex>>7));
+ public final void updateTexture(int id){
+ onValueUpdate((byte) id);
+ onTexturePageUpdate((byte) (id>>7));
}
- public final void updateTexture(byte texturePage, byte machineBlock){
- onValueUpdate(machineBlock);
- onTexturePageUpdate(texturePage);
+ /**
+ * Sets texture with page and index, rather unusable, but kept FFS
+ * @param page page of texure
+ * @param index index of texure
+ */
+ @Deprecated
+ public final void updateTexture(byte page, byte index){
+ onValueUpdate(index);
+ onTexturePageUpdate(page);
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
index d053bc658e..8c36c2af65 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
@@ -6,24 +6,29 @@ 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_LanguageManager;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
public GT_Recipe_Map mRecipeMap = null;
+ public boolean disableSort;
public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Input for Multiblocks",
- "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")});
+ super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{
+ "Item Input for Multiblocks",
+ "Shift + right click with screwdriver to turn Sort mode on/off",
+ "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")});
}
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
}
-
+
public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures);
}
@@ -114,11 +119,43 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
}
protected void fillStacksIntoFirstSlots() {
- for (int i = 0; i < mInventory.length; i++)
- for (int j = i + 1; j < mInventory.length; j++)
- if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) {
- GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
- }
+ if (disableSort) {
+ for (int i = 0; i < mInventory.length; i++)
+ for (int j = i + 1; j < mInventory.length; j++)
+ if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j])))
+ GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ } else {
+ for (int i = 0; i < mInventory.length; i++)
+ for (int j = i + 1; j < mInventory.length; j++)
+ if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j])))
+ GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("disableSort", disableSort);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ disableSort = aNBT.getBoolean("disableSort");
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ return;
+ if (aPlayer.isSneaking()) {
+ disableSort = !disableSort;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled")));
+ }
+ }
+
+ public String trans(String aKey, String aEnglish) {
+ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
index 9c74811b23..71eea9bf87 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
@@ -10,9 +10,9 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraftforge.fluids.*;
public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
private String lockedFluidName = null;
@@ -207,7 +207,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
playerThatLockedfluid = aPlayer;
if (mFluid == null) {
this.setLockedFluidName(null);
- inBrackets = trans("115.3","currently none, will be locked to the next that is put in");
+ inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)");
} else {
this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName());
inBrackets = this.getDrainableStack().getLocalizedName();
@@ -218,7 +218,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
playerThatLockedfluid = aPlayer;
if (mFluid == null) {
this.setLockedFluidName(null);
- inBrackets = trans("115.3","currently none, will be locked to the next that is put in");
+ inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)");
} else {
this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName());
inBrackets = this.getDrainableStack().getLocalizedName();
@@ -227,7 +227,41 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
break;
}
}
-
+ private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ return false;
+ if (!isFluidLocked())
+ return false;
+ ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
+ if (tCurrentItem == null)
+ return false;
+ FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tCurrentItem);
+ if (tFluid == null && tCurrentItem.getItem() instanceof IFluidContainerItem)
+ tFluid = ((IFluidContainerItem)tCurrentItem.getItem()).getFluid(tCurrentItem);
+ if (tFluid != null) {
+ if (getLockedFluidName() != null && !getLockedFluidName().equals(tFluid.getUnlocalizedName())) {
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s %s", trans("151.3",
+ "Hatch is locked to a different fluid. To change the locking, empty it and made it locked to the next fluid with a screwdriver. Currently locked to")
+ , StatCollector.translateToLocal(getLockedFluidName())));
+ }
+ else {
+ setLockedFluidName(tFluid.getUnlocalizedName());
+ if (mMode == 8)
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.1", "Outputs items and 1 specific Fluid"), tFluid.getLocalizedName()));
+ else
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.2", "Outputs 1 specific Fluid"), tFluid.getLocalizedName()));
+ }
+ return true;
+ }
+ return false;
+ }
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ if (tryToLockHatch(aPlayer, aSide))
+ return true;
+ return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ);
+ }
+
public String trans(String aKey, String aEnglish){
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false);
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index ad5b94266c..3efbe0d57b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -8,8 +8,6 @@ import java.util.ArrayList;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
-import gregtech.api.enums.Materials;
-import gregtech.api.enums.OrePrefixes;
import gregtech.api.gui.GT_Container_MultiMachine;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
@@ -19,7 +17,6 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
@@ -36,7 +33,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public static boolean disableMaintenance;
public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, 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 int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0;
+ public volatile int mUpdate = 0;
public ItemStack[] mOutputItems = null;
public FluidStack[] mOutputFluids = null;
public String mNEI;
@@ -435,7 +433,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
NBTTagCompound tNBT = mInventory[1].getTagCompound();
if (tNBT != null) {
NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");//tNBT2 dont use out if
- if (!tNBT.getBoolean("mDis")) {
+ /*if (!tNBT.getBoolean("mDis")) {
tNBT2 = new NBTTagCompound();
Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]);
ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1);
@@ -487,7 +485,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
tNBT.setBoolean("mDis", true);
mInventory[1].setTagCompound(tNBT);
- }
+ }*/
}
((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long)getDamageToComponent(mInventory[1]) * (long) Math.min(mEUt / this.damageFactorLow, Math.pow(mEUt, this.damageFactorHigh)));
if (mInventory[1].stackSize == 0) mInventory[1] = null;
@@ -515,15 +513,77 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public boolean addEnergyOutput(long aEU) {
- if (aEU <= 0) return true;
- for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) {
- return true;
+ if (aEU <= 0) {
+ return true;
+ }
+ if (mDynamoHatches.size() > 0) {
+ return addEnergyOutputMultipleDynamos(aEU, true);
+ }
+ return false;
+ }
+ public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) {
+ int injected = 0;
+ long totalOutput = 0;
+ long aFirstVoltageFound = -1;
+ boolean aFoundMixedDynamos = false;
+ for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) {
+ if( aDynamo == null ) {
+ return false;
+ }
+ if (isValidMetaTileEntity(aDynamo)) {
+ long aVoltage = aDynamo.maxEUOutput();
+ long aTotal = aDynamo.maxAmperesOut() * aVoltage;
+ // Check against voltage to check when hatch mixing
+ if (aFirstVoltageFound == -1) {
+ aFirstVoltageFound = aVoltage;
}
+ else {
+ /**
+ * Calcualtes overclocked ness using long integers
+ * @param aEUt - recipe EUt
+ * @param aDuration - recipe Duration
+ * @param mAmperage - should be 1 ?
+ */
+ //Long time calculation
+ if (aFirstVoltageFound != aVoltage) {
+ aFoundMixedDynamos = true;
+ }
+ }
+ totalOutput += aTotal;
}
}
- return false;
+
+ if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) {
+ explodeMultiblock();
+ return false;
+ }
+
+ long leftToInject;
+ //Long EUt calculation
+ long aVoltage;
+ //Isnt too low EUt check?
+ int aAmpsToInject;
+ int aRemainder;
+ int ampsOnCurrentHatch;
+ //xEUt *= 4;//this is effect of everclocking
+ for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) {
+ if (isValidMetaTileEntity(aDynamo)) {
+ leftToInject = aEU - injected;
+ aVoltage = aDynamo.maxEUOutput();
+ aAmpsToInject = (int) (leftToInject / aVoltage);
+ aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage));
+ ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject);
+ for (int i = 0; i < ampsOnCurrentHatch; i++) {
+ aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false);
+ }
+ injected+=aVoltage*ampsOnCurrentHatch;
+ if(aRemainder>0 && ampsOnCurrentHatch<aDynamo.maxAmperesOut()){
+ aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false);
+ injected+=aRemainder;
+ }
+ }
+ }
+ return injected > 0;
}
public long getMaxInputVoltage() {
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
index fd183d9e79..f33b8aa3d9 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
@@ -1,6 +1,5 @@
package gregtech.api.metatileentity.implementations;
-import appeng.api.parts.IPartHost;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyStorage;
import crazypants.enderio.machine.capbank.TileCapBank;
@@ -12,8 +11,6 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
-import ic2.api.energy.tile.IEnergySource;
-import ic2.api.reactor.IReactorChamber;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -143,27 +140,20 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- if (aBaseMetaTileEntity.isServerSide()) {
+ if (aBaseMetaTileEntity.isServerSide() && GregTech_API.mInputRF) {
aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork());
for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++)
if (aBaseMetaTileEntity.inputEnergyFrom(i)) {
TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
- if (tTileEntity instanceof IReactorChamber) {
- tTileEntity = (TileEntity) ((IReactorChamber) tTileEntity).getReactor();
- }
- if (tTileEntity instanceof IEnergySource && !(tTileEntity instanceof IPartHost) && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)))) {
- long tEU = Math.min(maxEUInput(), (long) ((IEnergySource) tTileEntity).getOfferedEnergy());
- ((IEnergySource) tTileEntity).drawEnergy(tEU);
- aBaseMetaTileEntity.injectEnergyUnits((byte) 6, tEU, 1);
- } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) {
+ if (tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) {
long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false);
tEU = tEU * GregTech_API.mRFtoEU / 100;
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1);
- } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) {
+ } else if (tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) {
long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false);
tEU = tEU * GregTech_API.mRFtoEU / 100;
aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1);
- } else if (GregTech_API.mInputRF && GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) {
+ } else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) {
int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored();
int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU);
long tEU = 0;
@@ -226,4 +216,9 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi
maxAmperesOut() +
trans("149","A");
}
+
+ @Override
+ public boolean shouldJoinIc2Enet() {
+ return true;
+ }
}