diff --git a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java index 8e9d5ba40..4dad00015 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java +++ b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java @@ -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; } } diff --git a/mechanical/src/main/scala/resonantinduction/mechanical/energy/turbine/TileWindTurbine.java b/mechanical/src/main/scala/resonantinduction/mechanical/energy/turbine/TileWindTurbine.java index e745b8c95..4996b739a 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/energy/turbine/TileWindTurbine.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/energy/turbine/TileWindTurbine.java @@ -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; + @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 this is a vertical turbine. - */ - if (getDirection().offsetY == 0) - { - maxPower = 3000; + /** Only the primary turbine ticks. */ + if (!getMultiBlock().isPrimary()) + return; - if (ticks % 20 == 0 && !worldObj.isRemote) - computePower(); + /** If this is a vertical turbine. */ + if (getDirection().offsetY == 0) + { + maxPower = 3000; - getMultiBlock().get().power += windPower; - } - else - { - maxPower = 10000; - } + if (ticks % 20 == 0 && !worldObj.isRemote) + computePower(); - if (getMultiBlock().isConstructed()) - torque = (long) (defaultTorque / (9d / multiBlockRadius)); - else - torque = defaultTorque / 12; + getMultiBlock().get().power += windPower; + } + else + { + maxPower = 10000; + } - super.updateEntity(); - } + if (getMultiBlock().isConstructed()) + torque = (long) (defaultTorque / (9d / multiBlockRadius)); + else + torque = defaultTorque / 12; - private void computePower() - { - int checkSize = 10; - int height = yCoord + checkCount / 28; - int deviation = checkCount % 7; - ForgeDirection checkDir; + super.updateEntity(); + } - Vector3 check = new Vector3(this); + private void computePower() + { + int checkSize = 10; + int height = yCoord + checkCount / 28; + int deviation = checkCount % 7; + ForgeDirection checkDir; - 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); - } + Vector3 check = new Vector3(this); - byte openAirBlocks = 0; + 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); + } - while (openAirBlocks < checkSize && worldObj.isAirBlock(check.intX(), check.intY(), check.intZ())) - { - check.translate(checkDir); - openAirBlocks++; - } + byte openAirBlocks = 0; - efficiency = efficiency - openBlockCache[checkCount] + openAirBlocks; - openBlockCache[checkCount] = openAirBlocks; - checkCount = (checkCount + 1) % (openBlockCache.length - 1); + while (openAirBlocks < checkSize && worldObj.isAirBlock(check.intX(), check.intY(), check.intZ())) + { + check.translate(checkDir); + openAirBlocks++; + } - float multiblockMultiplier = (multiBlockRadius + 0.5f) * 2; - float materialMultiplier = tier == 0 ? 1.1f : tier == 1 ? 0.9f : 1; + efficiency = efficiency - openBlockCache[checkCount] + openAirBlocks; + openBlockCache[checkCount] = openAirBlocks; + checkCount = (checkCount + 1) % (openBlockCache.length - 1); - BiomeGenBase biome = worldObj.getBiomeGenForCoords(xCoord, zCoord); - boolean hasBonus = biome instanceof BiomeGenOcean || biome instanceof BiomeGenPlains || biome == BiomeGenBase.river; + float multiblockMultiplier = (multiBlockRadius + 0.5f) * 2; + float materialMultiplier = tier == 0 ? 1.1f : tier == 1 ? 0.9f : 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); - } + 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); + } } diff --git a/src/main/scala/resonantinduction/core/Settings.java b/src/main/scala/resonantinduction/core/Settings.java index 4c47c104e..e535270f4 100644 --- a/src/main/scala/resonantinduction/core/Settings.java +++ b/src/main/scala/resonantinduction/core/Settings.java @@ -65,6 +65,13 @@ public class Settings public static double LEVITATOR_MAX_SPEED = .2; @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) {