Try to fix the unexpected disconnection caused by those unloaded chunks
This commit is contained in:
parent
e18f0a186d
commit
ced4854069
3 changed files with 28 additions and 22 deletions
|
@ -37,7 +37,7 @@ import java.util.List;
|
|||
|
||||
import static gregtech.api.enums.GT_Values.VN;
|
||||
|
||||
public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable{
|
||||
public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable {
|
||||
public final float mThickNess;
|
||||
public final Materials mMaterial;
|
||||
public final long mCableLossPerMeter, mAmperage, mVoltage;
|
||||
|
@ -218,7 +218,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
|
|||
mTransferredVoltageLast20 = 0;
|
||||
mTransferredAmperageLast20 = 0;
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) <= 0) disconnect(i);
|
||||
if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) == 0) disconnect(i);
|
||||
}
|
||||
if (GT_Mod.gregtechproxy.gt6Cable) mCheckConnections = false;
|
||||
}
|
||||
|
@ -258,23 +258,25 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
|
|||
if (aSide >= 6) return rConnect;
|
||||
byte tSide = GT_Utility.getOppositeSide(aSide);
|
||||
TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aSide);
|
||||
if (getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).alwaysLookConnected(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()) || getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()) || getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) {
|
||||
if (tTileEntity instanceof IColoredTileEntity) {
|
||||
if (getBaseMetaTileEntity().getColorization() >= 0) {
|
||||
byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
|
||||
if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization())
|
||||
return rConnect;
|
||||
}
|
||||
}
|
||||
if ((tTileEntity instanceof IEnergyConnected && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide)))
|
||||
|| (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable
|
||||
&& (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).letsEnergyIn(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).letsEnergyOut(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity))))
|
||||
|| (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) getBaseMetaTileEntity(), ForgeDirection.getOrientation(tSide)))
|
||||
|| (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(tSide)))
|
||||
/*|| (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)getBaseMetaTileEntity(), ForgeDirection.getOrientation(tSide)))*/) {
|
||||
rConnect = 1;
|
||||
}
|
||||
}
|
||||
if (tTileEntity != null) {
|
||||
if (getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).alwaysLookConnected(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()) || getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()) || getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) {
|
||||
if (tTileEntity instanceof IColoredTileEntity) {
|
||||
if (getBaseMetaTileEntity().getColorization() >= 0) {
|
||||
byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
|
||||
if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization())
|
||||
return rConnect;
|
||||
}
|
||||
}
|
||||
if ((tTileEntity instanceof IEnergyConnected && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide)))
|
||||
|| (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable
|
||||
&& (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).letsEnergyIn(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(tSide).letsEnergyOut(tSide, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(tSide), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(tSide), ((IGregTechTileEntity) tTileEntity))))
|
||||
|| (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) getBaseMetaTileEntity(), ForgeDirection.getOrientation(tSide)))
|
||||
|| (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(tSide)))
|
||||
/*|| (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)getBaseMetaTileEntity(), ForgeDirection.getOrientation(tSide)))*/) {
|
||||
rConnect = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rConnect > 0) {
|
||||
super.connect(aSide);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ 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.BaseTileEntity;
|
||||
import gregtech.api.metatileentity.MetaPipeEntity;
|
||||
import gregtech.api.objects.GT_RenderedTexture;
|
||||
import gregtech.api.objects.XSTR;
|
||||
|
@ -34,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import static gregtech.api.enums.GT_Values.D1;
|
||||
|
||||
public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity{
|
||||
public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
|
||||
public final float mThickNess;
|
||||
public final Materials mMaterial;
|
||||
public final int mCapacity, mHeatResistance, mPipeAmount;
|
||||
|
@ -388,6 +389,9 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity{
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (getBaseMetaTileEntity().getOffsetX(aSide, 1) >> 4 != getBaseMetaTileEntity().getXCoord() >> 4
|
||||
|| getBaseMetaTileEntity().getOffsetZ(aSide, 1) >> 4 != getBaseMetaTileEntity().getZCoord() >> 4) { // if chunk unloaded
|
||||
rConnect = -1;
|
||||
}
|
||||
if (rConnect > 0) {
|
||||
if (GT_Mod.gregtechproxy.gt6Pipe && tFluidPipe != null) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe{
|
||||
public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe {
|
||||
public final float mThickNess;
|
||||
public final Materials mMaterial;
|
||||
public final int mStepSize;
|
||||
|
@ -165,7 +165,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
|
|||
if (aTick % mTickTime == 0) mTransferredItems = 0;
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) <= 0) disconnect(i);
|
||||
if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) == 0) disconnect(i);
|
||||
}
|
||||
if (GT_Mod.gregtechproxy.gt6Pipe) mCheckConnections = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue