use of gregtech.api.interfaces.tileentity.ICoverable in project NewHorizonsCoreMod by GTNewHorizons.
the class GT_CustomMetaPipeEntity_Item method onPostTick.
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide() && aTick % 10 == 0) {
mConnections = 0;
if (aTick % mCustomTickTime == 0)
mTransferredItems = 0;
for (byte i = 0; i < 6; i++) {
TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
if (tTileEntity != null) {
boolean temp = GT_Utility.isConnectableNonInventoryPipe(tTileEntity, GT_Utility.getOppositeSide(i));
if (tTileEntity instanceof IGregTechTileEntity) {
temp = true;
if (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() == null)
continue;
if (aBaseMetaTileEntity.getColorization() >= 0) {
byte tColor = ((IGregTechTileEntity) tTileEntity).getColorization();
if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
continue;
}
}
if (((IGregTechTileEntity) tTileEntity).getMetaTileEntity().connectsToItemPipe(GT_Utility.getOppositeSide(i))) {
mConnections |= (1 << i);
continue;
}
}
if (tTileEntity instanceof IInventory) {
temp = true;
if (((IInventory) tTileEntity).getSizeInventory() <= 0) {
continue;
}
}
if (tTileEntity instanceof ISidedInventory) {
temp = true;
int[] tSlots = ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(GT_Utility.getOppositeSide(i));
if (tSlots == null || tSlots.length <= 0) {
continue;
}
}
if (temp) {
if (tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).alwaysLookConnected(GT_Utility.getOppositeSide(i), ((ICoverable) tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((ICoverable) tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((ICoverable) tTileEntity))) {
mConnections |= (1 << i);
continue;
}
if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) {
mConnections |= (1 << i);
continue;
}
if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -1, aBaseMetaTileEntity)) {
mConnections |= (1 << i);
continue;
}
if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -1, aBaseMetaTileEntity)) {
mConnections |= (1 << i);
continue;
}
}
}
}
if (oLastReceivedFrom == mLastReceivedFrom) {
doTickProfilingInThisTick = false;
ArrayList<IMetaTileEntityItemPipe> tPipeList = new ArrayList<IMetaTileEntityItemPipe>();
for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) {
temp = false;
tPipeList.clear();
for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<IMetaTileEntityItemPipe, Long>(), 0, false, false)).keySet()) {
if (temp)
break;
tPipeList.add(tTileEntity);
while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) for (IMetaTileEntityItemPipe tPipe : tPipeList) if (!tPipe.incrementTransferCounter(1))
temp = true;
}
}
}
if (isInventoryEmpty())
mLastReceivedFrom = 6;
oLastReceivedFrom = mLastReceivedFrom;
} else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4)
aBaseMetaTileEntity.issueTextureUpdate();
}
Aggregations