ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java
Ellpeck 2c6bcd72cf -Phantom Booster
-Coffee Machine
-Paxels
2015-06-12 19:12:06 +02:00

67 lines
2.4 KiB
Java

package ellpeck.actuallyadditions.tile;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyProvider;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider{
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){
return this.storage.extractEnergy(maxExtract, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from){
return this.storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from){
return this.storage.getMaxEnergyStored();
}
@Override
public boolean canConnectEnergy(ForgeDirection from){
return from != ForgeDirection.UP;
}
public EnergyStorage storage = new EnergyStorage(30000);
public static int energyProducedPerTick = ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue();
@Override
public void updateEntity(){
if(!worldObj.isRemote){
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
this.storage.receiveEnergy(energyProducedPerTick, false);
this.markDirty();
}
}
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
}
}
}
@Override
public void writeToNBT(NBTTagCompound compound){
this.storage.writeToNBT(compound);
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound){
this.storage.readFromNBT(compound);
super.readFromNBT(compound);
}
}