public abstract class EnergyHandler extends Syncable implements net.minecraftforge.energy.IEnergyStorage
Modifier and Type | Field and Description |
---|---|
int |
currentDifference |
EnergyBank |
energyStorage |
protected boolean |
firstRun |
int |
lastDifference |
int |
lastEnergy |
static int |
UPDATE_DIFFERENCE_ID |
static int |
UPDATE_ENERGY_ID |
Constructor and Description |
---|
EnergyHandler(net.minecraft.tileentity.TileEntityType<?> type)
Main Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
canExtract()
Returns if this storage can have energy extracted.
|
boolean |
canReceive()
Used to determine if this storage can receive energy.
|
int |
extractEnergy(int maxExtract,
boolean simulate)
Removes energy from the storage.
|
<T> net.minecraftforge.common.util.LazyOptional<T> |
getCapability(net.minecraftforge.common.capabilities.Capability<T> capability,
net.minecraft.util.Direction facing) |
protected abstract int |
getDefaultEnergyStorageSize()
Used to define the default size of this energy bank
|
int |
getEnergyStored()
Returns the amount of energy currently stored.
|
int |
getMaxEnergyStored()
Returns the maximum amount of energy that can be stored.
|
java.lang.Double |
getVariable(int id)
Used to get the field on the server, this will fetch the server value and overwrite the current
|
protected abstract boolean |
isProvider()
Is this tile an energy provider
|
protected abstract boolean |
isReceiver()
Is this tile an energy reciever
|
protected void |
onServerTick()
Tile Methods *
|
void |
read(net.minecraft.nbt.CompoundNBT compound) |
int |
receiveEnergy(int maxReceive,
boolean simulate)
Adds energy to the storage.
|
void |
setVariable(int id,
double value)
Used to set the value of a field
|
net.minecraft.nbt.CompoundNBT |
write(net.minecraft.nbt.CompoundNBT compound) |
sendValueToClient, sendValueToServer, updateClientValueFromServer
getUpdatePacket, getUpdateTag, markForUpdate, onClientTick, onDataPacket, tick
addInfoToCrashReport, create, getBlockState, getDistanceSq, getMaxRenderDistanceSquared, getPos, getTileData, getType, getWorld, hasWorld, isRemoved, markDirty, mirror, onlyOpsCanSetNbt, receiveClientEvent, remove, rotate, setPos, setWorld, updateContainingBlockInfo, validate, warnInvalidBlock
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, getCapabilities, invalidateCaps, reviveCaps, serializeCaps
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static final int UPDATE_ENERGY_ID
public static final int UPDATE_DIFFERENCE_ID
public EnergyBank energyStorage
protected boolean firstRun
public int lastEnergy
public int lastDifference
public int currentDifference
public EnergyHandler(net.minecraft.tileentity.TileEntityType<?> type)
protected abstract int getDefaultEnergyStorageSize()
protected abstract boolean isProvider()
protected abstract boolean isReceiver()
protected void onServerTick()
onServerTick
in class UpdatingTile
public net.minecraft.nbt.CompoundNBT write(net.minecraft.nbt.CompoundNBT compound)
write
in class net.minecraft.tileentity.TileEntity
public void read(net.minecraft.nbt.CompoundNBT compound)
read
in class net.minecraft.tileentity.TileEntity
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.Direction facing)
getCapability
in interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
in class net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.tileentity.TileEntity>
public void setVariable(int id, double value)
setVariable
in class Syncable
id
- The field idvalue
- The value of the fieldpublic java.lang.Double getVariable(int id)
getVariable
in class Syncable
id
- The field idpublic boolean canReceive()
canReceive
in interface net.minecraftforge.energy.IEnergyStorage
public boolean canExtract()
canExtract
in interface net.minecraftforge.energy.IEnergyStorage
public int getEnergyStored()
getEnergyStored
in interface net.minecraftforge.energy.IEnergyStorage
public int getMaxEnergyStored()
getMaxEnergyStored
in interface net.minecraftforge.energy.IEnergyStorage
public int receiveEnergy(int maxReceive, boolean simulate)
receiveEnergy
in interface net.minecraftforge.energy.IEnergyStorage
maxReceive
- Maximum amount of energy to be inserted.simulate
- If TRUE, the insertion will only be simulated.public int extractEnergy(int maxExtract, boolean simulate)
extractEnergy
in interface net.minecraftforge.energy.IEnergyStorage
maxExtract
- Maximum amount of energy to be extracted.simulate
- If TRUE, the extraction will only be simulated.