use of mekanism.api.heat.IHeatCapacitor 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));
}
}
}
}
}
Aggregations