use of mekanism.common.capabilities.ItemCapabilityWrapper in project Mekanism by mekanism.
the class ItemMekaSuitArmor method initCapabilities.
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
stack.hideTooltipPart(TooltipDisplayFlags.MODIFIERS);
// Note: We interact with this capability using "manual" as the automation type, to ensure we can properly bypass the energy limit for extracting
// Internal is used by the "null" side, which is what will get used for most items
ItemCapabilityWrapper wrapper = new ItemCapabilityWrapper(stack, RateLimitEnergyHandler.create(() -> getChargeRate(stack), () -> getMaxEnergy(stack), BasicEnergyContainer.manualOnly, BasicEnergyContainer.alwaysTrue), RadiationShieldingHandler.create(item -> isModuleEnabled(item, MekanismModules.RADIATION_SHIELDING_UNIT) ? ItemHazmatSuitArmor.getShieldingByArmor(slot) : 0), LaserDissipationHandler.create(item -> isModuleEnabled(item, MekanismModules.LASER_DISSIPATION_UNIT) ? laserDissipation : 0, item -> isModuleEnabled(item, MekanismModules.LASER_DISSIPATION_UNIT) ? laserRefraction : 0));
if (!gasTankSpecs.isEmpty()) {
wrapper.add(RateLimitMultiTankGasHandler.create(gasTankSpecs));
}
return wrapper;
}
use of mekanism.common.capabilities.ItemCapabilityWrapper 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