Moved power configs to settings class, attempting to fix missing config gen

This commit is contained in:
Robert S 2014-04-10 17:29:16 -04:00
parent 79f3fa57e0
commit a90f300602
3 changed files with 95 additions and 93 deletions

View file

@ -11,6 +11,7 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.electrical.battery.TileEnergyDistribution;
import universalelectricity.api.energy.EnergyStorageHandler;
@ -18,13 +19,12 @@ public class TileSolarPanel extends TileEnergyDistribution
{
@SideOnly(Side.CLIENT)
public static Icon sideIcon, bottomIcon;
@Config(category = "Power", key = "Solor_Panel")
public static long SOLAR_ENERGY = 50;
public TileSolarPanel()
{
super(Material.iron);
energy = new EnergyStorageHandler(SOLAR_ENERGY * 20);
energy = new EnergyStorageHandler(Settings.SOLAR_ENERGY * 20);
ioMap = 728;
textureName = "solarPanel_top";
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1);
@ -68,7 +68,7 @@ public class TileSolarPanel extends TileEnergyDistribution
{
if (!(this.worldObj.isThundering() || this.worldObj.isRaining()))
{
this.energy.receiveEnergy(SOLAR_ENERGY, true);
this.energy.receiveEnergy(Settings.SOLAR_ENERGY, true);
markDistributionUpdate |= produce() > 0;
}
}

View file

@ -2,6 +2,7 @@ package resonantinduction.mechanical.energy.turbine;
import java.util.List;
import resonantinduction.core.Settings;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
@ -12,115 +13,109 @@ import net.minecraft.world.biome.BiomeGenPlains;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.vector.Vector3;
import calclavia.api.resonantinduction.IBoilHandler;
import calclavia.lib.config.Config;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.utility.inventory.InventoryUtility;
/**
* The vertical wind turbine collects airflow.
* The horizontal wind turbine collects steam from steam power plants.
/** The vertical wind turbine collects airflow. The horizontal wind turbine collects steam from steam
* power plants.
*
* @author Calclavia
*
*/
* @author Calclavia */
public class TileWindTurbine extends TileMechanicalTurbine
{
private final byte[] openBlockCache = new byte[224];
private int checkCount = 0;
private float efficiency = 0;
private long windPower = 0;
private final byte[] openBlockCache = new byte[224];
private int checkCount = 0;
private float efficiency = 0;
private long windPower = 0;
@Override
public void updateEntity()
{
/**
* Break under storm.
*/
if (tier == 0 && getDirection().offsetY == 0 && worldObj.isRaining() && worldObj.isThundering() && worldObj.rand.nextFloat() < 0.00000008)
{
InventoryUtility.dropItemStack(worldObj, new Vector3(this), new ItemStack(Block.cloth, 1 + worldObj.rand.nextInt(2)));
InventoryUtility.dropItemStack(worldObj, new Vector3(this), new ItemStack(Item.stick, 3 + worldObj.rand.nextInt(8)));
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
return;
}
/**
* Only the primary turbine ticks.
*/
if (!getMultiBlock().isPrimary())
return;
/**
* If this is a vertical turbine.
*/
if (getDirection().offsetY == 0)
{
maxPower = 3000;
@Override
public void updateEntity()
{
/** Break under storm. */
if (tier == 0 && getDirection().offsetY == 0 && worldObj.isRaining() && worldObj.isThundering() && worldObj.rand.nextFloat() < 0.00000008)
{
InventoryUtility.dropItemStack(worldObj, new Vector3(this), new ItemStack(Block.cloth, 1 + worldObj.rand.nextInt(2)));
InventoryUtility.dropItemStack(worldObj, new Vector3(this), new ItemStack(Item.stick, 3 + worldObj.rand.nextInt(8)));
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
return;
}
if (ticks % 20 == 0 && !worldObj.isRemote)
computePower();
/** Only the primary turbine ticks. */
if (!getMultiBlock().isPrimary())
return;
getMultiBlock().get().power += windPower;
}
else
{
maxPower = 10000;
}
/** If this is a vertical turbine. */
if (getDirection().offsetY == 0)
{
maxPower = 3000;
if (getMultiBlock().isConstructed())
torque = (long) (defaultTorque / (9d / multiBlockRadius));
else
torque = defaultTorque / 12;
if (ticks % 20 == 0 && !worldObj.isRemote)
computePower();
super.updateEntity();
}
getMultiBlock().get().power += windPower;
}
else
{
maxPower = 10000;
}
private void computePower()
{
int checkSize = 10;
int height = yCoord + checkCount / 28;
int deviation = checkCount % 7;
ForgeDirection checkDir;
if (getMultiBlock().isConstructed())
torque = (long) (defaultTorque / (9d / multiBlockRadius));
else
torque = defaultTorque / 12;
Vector3 check = new Vector3(this);
super.updateEntity();
}
switch (checkCount / 7 % 4)
{
case 0:
checkDir = ForgeDirection.NORTH;
check = new Vector3(xCoord - 3 + deviation, height, zCoord - 4);
break;
case 1:
checkDir = ForgeDirection.WEST;
check = new Vector3(xCoord - 4, height, zCoord - 3 + deviation);
break;
case 2:
checkDir = ForgeDirection.SOUTH;
check = new Vector3(xCoord - 3 + deviation, height, zCoord + 4);
break;
default:
checkDir = ForgeDirection.EAST;
check = new Vector3(xCoord + 4, height, zCoord - 3 + deviation);
}
private void computePower()
{
int checkSize = 10;
int height = yCoord + checkCount / 28;
int deviation = checkCount % 7;
ForgeDirection checkDir;
byte openAirBlocks = 0;
Vector3 check = new Vector3(this);
while (openAirBlocks < checkSize && worldObj.isAirBlock(check.intX(), check.intY(), check.intZ()))
{
check.translate(checkDir);
openAirBlocks++;
}
switch (checkCount / 7 % 4)
{
case 0:
checkDir = ForgeDirection.NORTH;
check = new Vector3(xCoord - 3 + deviation, height, zCoord - 4);
break;
case 1:
checkDir = ForgeDirection.WEST;
check = new Vector3(xCoord - 4, height, zCoord - 3 + deviation);
break;
case 2:
checkDir = ForgeDirection.SOUTH;
check = new Vector3(xCoord - 3 + deviation, height, zCoord + 4);
break;
default:
checkDir = ForgeDirection.EAST;
check = new Vector3(xCoord + 4, height, zCoord - 3 + deviation);
}
efficiency = efficiency - openBlockCache[checkCount] + openAirBlocks;
openBlockCache[checkCount] = openAirBlocks;
checkCount = (checkCount + 1) % (openBlockCache.length - 1);
byte openAirBlocks = 0;
float multiblockMultiplier = (multiBlockRadius + 0.5f) * 2;
float materialMultiplier = tier == 0 ? 1.1f : tier == 1 ? 0.9f : 1;
while (openAirBlocks < checkSize && worldObj.isAirBlock(check.intX(), check.intY(), check.intZ()))
{
check.translate(checkDir);
openAirBlocks++;
}
BiomeGenBase biome = worldObj.getBiomeGenForCoords(xCoord, zCoord);
boolean hasBonus = biome instanceof BiomeGenOcean || biome instanceof BiomeGenPlains || biome == BiomeGenBase.river;
efficiency = efficiency - openBlockCache[checkCount] + openAirBlocks;
openBlockCache[checkCount] = openAirBlocks;
checkCount = (checkCount + 1) % (openBlockCache.length - 1);
float windSpeed = (worldObj.rand.nextFloat() / 8) + (yCoord / 256f) * (hasBonus ? 1.2f : 1) + worldObj.getRainStrength(1.5f);
windPower = (long) Math.min(materialMultiplier * multiblockMultiplier * windSpeed * efficiency, maxPower);
}
float multiblockMultiplier = (multiBlockRadius + 0.5f) * 2;
float materialMultiplier = tier == 0 ? 1.1f : tier == 1 ? 0.9f : 1;
BiomeGenBase biome = worldObj.getBiomeGenForCoords(xCoord, zCoord);
boolean hasBonus = biome instanceof BiomeGenOcean || biome instanceof BiomeGenPlains || biome == BiomeGenBase.river;
float windSpeed = (worldObj.rand.nextFloat() / 8) + (yCoord / 256f) * (hasBonus ? 1.2f : 1) + worldObj.getRainStrength(1.5f);
windPower = (long) Math.min(materialMultiplier * multiblockMultiplier * windSpeed * efficiency * Settings.WIND_POWER_RATIO, maxPower * Settings.WIND_POWER_RATIO);
}
}

View file

@ -66,6 +66,13 @@ public class Settings
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Acceleration")
public static double LEVITATOR_ACCELERATION = .02;
@Config(category = "Power", key = "Wind_tubine_Ratio")
public static int WIND_POWER_RATIO = 1;
@Config(category = "Power", key = "Water_tubine_Ratio")
public static int WATER_POWER_RATIO = 1;
@Config(category = "Power", key = "Solor_Panel")
public static long SOLAR_ENERGY = 50;
public static void setModMetadata(ModMetadata metadata, String id, String name)
{
setModMetadata(metadata, id, name, "");