public class EnergyUtils
extends java.lang.Object
NeoTech is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: http://creativecommons.org/licenses/by-nc-sa/4.0/ Helper class to help manage energy, based off TeslaUtils but with Forge Energy
Constructor and Description |
---|
EnergyUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addToolTipInfo(net.minecraftforge.energy.IEnergyStorage energyStorage,
java.util.List<java.lang.String> toolTip,
int insert,
int extract)
Adds the energy storage info
|
static void |
addToolTipInfo(net.minecraft.item.ItemStack stack,
java.util.List<java.lang.String> toolTip)
Adds the info needed to display held energy
|
static int |
consumePowerFromFaces(net.minecraftforge.energy.IEnergyStorage source,
net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
int amountPerFace,
boolean simulated)
Sends power to all faces connected
|
static int |
distributePowerToFaces(net.minecraftforge.energy.IEnergyStorage source,
net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos,
int amountPerFace,
boolean simulated)
Sends power to all faces connected
|
static <T> java.util.List<T> |
getConnectedCapabilities(net.minecraftforge.common.capabilities.Capability<T> capability,
net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Gets a list of all capabilities that touch a BlockPos.
|
static java.lang.String |
getEnergyDisplay(int energy)
Converts the given number into a readable energy number.
|
static int |
transferPower(net.minecraftforge.energy.IEnergyStorage source,
net.minecraftforge.energy.IEnergyStorage destination,
int maxAmount,
boolean simulate)
Transfers power from one storage to another, either can be null if you are not sure if it is capable
|
public static java.lang.String getEnergyDisplay(int energy)
energy
- The numberpublic static int transferPower(@Nullable net.minecraftforge.energy.IEnergyStorage source, @Nullable net.minecraftforge.energy.IEnergyStorage destination, int maxAmount, boolean simulate)
source
- The source energy storagedestination
- The destination energy storagemaxAmount
- Max amount to transfersimulate
- True to only simulate, not actually transferpublic static <T> java.util.List<T> getConnectedCapabilities(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
capability
- The capability you want to retrieve.world
- The world that this is happening in.pos
- The position to search around.public static int distributePowerToFaces(net.minecraftforge.energy.IEnergyStorage source, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, int amountPerFace, boolean simulated)
source
- The energy sourceworld
- The worldpos
- The positionamountPerFace
- How much per facesimulated
- True to just simulatepublic static int consumePowerFromFaces(net.minecraftforge.energy.IEnergyStorage source, net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos, int amountPerFace, boolean simulated)
source
- The energy sourceworld
- The worldpos
- The positionamountPerFace
- How much per facesimulated
- True to just simulatepublic static void addToolTipInfo(net.minecraft.item.ItemStack stack, java.util.List<java.lang.String> toolTip)
stack
- The stacktoolTip
- The tip listpublic static void addToolTipInfo(net.minecraftforge.energy.IEnergyStorage energyStorage, java.util.List<java.lang.String> toolTip, int insert, int extract)
energyStorage
- The energy storage objecttoolTip
- The list to add toinsert
- The max insert, -1 to skipextract
- The max extract, -1 to skip