45 lines
1.2 KiB
Java
45 lines
1.2 KiB
Java
/*
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
*/
|
|
|
|
package dan200.computercraft.shared.peripheral.generic.methods;
|
|
|
|
import com.google.auto.service.AutoService;
|
|
import dan200.computercraft.api.lua.LuaFunction;
|
|
import dan200.computercraft.core.asm.GenericSource;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.energy.IEnergyStorage;
|
|
import net.minecraftforge.versions.forge.ForgeVersion;
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
/**
|
|
* Methods for interacting with blocks using Forge's energy storage system.
|
|
*
|
|
* @cc.module energy_storage
|
|
*/
|
|
@AutoService( GenericSource.class )
|
|
public class EnergyMethods implements GenericSource
|
|
{
|
|
@Nonnull
|
|
@Override
|
|
public ResourceLocation id()
|
|
{
|
|
return new ResourceLocation( ForgeVersion.MOD_ID, "energy" );
|
|
}
|
|
|
|
@LuaFunction( mainThread = true )
|
|
public static int getEnergy( IEnergyStorage energy )
|
|
{
|
|
return energy.getEnergyStored();
|
|
}
|
|
|
|
@LuaFunction( mainThread = true )
|
|
public static int getEnergyCapacity( IEnergyStorage energy )
|
|
{
|
|
return energy.getMaxEnergyStored();
|
|
}
|
|
}
|