Got solar panel output power
This commit is contained in:
parent
99f8af9d5c
commit
484882de9d
2 changed files with 54 additions and 9 deletions
|
@ -15,13 +15,15 @@ import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
|||
|
||||
public class BlockSolarPanel extends BlockMachine implements IExtraObjectInfo
|
||||
{
|
||||
public static float tickRate = 10;
|
||||
public static float wattPerLightValue = .012f;
|
||||
public static int tickRate = 10;
|
||||
public static float wattDay = 0.120f;
|
||||
public static float wattNight = 0.001f;
|
||||
public static float wattStorm = 0.005f;
|
||||
|
||||
public BlockSolarPanel()
|
||||
{
|
||||
super(new BlockBuildData(BlockSolarPanel.class, "BlockSolarPanel", UniversalElectricity.machine));
|
||||
this.setBlockBounds(0, 0, 0, 1f, .3f, 1f);
|
||||
this.setBlockBounds(0, 0, 0, 1f, .6f, 1f);
|
||||
this.setCreativeTab(DMCreativeTab.tabIndustrial);
|
||||
}
|
||||
|
||||
|
@ -51,7 +53,7 @@ public class BlockSolarPanel extends BlockMachine implements IExtraObjectInfo
|
|||
@Override
|
||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
||||
{
|
||||
list.add(new Pair<String,Class<? extends TileEntity>>("DMSolarCell", TileEntitySolarPanel.class));
|
||||
list.add(new Pair<String, Class<? extends TileEntity>>("DMSolarCell", TileEntitySolarPanel.class));
|
||||
|
||||
}
|
||||
|
||||
|
@ -65,7 +67,9 @@ public class BlockSolarPanel extends BlockMachine implements IExtraObjectInfo
|
|||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
tickRate = config.get("settings", "PanelUpdateRate", tickRate).getInt();
|
||||
wattPerLightValue = (config.get("settings", "WattPerLightvalue", (int) wattPerLightValue * 1000, "Value * 15 equals full output").getInt() / 1000);
|
||||
wattDay = (float) (config.get("settings", "WattDayLight", 120).getDouble(120) / 1000);
|
||||
wattNight = (float) (config.get("settings", "WattMoonLight", 1).getDouble(1) / 1000);
|
||||
wattStorm = (float) (config.get("settings", "WattStorm", 6).getDouble(6) / 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,24 +2,59 @@ package dark.core.common.machines;
|
|||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
import micdoodle8.mods.galacticraft.API.ISolarLevel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import dark.core.prefab.machine.TileEntityEnergyMachine;
|
||||
|
||||
public class TileEntitySolarPanel extends TileEntityEnergyMachine
|
||||
{
|
||||
float wattOutput = 0;
|
||||
|
||||
public TileEntitySolarPanel()
|
||||
{
|
||||
this.MAX_WATTS = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (this.ticks % BlockSolarPanel.tickRate == 0)
|
||||
if (!this.worldObj.isRemote && this.ticks % BlockSolarPanel.tickRate == 0)
|
||||
{
|
||||
|
||||
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
|
||||
{
|
||||
System.out.println("DayPower: "+BlockSolarPanel.wattDay);
|
||||
System.out.println("NightPower: "+BlockSolarPanel.wattNight);
|
||||
System.out.println("StormPower: "+BlockSolarPanel.wattStorm);
|
||||
if (this.worldObj.isDaytime())
|
||||
{
|
||||
System.out.println("HasSunLight");
|
||||
this.wattOutput = BlockSolarPanel.wattDay;
|
||||
if (this.worldObj.isThundering() || this.worldObj.isRaining())
|
||||
{
|
||||
System.out.println("Storming");
|
||||
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;
|
||||
}
|
||||
System.out.println("Watts: " + this.wattOutput);
|
||||
this.produceAllSides();
|
||||
}
|
||||
|
||||
|
@ -27,7 +62,7 @@ public class TileEntitySolarPanel extends TileEntityEnergyMachine
|
|||
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.DOWN);
|
||||
return EnumSet.allOf(ForgeDirection.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,6 +77,12 @@ public class TileEntitySolarPanel extends TileEntityEnergyMachine
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
return this.wattOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float receiveElectricity(ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue