use of mekanism.api.math.FloatingLongSupplier in project Mekanism by mekanism.
the class ItemBlockMachine method initCapabilities.
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
if (Attribute.has(getBlock(), AttributeEnergy.class)) {
AttributeEnergy attributeEnergy = Attribute.get(getBlock(), AttributeEnergy.class);
FloatingLongSupplier maxEnergy;
if (Attribute.has(getBlock(), AttributeUpgradeSupport.class)) {
// If our block supports upgrades, make a more dynamically updating cache for our item's max energy
maxEnergy = new UpgradeBasedFloatingLongCache(stack, attributeEnergy::getStorage);
} else {
// Otherwise, just return that the max is what the base max is
maxEnergy = attributeEnergy::getStorage;
}
return new ItemCapabilityWrapper(stack, RateLimitEnergyHandler.create(maxEnergy, BasicEnergyContainer.manualOnly, BasicEnergyContainer.alwaysTrue));
}
return super.initCapabilities(stack, nbt);
}
Aggregations