2015-03-30 15:08:19 +02:00
|
|
|
package ellpeck.actuallyadditions.tile;
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-03-30 15:08:19 +02:00
|
|
|
|
|
|
|
@Override
|
2015-05-20 22:39:43 +02:00
|
|
|
public int getEnergyStored(ForgeDirection from){
|
|
|
|
return this.storage.getEnergyStored();
|
2015-04-24 19:22:03 +02:00
|
|
|
}
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
@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, energyProducedPerTick+50);
|
|
|
|
|
|
|
|
public static int energyProducedPerTick = ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue();
|
2015-04-24 19:22:03 +02:00
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
@Override
|
2015-03-30 15:08:19 +02:00
|
|
|
public void updateEntity(){
|
|
|
|
if(!worldObj.isRemote){
|
|
|
|
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
|
2015-05-20 22:39:43 +02:00
|
|
|
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
|
|
|
this.storage.receiveEnergy(energyProducedPerTick, false);
|
|
|
|
this.markDirty();
|
|
|
|
}
|
|
|
|
}
|
2015-03-30 15:08:19 +02:00
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
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);
|
2015-03-31 20:37:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
@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);
|
|
|
|
}
|
2015-03-30 15:08:19 +02:00
|
|
|
}
|