Search in sources :

Example 1 with CoverData

use of gregapi.cover.CoverData in project gregtech6 by GregTech6.

the class MultiTileEntityItemInternal method getOreDictItemData.

@Override
public OreDictItemData getOreDictItemData(ItemStack aStack) {
    List<OreDictItemData> rList = new ArrayListNoNulls<>(F, OM.data(aStack));
    MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry.getNewTileEntityContainer(aStack);
    // Yes I keep Covers a special case, less chances for fuck ups.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityCoverable) {
        CoverData tCoverData = ((ITileEntityCoverable) tTileEntityContainer.mTileEntity).getCoverData();
        if (tCoverData != null)
            for (byte tSide : ALL_SIDES_VALID) rList.add(OM.anydata(tCoverData.getCoverItem(tSide)));
    }
    // Same for foamed Blocks.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityFoamable && ((ITileEntityFoamable) tTileEntityContainer.mTileEntity).hasFoam(SIDE_ANY)) {
        rList.add(new OreDictItemData(MT.ConstructionFoam, U));
        if (((ITileEntityFoamable) tTileEntityContainer.mTileEntity).ownedFoam(SIDE_ANY))
            rList.add(new OreDictItemData(MT.Pd, U4));
    }
    // General case for Custom additional OreDictItemData.
    if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IMTE_GetOreDictItemData) {
        rList = ((IMTE_GetOreDictItemData) tTileEntityContainer.mTileEntity).getOreDictItemData(rList);
    }
    return rList.isEmpty() ? null : rList.size() > 1 ? new OreDictItemData(rList) : rList.get(0);
}
Also used : ITileEntityCoverable(gregapi.cover.ITileEntityCoverable) OreDictItemData(gregapi.oredict.OreDictItemData) CoverData(gregapi.cover.CoverData) ITileEntityFoamable(gregapi.tileentity.ITileEntityFoamable) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) IItemNoGTOverride(gregapi.item.IItemNoGTOverride)

Example 2 with CoverData

use of gregapi.cover.CoverData in project gregtech6 by GregTech6.

the class CompatIC2 method onRetextureEvent.

@SubscribeEvent
public void onRetextureEvent(RetextureEvent aEvent) {
    TileEntity tTileEntity = WD.te(aEvent.world, aEvent.x, aEvent.y, aEvent.z, T);
    if (tTileEntity instanceof ITileEntityCoverable) {
        CoverData tData = ((ITileEntityCoverable) tTileEntity).getCoverData();
        if (tData != null && tData.mBehaviours[aEvent.side] instanceof CoverTextureCanvas) {
            if (tData.mNBTs[aEvent.side] == null)
                tData.mNBTs[aEvent.side] = UT.NBT.make();
            tData.mNBTs[aEvent.side].setInteger(NBT_CANVAS_BLOCK, Block.getIdFromBlock(aEvent.referencedBlock));
            tData.mNBTs[aEvent.side].setInteger(NBT_CANVAS_META, aEvent.referencedMeta);
            tData.mBehaviours[aEvent.side].onCoverPlaced((byte) aEvent.side, tData, null, tData.getCoverItem((byte) aEvent.side));
            aEvent.applied = T;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITileEntityCoverable(gregapi.cover.ITileEntityCoverable) CoverData(gregapi.cover.CoverData) CoverTextureCanvas(gregapi.cover.covers.CoverTextureCanvas) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with CoverData

use of gregapi.cover.CoverData in project gregtech6 by GregTech6.

the class MultiTileEntityLogisticsCore method onServerTickPre.

@Override
@SuppressWarnings("unchecked")
public void onServerTickPre(boolean aFirst) {
    // Sync up with other Stuff that happens to check for visual Updates every 20 Ticks to reduce Lag.
    if (SYNC_SECOND) {
        int tCPU_Logic = oCPU_Logic, tCPU_Control = oCPU_Control, tCPU_Storage = oCPU_Storage, tCPU_Conversion = oCPU_Conversion;
        oCPU_Logic = 0;
        oCPU_Control = 0;
        oCPU_Storage = 0;
        oCPU_Conversion = 0;
        if (checkStructure(F) && mEnergy >= 128L + mCPU_Logic * 64L * mCPU_Conversion) {
            int tX = getOffsetXN(mFacing, 2), tY = getOffsetYN(mFacing, 2), tZ = getOffsetZN(mFacing, 2);
            ItemStackSet<ItemStackContainer> tFilteredFor = new ItemStackSet<>();
            final List<LogisticsData> tStackImportsGeneric = new ArrayListNoNulls<>(), tStackImportsSemi = new ArrayListNoNulls<>(), tStackImportsFiltered = new ArrayListNoNulls<>(), tStackExportsGeneric = new ArrayListNoNulls<>(), tStackExportsSemi = new ArrayListNoNulls<>(), tStackExportsFiltered = new ArrayListNoNulls<>(), tStackStorageGeneric = new ArrayListNoNulls<>(), tStackStorageSemi = new ArrayListNoNulls<>(), tStackStorageFiltered = new ArrayListNoNulls<>(), tStackDumps = new ArrayListNoNulls<>(), tFluidImportsGeneric = new ArrayListNoNulls<>(), tFluidImportsSemi = new ArrayListNoNulls<>(), tFluidImportsFiltered = new ArrayListNoNulls<>(), tFluidExportsGeneric = new ArrayListNoNulls<>(), tFluidExportsSemi = new ArrayListNoNulls<>(), tFluidExportsFiltered = new ArrayListNoNulls<>(), tFluidStorageGeneric = new ArrayListNoNulls<>(), tFluidStorageSemi = new ArrayListNoNulls<>(), tFluidStorageFiltered = new ArrayListNoNulls<>(), tExports1[][] = new List[][] { { tFluidExportsFiltered, tStackExportsFiltered }, { tFluidExportsSemi, tStackExportsSemi }, { tFluidExportsGeneric, tStackExportsGeneric }, { tFluidStorageFiltered, tStackStorageFiltered }, { tFluidStorageSemi, tStackStorageSemi }, { tFluidStorageGeneric, tStackStorageGeneric } }, tExports2[][] = new List[][] { { tFluidExportsFiltered, tStackExportsFiltered }, { tFluidExportsSemi, tStackExportsSemi }, { tFluidExportsGeneric, tStackExportsGeneric } }, tImports1[][] = new List[][] { { tFluidImportsGeneric, tStackImportsGeneric }, { tFluidImportsSemi, tStackImportsSemi }, { tFluidImportsFiltered, tStackImportsFiltered } }, tImports2[][] = new List[][] { { tFluidStorageGeneric, tStackStorageGeneric }, { tFluidStorageSemi, tStackStorageSemi }, { tFluidStorageFiltered, tStackStorageFiltered } };
            Set<ITileEntityLogistics> tScanning = new HashSetNoNulls<>(), tScanningNext = new HashSetNoNulls<>();
            Set<TileEntity> tScanned = new HashSetNoNulls<>();
            for (int i = -2; i <= 2; i++) for (int j = -2; j <= 2; j++) for (int k = -2; k <= 2; k++) {
                TileEntity tTileEntity = WD.te(worldObj, tX + i, tY + j, tZ + k, T);
                if (tScanned.add(tTileEntity) && tTileEntity instanceof ITileEntityLogistics)
                    tScanning.add((ITileEntityLogistics) tTileEntity);
            }
            while (!tScanning.isEmpty()) {
                for (ITileEntityLogistics tLogistics : tScanning) {
                    if (tLogistics instanceof ITileEntityLogisticsStorage) {
                        tFilteredFor.add(((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem());
                        if (tLogistics instanceof ITileEntityLogisticsSemiFilteredItem) {
                            tFilteredFor.addAll(((ITileEntityLogisticsSemiFilteredItem) tLogistics).getLogisticsFilter(SIDE_ANY));
                        }
                        switch(((ITileEntityLogisticsStorage) tLogistics).getLogisticsPriorityFluid()) {
                            case 1:
                                tFluidStorageGeneric.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
                                break;
                            case 2:
                                tFluidStorageSemi.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
                                break;
                            case 3:
                                tFluidStorageFiltered.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
                                break;
                        }
                        switch(((ITileEntityLogisticsStorage) tLogistics).getLogisticsPriorityItem()) {
                            case 1:
                                tStackStorageGeneric.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
                                break;
                            case 2:
                                tStackStorageSemi.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
                                break;
                            case 3:
                                tStackStorageFiltered.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
                                break;
                        }
                    }
                    CoverData tCovers = tLogistics.getCoverData();
                    if (tCovers != null && !tCovers.mStopped) {
                        for (byte tSide : ALL_SIDES_VALID) if (tCovers.mBehaviours[tSide] instanceof AbstractCoverAttachmentLogistics) {
                            if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPULogic.INSTANCE) {
                                tCovers.value(tSide, (short) (tCPU_Logic <= 0 ? 0 : tCPU_Logic >= mCPU_Logic ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Logic - tCPU_Logic) * 14L) / mCPU_Logic))), T);
                                tCovers.visual(tSide, (short) (tCPU_Logic <= 0 ? 0 : tCPU_Logic >= mCPU_Logic ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Logic - tCPU_Logic) * 9L) / mCPU_Logic))));
                                continue;
                            }
                            if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUControl.INSTANCE) {
                                tCovers.value(tSide, (short) (tCPU_Control <= 0 ? 0 : tCPU_Control >= mCPU_Control ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Control - tCPU_Control) * 14L) / mCPU_Control))), T);
                                tCovers.visual(tSide, (short) (tCPU_Control <= 0 ? 0 : tCPU_Control >= mCPU_Control ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Control - tCPU_Control) * 9L) / mCPU_Control))));
                                continue;
                            }
                            if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUStorage.INSTANCE) {
                                tCovers.value(tSide, (short) (tCPU_Storage <= 0 ? 0 : tCPU_Storage >= mCPU_Storage ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Storage - tCPU_Storage) * 14L) / mCPU_Storage))), T);
                                tCovers.visual(tSide, (short) (tCPU_Storage <= 0 ? 0 : tCPU_Storage >= mCPU_Storage ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Storage - tCPU_Storage) * 9L) / mCPU_Storage))));
                                continue;
                            }
                            if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUConversion.INSTANCE) {
                                tCovers.value(tSide, (short) (tCPU_Conversion <= 0 ? 0 : tCPU_Conversion >= mCPU_Conversion ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Conversion - tCPU_Conversion) * 14L) / mCPU_Conversion))), T);
                                tCovers.visual(tSide, (short) (tCPU_Conversion <= 0 ? 0 : tCPU_Conversion >= mCPU_Conversion ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Conversion - tCPU_Conversion) * 9L) / mCPU_Conversion))));
                                continue;
                            }
                            DelegatorTileEntity<TileEntity> tAdjacent = tLogistics.getAdjacentTileEntity(tSide);
                            if (tAdjacent.mTileEntity instanceof ITileEntityLogistics && ((ITileEntityLogistics) tAdjacent.mTileEntity).canLogistics(SIDE_ANY)) {
                            // Ignore those ones to reduce likelihood of infinite Loops.
                            } else {
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidExport.INSTANCE) {
                                    FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
                                    if (tFluid != null && tFluid.getFluid() != null) {
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tFluidExportsGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            case 2:
                                                tFluidExportsSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            default:
                                                tFluidExportsFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidImport.INSTANCE) {
                                    FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
                                    if (tFluid != null && tFluid.getFluid() != null) {
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tFluidImportsGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            case 2:
                                                tFluidImportsSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            default:
                                                tFluidImportsFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidStorage.INSTANCE) {
                                    FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
                                    if (tFluid != null && tFluid.getFluid() != null) {
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tFluidStorageGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            case 2:
                                                tFluidStorageSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                            default:
                                                tFluidStorageFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsItemExport.INSTANCE) {
                                    ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
                                    if (ST.valid(tStack)) {
                                        tFilteredFor.add(tStack);
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tStackExportsGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            case 2:
                                                tStackExportsSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            default:
                                                tStackExportsFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsItemImport.INSTANCE) {
                                    ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
                                    if (ST.valid(tStack)) {
                                        tFilteredFor.add(tStack);
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tStackImportsGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            case 2:
                                                tStackImportsSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            default:
                                                tStackImportsFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsItemStorage.INSTANCE) {
                                    ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
                                    if (ST.valid(tStack)) {
                                        tFilteredFor.add(tStack);
                                        switch(tCovers.mValues[tSide] & 3) {
                                            case 1:
                                                tStackStorageGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            case 2:
                                                tStackStorageSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                            default:
                                                tStackStorageFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
                                                break;
                                        }
                                    }
                                    continue;
                                }
                                LogisticsData tTarget = new LogisticsData(tAdjacent, (tCovers.mValues[tSide] >> 2) & 127);
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericDump.INSTANCE) {
                                    tStackDumps.add(tTarget);
                                    continue;
                                }
                                int tDefault = (tCovers.mValues[tSide] & 3);
                                boolean aAllowFluids = T;
                                if (tAdjacent.mTileEntity instanceof ITileEntityLogisticsSemiFilteredItem) {
                                    aAllowFluids = F;
                                    ItemStackSet<ItemStackContainer> tFilter = ((ITileEntityLogisticsSemiFilteredItem) tAdjacent.mTileEntity).getLogisticsFilter(tAdjacent.mSideOfTileEntity);
                                    if (tFilter != null) {
                                        tFilteredFor.addAll(tFilter);
                                        if (tDefault == 0)
                                            tDefault = 2;
                                    }
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericExport.INSTANCE) {
                                    switch(tDefault) {
                                        default:
                                            if (aAllowFluids)
                                                tFluidExportsGeneric.add(tTarget);
                                            tStackExportsGeneric.add(tTarget);
                                            break;
                                        case 2:
                                            if (aAllowFluids)
                                                tFluidExportsSemi.add(tTarget);
                                            tStackExportsSemi.add(tTarget);
                                            break;
                                        case 3:
                                            if (aAllowFluids)
                                                tFluidExportsFiltered.add(tTarget);
                                            tStackExportsFiltered.add(tTarget);
                                            break;
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericImport.INSTANCE) {
                                    switch(tDefault) {
                                        default:
                                            if (aAllowFluids)
                                                tFluidImportsGeneric.add(tTarget);
                                            tStackImportsGeneric.add(tTarget);
                                            break;
                                        case 2:
                                            if (aAllowFluids)
                                                tFluidImportsSemi.add(tTarget);
                                            tStackImportsSemi.add(tTarget);
                                            break;
                                        case 3:
                                            if (aAllowFluids)
                                                tFluidImportsFiltered.add(tTarget);
                                            tStackImportsFiltered.add(tTarget);
                                            break;
                                    }
                                    continue;
                                }
                                if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericStorage.INSTANCE) {
                                    switch(tDefault) {
                                        default:
                                            if (aAllowFluids)
                                                tFluidStorageGeneric.add(tTarget);
                                            tStackStorageGeneric.add(tTarget);
                                            break;
                                        case 2:
                                            if (aAllowFluids)
                                                tFluidStorageSemi.add(tTarget);
                                            tStackStorageSemi.add(tTarget);
                                            break;
                                        case 3:
                                            if (aAllowFluids)
                                                tFluidStorageFiltered.add(tTarget);
                                            tStackStorageFiltered.add(tTarget);
                                            break;
                                    }
                                    continue;
                                }
                            }
                        }
                    }
                    if (tLogistics.getWorld() == worldObj)
                        for (byte tSide : ALL_SIDES_VALID) if (tLogistics.canLogistics(tSide)) {
                            int tMaxDistance = Math.max(Math.abs(tLogistics.getOffsetX(tSide) - tX), Math.max(Math.abs(tLogistics.getOffsetY(tSide) - tY), Math.abs(tLogistics.getOffsetZ(tSide) - tZ)));
                            if (tMaxDistance <= mCPU_Control + 2) {
                                oCPU_Control = Math.max(oCPU_Control, tMaxDistance - 2);
                                DelegatorTileEntity<TileEntity> tAdjacent = tLogistics.getAdjacentTileEntity(tSide);
                                if (tAdjacent.mTileEntity instanceof ITileEntityLogistics && ((ITileEntityLogistics) tAdjacent.mTileEntity).canLogistics(tAdjacent.mSideOfTileEntity) && tScanned.add(tAdjacent.mTileEntity))
                                    tScanningNext.add((ITileEntityLogistics) tAdjacent.mTileEntity);
                            }
                        }
                }
                tScanning.clear();
                tScanning.addAll(tScanningNext);
                tScanningNext.clear();
            }
            while (++oCPU_Logic <= mCPU_Logic) {
                boolean tBreak = F;
                // Import Export Business
                for (List<LogisticsData>[] tExports : tExports1) {
                    for (List<LogisticsData>[] tImports : tImports1) {
                        if (moveFluids(tImports[0], tExports[0])) {
                            tBreak = T;
                            break;
                        }
                        if (moveStacks(tImports[1], tExports[1])) {
                            tBreak = T;
                            break;
                        }
                    }
                    if (tBreak)
                        break;
                }
                if (tBreak)
                    continue;
                for (List<LogisticsData>[] tExports : tExports2) {
                    for (List<LogisticsData>[] tImports : tImports2) {
                        if (moveFluids(tImports[0], tExports[0])) {
                            tBreak = T;
                            break;
                        }
                        if (moveStacks(tImports[1], tExports[1])) {
                            tBreak = T;
                            break;
                        }
                    }
                    if (tBreak)
                        break;
                }
                if (tBreak)
                    continue;
                // Defragmentation
                if (moveFluids(tFluidStorageGeneric, tFluidStorageFiltered))
                    continue;
                if (moveStacks(tStackStorageGeneric, tStackStorageFiltered))
                    continue;
                if (moveFluids(tFluidStorageGeneric, tFluidStorageSemi))
                    continue;
                if (moveStacks(tStackStorageGeneric, tStackStorageSemi))
                    continue;
                // Dump
                for (LogisticsData tImport : tStackStorageGeneric) {
                    for (LogisticsData tExport : tStackDumps) {
                        for (int j = 0; j < mCPU_Conversion; j++) {
                            long tMoved = ST.move(tImport.mTarget, tExport.mTarget, tFilteredFor, F, F, T, F, 64, 1, 64, 1);
                            if (tMoved > 0) {
                                oCPU_Conversion = Math.max(oCPU_Conversion, j + 1);
                                mEnergy -= tMoved;
                                tBreak = T;
                                continue;
                            }
                            break;
                        }
                        if (tBreak)
                            break;
                    }
                    if (tBreak)
                        break;
                }
                if (tBreak)
                    continue;
                // Core didn't actually get used.
                oCPU_Logic--;
                break;
            }
        }
    }
    mEnergy -= 20 + mCPU_Logic + mCPU_Control + mCPU_Storage + mCPU_Conversion;
    if (mEnergy < 0)
        mEnergy = 0;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) CoverData(gregapi.cover.CoverData) DelegatorTileEntity(gregapi.tileentity.delegate.DelegatorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ItemStackContainer(gregapi.code.ItemStackContainer) ITileEntityLogisticsSemiFilteredItem(gregapi.tileentity.logistics.ITileEntityLogisticsSemiFilteredItem) List(java.util.List) DelegatorTileEntity(gregapi.tileentity.delegate.DelegatorTileEntity) ItemStackSet(gregapi.code.ItemStackSet) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) HashSetNoNulls(gregapi.code.HashSetNoNulls) ITileEntityLogistics(gregapi.tileentity.logistics.ITileEntityLogistics) ITileEntityLogisticsStorage(gregapi.tileentity.logistics.ITileEntityLogisticsStorage) ItemStack(net.minecraft.item.ItemStack)

