Fixed solar generator

This commit is contained in:
Robert 2013-12-25 14:38:21 -05:00
parent a9c31ce758
commit 75c2579960
2 changed files with 53 additions and 36 deletions

View file

@ -11,7 +11,7 @@ public class TileEntitySolarPanel extends TileEntityGenerator
{
public TileEntitySolarPanel()
{
super(0);
super();
}
@Override
@ -29,10 +29,9 @@ public class TileEntitySolarPanel extends TileEntityGenerator
@Override
public void consumeFuel()
{
this.burnTime = BlockSolarPanel.tickRate;
if (!this.worldObj.isRemote && this.ticks % BlockSolarPanel.tickRate == 0)
{
this.setJoulesPerSecound(0);
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
@ -40,37 +39,19 @@ public class TileEntitySolarPanel extends TileEntityGenerator
this.setJoulesPerTick(BlockSolarPanel.wattDay);
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.setJoulesPerTick(BlockSolarPanel.wattStorm);
this.setJoulesPerSecound(BlockSolarPanel.wattStorm);
}
}
else
{
this.setJoulesPerTick(BlockSolarPanel.wattNight);
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
if (!this.worldObj.isThundering() && !this.worldObj.isRaining())
{
this.setJoulesPerTick(0);
this.setJoulesPerTick(BlockSolarPanel.wattNight);
}
}
this.setJoulesPerTick(this.JOULES_PER_TICK + this.JOULES_PER_TICK * (this.worldObj.provider instanceof ISolarLevel ? (int) ((ISolarLevel) this.worldObj.provider).getSolarEnergyMultiplier() : 0));
}
else
{
this.setJoulesPerTick(0);
}
this.setJoulesPerSecound(this.JOULES_PER_TICK + this.JOULES_PER_TICK * (this.worldObj.provider instanceof ISolarLevel ? (int) ((ISolarLevel) this.worldObj.provider).getSolarEnergyMultiplier() : 0));
}
}
}
@Override
public long getEnergy(ForgeDirection from)
{
return 0;
}
@Override
public long getEnergyCapacity(ForgeDirection from)
{
return 0;
}
}
}

View file

@ -1,14 +1,15 @@
package com.builtbroken.assemblyline.machine;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import com.builtbroken.minecraft.prefab.TileEntityEnergyMachine;
public abstract class TileEntityGenerator extends TileEntityEnergyMachine
{
/** Run time left */
protected int burnTime = 0;
public TileEntityGenerator()
{
super();
@ -33,22 +34,45 @@ public abstract class TileEntityGenerator extends TileEntityEnergyMachine
this.consumeFuel();
if (this.isFunctioning())
{
this.burnTime--;
this.produce();
}
}
}
@Override
protected void produce()
{
for (ForgeDirection direction : this.getOutputDirections())
{
if (direction != ForgeDirection.UNKNOWN)
{
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), direction);
if (CompatibilityModule.canConnect(entity, direction.getOpposite()))
{
CompatibilityModule.receiveEnergy(entity, direction.getOpposite(), this.JOULES_PER_TICK, true);
}
}
}
}
@Override
public long onExtractEnergy(ForgeDirection from, long receive, boolean doReceive)
{
if (this.canConnect(from) && this.getOutputDirections().contains(from))
{
return Math.min(receive, this.JOULES_PER_TICK);
}
return 0;
}
@Override
public boolean canFunction()
{
return this.enabled && !this.isDisabled() && this.hasFuel();
}
public boolean hasFuel()
{
return burnTime > 0;
}
/** Does this generator have fuel time left to burn */
public abstract boolean hasFuel();
/** Called each tick to handle anything fuel related */
public abstract void consumeFuel();
@ -62,4 +86,16 @@ public abstract class TileEntityGenerator extends TileEntityEnergyMachine
{
return 0;
}
@Override
public long getEnergy(ForgeDirection from)
{
return 0;
}
@Override
public long getEnergyCapacity(ForgeDirection from)
{
return 0;
}
}