use of mekanism.common.block.attribute.AttributeEnergy in project Mekanism by mekanism.
the class Factory method setMachineData.
private void setMachineData() {
setFrom(origMachine, AttributeSound.class, AttributeFactoryType.class, AttributeUpgradeSupport.class);
AttributeEnergy origEnergy = origMachine.get(AttributeEnergy.class);
// TODO: Make this more readable
add(new AttributeEnergy(origEnergy::getUsage, () -> origEnergy.getConfigStorage().multiply(0.5).max(origEnergy.getUsage()).multiply(((FactoryTier) get(AttributeTier.class).getTier()).processes)));
}
use of mekanism.common.block.attribute.AttributeEnergy in project Mekanism by mekanism.
the class MachineEnergyContainer method validateBlock.
public static AttributeEnergy validateBlock(TileEntityMekanism tile) {
Objects.requireNonNull(tile, "Tile cannot be null");
Block block = tile.getBlockType();
if (!Attribute.has(block, AttributeEnergy.class)) {
throw new IllegalArgumentException("Block provider must be an electric block");
}
return Attribute.get(block, AttributeEnergy.class);
}
use of mekanism.common.block.attribute.AttributeEnergy 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