Example 4 with CoverData

use of gregapi.cover.CoverData in project gregtech6 by GregTech6.

the class MultiTileEntityItemInternal method addInformation.

@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, @SuppressWarnings("rawtypes") List aList, boolean aF3_H) {
    MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry.getNewTileEntityContainer(aStack);
    if (tTileEntityContainer == null) {
        aList.add("INVALID ITEM! THIS IS A BUG IF ACQUIRED IN A LEGIT WAY!");
        return;
    }
    if (tTileEntityContainer.mTileEntity instanceof IMTE_AddToolTips)
        try {
            ((IMTE_AddToolTips) tTileEntityContainer.mTileEntity).addToolTips(aList, aStack, aF3_H);
        } catch (Throwable e) {
            e.printStackTrace(ERR);
        }
    if (tTileEntityContainer.mTileEntity instanceof IMTE_GetFlammability ? ((IMTE_GetFlammability) tTileEntityContainer.mTileEntity).getFlammability(SIDE_ANY, tTileEntityContainer.mBlock.getMaterial().getCanBurn()) > 0 : tTileEntityContainer.mBlock.getMaterial().getCanBurn())
        aList.add(LH.Chat.RED + LH.get(LH.TOOLTIP_FLAMMABLE));
    if (tTileEntityContainer.mTileEntity instanceof IMTE_GetEnchantPowerBonus)
        aList.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_ENCHANT_BONUS));
    if (tTileEntityContainer.mTileEntity instanceof ITileEntityCoverable) {
        CoverData tCoverData = ((ITileEntityCoverable) tTileEntityContainer.mTileEntity).getCoverData();
        if (tCoverData != null)
            for (byte tSide : ALL_SIDES_VALID) if (tCoverData.mBehaviours[tSide] != null) {
                aList.add(LH.Chat.DGRAY + LH.get(LH.TOOL_TO_UNCOVER_CROWBAR));
                break;
            }
    }
    if (tTileEntityContainer.mTileEntity instanceof IMTE_GetExplosionResistance) {
        float tResistance = ((IMTE_GetExplosionResistance) tTileEntityContainer.mTileEntity).getExplosionResistance();
        if (tResistance >= 4)
            aList.add(LH.getToolTipBlastResistance(mBlock, tResistance));
    }
    aList.add(LH.getToolTipHarvest(tTileEntityContainer.mBlock.getMaterial(), tTileEntityContainer.mBlock.getHarvestTool(tTileEntityContainer.mBlockMetaData), tTileEntityContainer.mBlock.getHarvestLevel(tTileEntityContainer.mBlockMetaData)));
    while (aList.remove(null)) ;
