Search in sources :

Example 1 with TileEntityUpdateable

use of mekanism.common.tile.base.TileEntityUpdateable in project Mekanism by mekanism.

the class LookingAtUtils method addInfo.

public static void addInfo(LookingAtHelper info, @Nonnull TileEntity tile, boolean displayTanks, boolean displayFluidTanks) {
    MultiblockData structure = getMultiblock(tile);
    Optional<IStrictEnergyHandler> energyCapability = CapabilityUtils.getCapability(tile, Capabilities.STRICT_ENERGY_CAPABILITY, null).resolve();
    if (energyCapability.isPresent()) {
        displayEnergy(info, energyCapability.get());
    } else if (structure != null && structure.isFormed()) {
        // Special handling to allow viewing the energy of multiblock's when looking at things other than the ports
        displayEnergy(info, structure);
    }
    if (displayTanks) {
        // Fluid - only add it to our own tiles in which we disable the default display for
        if (displayFluidTanks && tile instanceof TileEntityUpdateable) {
            Optional<IFluidHandler> fluidCapability = CapabilityUtils.getCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).resolve();
            if (fluidCapability.isPresent()) {
                displayFluid(info, fluidCapability.get());
            } else if (structure != null && structure.isFormed()) {
                // Special handling to allow viewing the fluid in a multiblock when looking at things other than the ports
                displayFluid(info, structure);
            }
        }
        // Chemicals
        addInfo(tile, structure, Capabilities.GAS_HANDLER_CAPABILITY, multiblock -> multiblock.getGasTanks(null), info, MekanismLang.GAS, Current.GAS, CurrentType.GAS);
        addInfo(tile, structure, Capabilities.INFUSION_HANDLER_CAPABILITY, multiblock -> multiblock.getInfusionTanks(null), info, MekanismLang.INFUSE_TYPE, Current.INFUSION, CurrentType.INFUSION);
        addInfo(tile, structure, Capabilities.PIGMENT_HANDLER_CAPABILITY, multiblock -> multiblock.getPigmentTanks(null), info, MekanismLang.PIGMENT, Current.PIGMENT, CurrentType.PIGMENT);
        addInfo(tile, structure, Capabilities.SLURRY_HANDLER_CAPABILITY, multiblock -> multiblock.getSlurryTanks(null), info, MekanismLang.SLURRY, Current.SLURRY, CurrentType.SLURRY);
    }
}
Also used : IStrictEnergyHandler(mekanism.api.energy.IStrictEnergyHandler) TileEntityUpdateable(mekanism.common.tile.base.TileEntityUpdateable) MultiblockData(mekanism.common.lib.multiblock.MultiblockData) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

IStrictEnergyHandler (mekanism.api.energy.IStrictEnergyHandler)1 MultiblockData (mekanism.common.lib.multiblock.MultiblockData)1 TileEntityUpdateable (mekanism.common.tile.base.TileEntityUpdateable)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1