worked on generators and battery box

This commit is contained in:
Robert 2013-12-03 08:59:11 -05:00
parent 58f3634f4b
commit 68e121cdfc
4 changed files with 61 additions and 63 deletions

View file

@ -5,6 +5,7 @@ import java.util.EnumSet;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@ -128,6 +129,11 @@ public class TileEntityBatteryBox extends TileEntityEnergyMachine
{
return PacketHandler.instance().getTilePacket(this.getChannel(), this, "desc", this.getEnergyStored(), this.getMaxEnergyStored());
}
public void sendGUIPacket(EntityPlayer entity)
{
}
@Override
public String getInvName()

View file

@ -7,52 +7,15 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
import dark.core.prefab.machine.TileEntityEnergyMachine;
import dark.core.prefab.machine.TileEntityGenerator;
public class TileEntitySolarPanel extends TileEntityEnergyMachine
public class TileEntitySolarPanel extends TileEntityGenerator
{
protected float wattOutput = 0;
public TileEntitySolarPanel()
{
super(0, 1);
}
@Override
public void updateEntity()
{
super.updateEntity();
if (!this.worldObj.isRemote && this.ticks % BlockSolarPanel.tickRate == 0)
{
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
{
this.wattOutput = BlockSolarPanel.wattDay;
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.wattOutput = BlockSolarPanel.wattStorm;
}
}
else
{
this.wattOutput = BlockSolarPanel.wattNight;
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.wattOutput = 0;
}
}
this.wattOutput += this.wattOutput * (this.worldObj.provider instanceof ISolarLevel ? (int) ((ISolarLevel) this.worldObj.provider).getSolarEnergyMultiplier() : 0);
}
else
{
wattOutput = 0;
}
this.produceAllSides();
}
}
@Override
public EnumSet<ForgeDirection> getOutputDirections()
{
@ -60,26 +23,38 @@ public class TileEntitySolarPanel extends TileEntityEnergyMachine
}
@Override
public float getRequest(ForgeDirection direction)
public void consumeFuel()
{
return 0;
}
this.burnTime = BlockSolarPanel.tickRate;
if (!this.worldObj.isRemote && this.ticks % BlockSolarPanel.tickRate == 0)
{
@Override
public float getProvide(ForgeDirection direction)
{
return this.wattOutput;
}
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
{
this.setJoulesPerTick(BlockSolarPanel.wattDay);
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.setJoulesPerTick(BlockSolarPanel.wattStorm);
}
}
else
{
this.setJoulesPerTick(BlockSolarPanel.wattNight);
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.setJoulesPerTick(0);
}
}
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.produceAllSides();
}
@Override
public float receiveElectricity(ElectricityPack receive, boolean doReceive)
{
return 0;
}
@Override
public float getVoltage()
{
return 0.060F;
}
}

View file

@ -6,7 +6,22 @@ import universalelectricity.core.electricity.ElectricityPack;
public abstract class TileEntityGenerator extends TileEntityEnergyMachine
{
/** Run time left */
int burnTime = 0;
protected int burnTime = 0;
public TileEntityGenerator()
{
super();
}
public TileEntityGenerator(float wattsPerTick)
{
super(wattsPerTick);
}
public TileEntityGenerator(float wattsPerTick, float maxEnergy)
{
super(wattsPerTick, maxEnergy);
}
@Override
public void updateEntity()
@ -14,7 +29,7 @@ public abstract class TileEntityGenerator extends TileEntityEnergyMachine
super.updateEntity();
if (!this.worldObj.isRemote && this.enabled)
{
if (this.burnTime <= 10)
if (this.burnTime <= 0)
{
this.consumeFuel();
}

View file

@ -14,6 +14,7 @@ import universalelectricity.prefab.tile.IRotatable;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import dark.api.IDisableable;
import dark.core.common.DarkMain;
@ -225,14 +226,15 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
}
/** Sends a gui packet only to the given player */
public void sendGUIPacket(EntityPlayer entity)
public Packet getGUIPacket()
{
return null;
}
public void sendGUIPacket()
{
if (this.hasGUI && this.getContainer() != null && this.ticks % 5 == 0)
Packet packet = this.getGUIPacket();
if (this.hasGUI && this.getContainer() != null && packet != null)
{
this.playersUsingMachine = 0;
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(10, 10, 10)))
@ -242,7 +244,7 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
if (((EntityPlayer) entity).openContainer.getClass().isAssignableFrom(this.getContainer()))
{
this.playersUsingMachine += 1;
this.sendGUIPacket((EntityPlayer) entity);
PacketDispatcher.sendPacketToPlayer(packet, (Player) entity);
}
}
}