// Remove all Nulls and fix eventual Formatting mistakes. No longer needed because the Tooltip Event fixes it
// for (int i = 0, j = aList.size(); i < j; i++) if (aList.get(i) == null) {aList.remove(i--); j--;} else aList.set(i, LH.Chat.GRAY + aList.get(i) + LH.Chat.RESET_TOOLTIP);
}
Also used : ITileEntityCoverable(gregapi.cover.ITileEntityCoverable) CoverData(gregapi.cover.CoverData) IItemNoGTOverride(gregapi.item.IItemNoGTOverride)

Aggregations

CoverData (gregapi.cover.CoverData)4 ITileEntityCoverable (gregapi.cover.ITileEntityCoverable)3 ArrayListNoNulls (gregapi.code.ArrayListNoNulls)2 IItemNoGTOverride (gregapi.item.IItemNoGTOverride)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 HashSetNoNulls (gregapi.code.HashSetNoNulls)1 ItemStackContainer (gregapi.code.ItemStackContainer)1 ItemStackSet (gregapi.code.ItemStackSet)1 CoverTextureCanvas (gregapi.cover.covers.CoverTextureCanvas)1 OreDictItemData (gregapi.oredict.OreDictItemData)1 ITileEntityFoamable (gregapi.tileentity.ITileEntityFoamable)1 DelegatorTileEntity (gregapi.tileentity.delegate.DelegatorTileEntity)1 ITileEntityLogistics (gregapi.tileentity.logistics.ITileEntityLogistics)1 ITileEntityLogisticsSemiFilteredItem (gregapi.tileentity.logistics.ITileEntityLogisticsSemiFilteredItem)1 ITileEntityLogisticsStorage (gregapi.tileentity.logistics.ITileEntityLogisticsStorage)1 List (java.util.List)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1