2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("TileEntityFurnaceSolar.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 19:12:06 +02:00
|
|
|
|
public EnergyStorage storage = new EnergyStorage(30000);
|
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-08-15 20:41:45 +02:00
|
|
|
|
if(ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue() <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
|
|
|
|
this.storage.receiveEnergy(ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue(), false);
|
2015-05-20 22:39:43 +02:00
|
|
|
|
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
|
|
|
|
}
|