Search in sources :

Example 1 with BasicHeatCapacitor

use of mekanism.common.capabilities.heat.BasicHeatCapacitor in project Mekanism by mekanism.

the class TileEntityMekanism method addContainerTrackers.

@Override
public void addContainerTrackers(MekanismContainer container) {
    // setup dynamic container syncing
    SyncMapper.INSTANCE.setup(container, getClass(), () -> this);
    for (ITileComponent component : components) {
        component.trackForMainContainer(container);
    }
    if (supportsRedstone()) {
        container.track(SyncableEnum.create(RedstoneControl::byIndexStatic, RedstoneControl.DISABLED, () -> controlType, value -> controlType = value));
    }
    boolean isClient = isRemote();
    if (canHandleGas() && handles(SubstanceType.GAS)) {
        List<IGasTank> gasTanks = getGasTanks(null);
        for (IGasTank gasTank : gasTanks) {
            container.track(SyncableGasStack.create(gasTank, isClient));
        }
    }
    if (canHandleInfusion() && handles(SubstanceType.INFUSION)) {
        List<IInfusionTank> infusionTanks = getInfusionTanks(null);
        for (IInfusionTank infusionTank : infusionTanks) {
            container.track(SyncableInfusionStack.create(infusionTank, isClient));
        }
    }
    if (canHandlePigment() && handles(SubstanceType.PIGMENT)) {
        List<IPigmentTank> pigmentTanks = getPigmentTanks(null);
        for (IPigmentTank pigmentTank : pigmentTanks) {
            container.track(SyncablePigmentStack.create(pigmentTank, isClient));
        }
    }
    if (canHandleSlurry() && handles(SubstanceType.SLURRY)) {
        List<ISlurryTank> slurryTanks = getSlurryTanks(null);
        for (ISlurryTank slurryTank : slurryTanks) {
            container.track(SyncableSlurryStack.create(slurryTank, isClient));
        }
    }
    if (canHandleFluid() && handles(SubstanceType.FLUID)) {
        List<IExtendedFluidTank> fluidTanks = getFluidTanks(null);
        for (IExtendedFluidTank fluidTank : fluidTanks) {
            container.track(SyncableFluidStack.create(fluidTank, isClient));
        }
    }
    if (canHandleHeat() && handles(SubstanceType.HEAT)) {
        List<IHeatCapacitor> heatCapacitors = getHeatCapacitors(null);
        for (IHeatCapacitor capacitor : heatCapacitors) {
            container.track(SyncableDouble.create(capacitor::getHeat, capacitor::setHeat));
            if (capacitor instanceof BasicHeatCapacitor) {
                container.track(SyncableDouble.create(capacitor::getHeatCapacity, capacity -> ((BasicHeatCapacitor) capacitor).setHeatCapacity(capacity, false)));
            }
        }
    }
    if (canHandleEnergy() && handles(SubstanceType.ENERGY)) {
        container.track(SyncableFloatingLong.create(this::getInputRate, this::setInputRate));
        List<IEnergyContainer> energyContainers = getEnergyContainers(null);
        for (IEnergyContainer energyContainer : energyContainers) {
            container.track(SyncableFloatingLong.create(energyContainer::getEnergy, energyContainer::setEnergy));
            if (energyContainer instanceof MachineEnergyContainer) {
                MachineEnergyContainer<?> machineEnergy = (MachineEnergyContainer<?>) energyContainer;
                if (supportsUpgrades() || machineEnergy.adjustableRates()) {
                    container.track(SyncableFloatingLong.create(machineEnergy::getMaxEnergy, machineEnergy::setMaxEnergy));
                    container.track(SyncableFloatingLong.create(machineEnergy::getEnergyPerTick, machineEnergy::setEnergyPerTick));
                }
            }
        }
    }
}
Also used : IHeatHandler(mekanism.api.heat.IHeatHandler) IGasTile(mekanism.common.tile.interfaces.chemical.IGasTile) SecurityMode(mekanism.common.lib.security.SecurityMode) IHeatCapacitorHolder(mekanism.common.capabilities.holder.heat.IHeatCapacitorHolder) ComputerMethodMapper(mekanism.common.integration.computer.ComputerMethodMapper) ITileHeatHandler(mekanism.common.capabilities.heat.ITileHeatHandler) IEnergyContainerHolder(mekanism.common.capabilities.holder.energy.IEnergyContainerHolder) GasHandlerManager(mekanism.common.capabilities.resolver.manager.ChemicalHandlerManager.GasHandlerManager) TileComponentConfig(mekanism.common.tile.component.TileComponentConfig) CompoundNBT(net.minecraft.nbt.CompoundNBT) ITierUpgradable(mekanism.common.tile.interfaces.ITierUpgradable) Direction(net.minecraft.util.Direction) SlurryHandlerManager(mekanism.common.capabilities.resolver.manager.ChemicalHandlerManager.SlurryHandlerManager) ITileRadioactive(mekanism.common.tile.interfaces.ITileRadioactive) IComputerTile(mekanism.common.integration.computer.IComputerTile) Block(net.minecraft.block.Block) Capabilities(mekanism.common.capabilities.Capabilities) Map(java.util.Map) InfusionHandlerManager(mekanism.common.capabilities.resolver.manager.ChemicalHandlerManager.InfusionHandlerManager) BoundComputerMethod(mekanism.common.integration.computer.BoundComputerMethod) SyncMapper(mekanism.common.inventory.container.sync.dynamic.SyncMapper) ISound(net.minecraft.client.audio.ISound) ISustainedInventory(mekanism.common.tile.interfaces.ISustainedInventory) ListNBT(net.minecraft.nbt.ListNBT) IChunkLoader(mekanism.common.lib.chunkloading.IChunkLoader) ITileRedstone(mekanism.common.tile.interfaces.ITileRedstone) Attribute(mekanism.common.block.attribute.Attribute) NBTUtils(mekanism.common.util.NBTUtils) EnergyHandlerManager(mekanism.common.capabilities.resolver.manager.EnergyHandlerManager) Set(java.util.Set) IBlockProvider(mekanism.api.providers.IBlockProvider) IMekanismFluidHandler(mekanism.api.fluid.IMekanismFluidHandler) ISecurityTile(mekanism.common.lib.security.ISecurityTile) ITrackableContainer(mekanism.common.inventory.container.ITrackableContainer) MekanismUtils(mekanism.common.util.MekanismUtils) FluidHandlerManager(mekanism.common.capabilities.resolver.manager.FluidHandlerManager) MethodRestriction(mekanism.common.integration.computer.ComputerMethodMapper.MethodRestriction) ComputerException(mekanism.common.integration.computer.ComputerException) ComputerCapabilityHelper(mekanism.common.integration.computer.ComputerCapabilityHelper) IGasTank(mekanism.api.chemical.gas.IGasTank) ITileSound(mekanism.common.tile.interfaces.ITileSound) SyncablePigmentStack(mekanism.common.inventory.container.sync.chemical.SyncablePigmentStack) TileComponentSecurity(mekanism.common.tile.component.TileComponentSecurity) ActionResultType(net.minecraft.util.ActionResultType) SyncableFloatingLong(mekanism.common.inventory.container.sync.SyncableFloatingLong) Util(net.minecraft.util.Util) IInfusionTile(mekanism.common.tile.interfaces.chemical.IInfusionTile) IHeatCapacitor(mekanism.api.heat.IHeatCapacitor) AttributeUpgradeable(mekanism.common.block.attribute.AttributeUpgradeable) IPigmentTank(mekanism.api.chemical.pigment.IPigmentTank) ISlurryTank(mekanism.api.chemical.slurry.ISlurryTank) AttributeComparator(mekanism.common.block.attribute.Attributes.AttributeComparator) ArrayList(java.util.ArrayList) ItemConfigurationCard(mekanism.common.item.ItemConfigurationCard) ItemStack(net.minecraft.item.ItemStack) ItemConfigurator(mekanism.common.item.ItemConfigurator) NetworkHooks(net.minecraftforge.fml.network.NetworkHooks) IMekanismStrictEnergyHandler(mekanism.api.energy.IMekanismStrictEnergyHandler) AttributeStateFacing(mekanism.common.block.attribute.AttributeStateFacing) IEnergyContainer(mekanism.api.energy.IEnergyContainer) ICapabilityHandlerManager(mekanism.common.capabilities.resolver.manager.ICapabilityHandlerManager) Nullable(javax.annotation.Nullable) EnumUtils(mekanism.common.util.EnumUtils) SyncableEnum(mekanism.common.inventory.container.sync.SyncableEnum) PigmentHandlerManager(mekanism.common.capabilities.resolver.manager.ChemicalHandlerManager.PigmentHandlerManager) IComparatorSupport(mekanism.common.tile.interfaces.IComparatorSupport) BlockPos(net.minecraft.util.math.BlockPos) SecurityUtils(mekanism.common.util.SecurityUtils) IUpgradeData(mekanism.common.upgrade.IUpgradeData) AttributeSecurity(mekanism.common.block.attribute.Attributes.AttributeSecurity) BasicHeatCapacitor(mekanism.common.capabilities.heat.BasicHeatCapacitor) IFrequencyHandler(mekanism.common.lib.frequency.IFrequencyHandler) TileEntity(net.minecraft.tileentity.TileEntity) TextComponentUtil(mekanism.api.text.TextComponentUtil) IInventorySlotHolder(mekanism.common.capabilities.holder.slot.IInventorySlotHolder) Action(mekanism.api.Action) SoundEvent(net.minecraft.util.SoundEvent) MekanismAPI(mekanism.api.MekanismAPI) IMekanismInventory(mekanism.api.inventory.IMekanismInventory) SyncableGasStack(mekanism.common.inventory.container.sync.chemical.SyncableGasStack) AutomationType(mekanism.api.inventory.AutomationType) ITileUpgradable(mekanism.common.tile.interfaces.ITileUpgradable) AttributeComputerIntegration(mekanism.common.block.attribute.Attributes.AttributeComputerIntegration) TileComponentUpgrade(mekanism.common.tile.component.TileComponentUpgrade) IInfusionTank(mekanism.api.chemical.infuse.IInfusionTank) AttributeStateActive(mekanism.common.block.attribute.AttributeStateActive) TileEntityType(net.minecraft.tileentity.TileEntityType) BlockState(net.minecraft.block.BlockState) AttributeRedstone(mekanism.common.block.attribute.Attributes.AttributeRedstone) AttributeGui(mekanism.common.block.attribute.AttributeGui) PlayerEntity(net.minecraft.entity.player.PlayerEntity) MachineEnergyContainer(mekanism.common.capabilities.energy.MachineEnergyContainer) SyncableInfusionStack(mekanism.common.inventory.container.sync.chemical.SyncableInfusionStack) SyncableSlurryStack(mekanism.common.inventory.container.sync.chemical.SyncableSlurryStack) DataHandlerUtils(mekanism.api.DataHandlerUtils) IExtendedFluidTank(mekanism.api.fluid.IExtendedFluidTank) ITileActive(mekanism.common.tile.interfaces.ITileActive) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) Objects(java.util.Objects) IConfigCardAccess(mekanism.api.IConfigCardAccess) List(java.util.List) AttributeSound(mekanism.common.block.attribute.AttributeSound) NBTConstants(mekanism.api.NBTConstants) ItemHandlerManager(mekanism.common.capabilities.resolver.manager.ItemHandlerManager) CachedAmbientTemperature(mekanism.common.capabilities.heat.CachedAmbientTemperature) ITickableTileEntity(net.minecraft.tileentity.ITickableTileEntity) MekanismContainer(mekanism.common.inventory.container.MekanismContainer) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) Upgrade(mekanism.api.Upgrade) IPigmentTile(mekanism.common.tile.interfaces.chemical.IPigmentTile) CapabilityUtils(mekanism.common.util.CapabilityUtils) IFluidTankHolder(mekanism.common.capabilities.holder.fluid.IFluidTankHolder) SyncableDouble(mekanism.common.inventory.container.sync.SyncableDouble) Function(java.util.function.Function) ITextComponent(net.minecraft.util.text.ITextComponent) Minecraft(net.minecraft.client.Minecraft) FloatingLong(mekanism.api.math.FloatingLong) ComputerMethod(mekanism.common.integration.computer.annotation.ComputerMethod) ISlurryTile(mekanism.common.tile.interfaces.chemical.ISlurryTile) IHasTileEntity(mekanism.common.block.interfaces.IHasTileEntity) Hand(net.minecraft.util.Hand) Nonnull(javax.annotation.Nonnull) IntSupplier(java.util.function.IntSupplier) AttributeUpgradeSupport(mekanism.common.block.attribute.AttributeUpgradeSupport) Mekanism(mekanism.common.Mekanism) SoundHandler(mekanism.client.sound.SoundHandler) ITileComponent(mekanism.common.tile.component.ITileComponent) HeatHandlerManager(mekanism.common.capabilities.resolver.manager.HeatHandlerManager) ITileDirectional(mekanism.common.tile.interfaces.ITileDirectional) ObjectOpenHashSet(it.unimi.dsi.fastutil.objects.ObjectOpenHashSet) NBT(net.minecraftforge.common.util.Constants.NBT) TileComponentFrequency(mekanism.common.lib.frequency.TileComponentFrequency) IInventorySlot(mekanism.api.inventory.IInventorySlot) WorldUtils(mekanism.common.util.WorldUtils) Collections(java.util.Collections) MekanismConfig(mekanism.common.config.MekanismConfig) SyncableFluidStack(mekanism.common.inventory.container.sync.SyncableFluidStack) BasicHeatCapacitor(mekanism.common.capabilities.heat.BasicHeatCapacitor) IGasTank(mekanism.api.chemical.gas.IGasTank) ITileComponent(mekanism.common.tile.component.ITileComponent) IPigmentTank(mekanism.api.chemical.pigment.IPigmentTank) IEnergyContainer(mekanism.api.energy.IEnergyContainer) IInfusionTank(mekanism.api.chemical.infuse.IInfusionTank) IHeatCapacitor(mekanism.api.heat.IHeatCapacitor) MachineEnergyContainer(mekanism.common.capabilities.energy.MachineEnergyContainer) IExtendedFluidTank(mekanism.api.fluid.IExtendedFluidTank) ISlurryTank(mekanism.api.chemical.slurry.ISlurryTank)

Aggregations

ObjectOpenHashSet (it.unimi.dsi.fastutil.objects.ObjectOpenHashSet)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Function (java.util.function.Function)1 IntSupplier (java.util.function.IntSupplier)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Action (mekanism.api.Action)1 DataHandlerUtils (mekanism.api.DataHandlerUtils)1 IConfigCardAccess (mekanism.api.IConfigCardAccess)1 MekanismAPI (mekanism.api.MekanismAPI)1 NBTConstants (mekanism.api.NBTConstants)1 Upgrade (mekanism.api.Upgrade)1 IGasTank (mekanism.api.chemical.gas.IGasTank)1 IInfusionTank (mekanism.api.chemical.infuse.IInfusionTank)1 IPigmentTank (mekanism.api.chemical.pigment.IPigmentTank)1