2016-11-23 18:10:55 +01:00
|
|
|
/*
|
|
|
|
* This file ("CustomEnergyStorage.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015-2016 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.tile;
|
|
|
|
|
2016-11-26 08:58:42 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraftforge.energy.EnergyStorage;
|
2016-11-23 18:10:55 +01:00
|
|
|
|
|
|
|
public class CustomEnergyStorage extends EnergyStorage{
|
|
|
|
|
|
|
|
public CustomEnergyStorage(int capacity){
|
|
|
|
super(capacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public CustomEnergyStorage(int capacity, int maxTransfer){
|
|
|
|
super(capacity, maxTransfer);
|
|
|
|
}
|
|
|
|
|
|
|
|
public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract){
|
|
|
|
super(capacity, maxReceive, maxExtract);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int extractEnergyInternal(int maxExtract, boolean simulate){
|
|
|
|
int before = this.maxExtract;
|
2016-11-26 08:58:42 +01:00
|
|
|
this.maxExtract = Integer.MAX_VALUE;
|
2016-11-23 18:10:55 +01:00
|
|
|
|
|
|
|
int toReturn = this.extractEnergy(maxExtract, simulate);
|
|
|
|
|
2016-11-26 08:58:42 +01:00
|
|
|
this.maxExtract = before;
|
2016-11-23 18:10:55 +01:00
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int receiveEnergyInternal(int maxReceive, boolean simulate){
|
|
|
|
int before = this.maxReceive;
|
2016-11-26 08:58:42 +01:00
|
|
|
this.maxReceive = Integer.MAX_VALUE;
|
2016-11-23 18:10:55 +01:00
|
|
|
|
|
|
|
int toReturn = this.receiveEnergy(maxReceive, simulate);
|
|
|
|
|
2016-11-26 08:58:42 +01:00
|
|
|
this.maxReceive = before;
|
2016-11-23 18:10:55 +01:00
|
|
|
return toReturn;
|
|
|
|
}
|
2016-11-26 08:58:42 +01:00
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound compound){
|
|
|
|
this.energy = compound.getInteger("Energy");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writeToNBT(NBTTagCompound compound){
|
|
|
|
compound.setInteger("Energy", this.energy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnergyStored(int energy){
|
|
|
|
this.energy = energy;
|
|
|
|
}
|
2016-11-23 18:10:55 +01:00
|
|
|
}
|