Merge pull request #1622 from bshelden/1614-powergen-config
Added additional power generation configuration (#1164)
This commit is contained in:
commit
aee18c0181
5 changed files with 80 additions and 20 deletions
|
@ -1,5 +1,6 @@
|
|||
package mekanism.generators.client.gui;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
|
@ -29,6 +30,8 @@ public class GuiWindTurbine extends GuiMekanism
|
|||
{
|
||||
public TileEntityWindTurbine tileEntity;
|
||||
|
||||
private DecimalFormat powerFormat = new DecimalFormat("0.##");
|
||||
|
||||
public GuiWindTurbine(InventoryPlayer inventory, TileEntityWindTurbine tentity)
|
||||
{
|
||||
super(new ContainerWindTurbine(inventory, tentity));
|
||||
|
@ -40,7 +43,7 @@ public class GuiWindTurbine extends GuiMekanism
|
|||
public List<String> getInfo()
|
||||
{
|
||||
return ListUtils.asList(
|
||||
"Producing: " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? MekanismGenerators.windGeneration*tileEntity.getMultiplier() : 0) + "/t",
|
||||
"Producing: " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? MekanismGenerators.windGenerationMin*tileEntity.getMultiplier() : 0) + "/t",
|
||||
"Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()),
|
||||
"Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
|
||||
}
|
||||
|
@ -57,7 +60,7 @@ public class GuiWindTurbine extends GuiMekanism
|
|||
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.power") + ": " + MekanismGenerators.windGeneration*tileEntity.getMultiplier(), 51, 35, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.power") + ": " + powerFormat.format(MekanismGenerators.windGenerationMin*tileEntity.getMultiplier()), 51, 35, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00);
|
||||
|
||||
int size = 44;
|
||||
|
|
|
@ -51,13 +51,36 @@ public class GeneratorsCommonProxy
|
|||
MekanismGenerators.advancedSolarGeneration = Mekanism.configuration.get("generation", "AdvancedSolarGeneration", 300D).getDouble(300D);
|
||||
MekanismGenerators.bioGeneration = Mekanism.configuration.get("generation", "BioGeneration", 350D).getDouble(350D);
|
||||
MekanismGenerators.heatGeneration = Mekanism.configuration.get("generation", "HeatGeneration", 150D).getDouble(150D);
|
||||
MekanismGenerators.heatGenerationLava = Mekanism.configuration.get("generation", "HeatGenerationLava", 5D).getDouble(5D);
|
||||
MekanismGenerators.heatGenerationNether = Mekanism.configuration.get("generation", "HeatGenerationNether", 100D).getDouble(100D);
|
||||
MekanismGenerators.solarGeneration = Mekanism.configuration.get("generation", "SolarGeneration", 50D).getDouble(50D);
|
||||
MekanismGenerators.windGeneration = Mekanism.configuration.get("generation", "WindGeneration", 60D).getDouble(60D);
|
||||
loadWindConfiguration();
|
||||
|
||||
if(Mekanism.configuration.hasChanged())
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
private void loadWindConfiguration() {
|
||||
if (Mekanism.configuration.hasKey("generation", "WindGeneration")) {
|
||||
// Migrate the old wind generation config
|
||||
final double legacyWindGeneration = Mekanism.configuration.get("generation", "WindGeneration", 60D).getDouble(60D);
|
||||
final double windGenerationMax = legacyWindGeneration * 8D;
|
||||
Mekanism.configuration.getCategory("generation").remove("WindGeneration");
|
||||
|
||||
MekanismGenerators.windGenerationMin = Mekanism.configuration.get("generation", "WindGenerationMin", legacyWindGeneration).getDouble(legacyWindGeneration);
|
||||
MekanismGenerators.windGenerationMax = Mekanism.configuration.get("generation", "WindGenerationMax", windGenerationMax).getDouble(windGenerationMax);
|
||||
} else {
|
||||
MekanismGenerators.windGenerationMin = Mekanism.configuration.get("generation", "WindGenerationMin", 60D).getDouble(60D);
|
||||
MekanismGenerators.windGenerationMax = Mekanism.configuration.get("generation", "WindGenerationMax", 480D).getDouble(480D);
|
||||
}
|
||||
|
||||
// Ensure max > min to avoid division by zero later
|
||||
final int minY = Mekanism.configuration.get("generation", "WindGenerationMinY", 24).getInt(24);
|
||||
final int maxY = Mekanism.configuration.get("generation", "WindGenerationMaxY", 255).getInt(255);
|
||||
MekanismGenerators.windGenerationMinY = minY;
|
||||
MekanismGenerators.windGenerationMaxY = Math.max(minY + 1, maxY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual interface for a GUI. Client-only.
|
||||
* @param ID - gui ID
|
||||
|
|
|
@ -59,8 +59,15 @@ public class MekanismGenerators implements IModule
|
|||
public static double advancedSolarGeneration;
|
||||
public static double bioGeneration;
|
||||
public static double heatGeneration;
|
||||
public static double heatGenerationLava;
|
||||
public static double heatGenerationNether;
|
||||
public static double solarGeneration;
|
||||
public static double windGeneration;
|
||||
|
||||
public static double windGenerationMin;
|
||||
public static double windGenerationMax;
|
||||
|
||||
public static int windGenerationMinY;
|
||||
public static int windGenerationMaxY;
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
|
@ -168,8 +175,13 @@ public class MekanismGenerators implements IModule
|
|||
dataStream.writeDouble(advancedSolarGeneration);
|
||||
dataStream.writeDouble(bioGeneration);
|
||||
dataStream.writeDouble(heatGeneration);
|
||||
dataStream.writeDouble(heatGenerationLava);
|
||||
dataStream.writeDouble(heatGenerationNether);
|
||||
dataStream.writeDouble(solarGeneration);
|
||||
dataStream.writeDouble(windGeneration);
|
||||
dataStream.writeDouble(windGenerationMin);
|
||||
dataStream.writeDouble(windGenerationMax);
|
||||
dataStream.writeInt(windGenerationMinY);
|
||||
dataStream.writeInt(windGenerationMaxY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,8 +190,13 @@ public class MekanismGenerators implements IModule
|
|||
advancedSolarGeneration = dataStream.readDouble();
|
||||
bioGeneration = dataStream.readDouble();
|
||||
heatGeneration = dataStream.readDouble();
|
||||
heatGenerationLava = dataStream.readDouble();
|
||||
heatGenerationNether = dataStream.readDouble();
|
||||
solarGeneration = dataStream.readDouble();
|
||||
windGeneration = dataStream.readDouble();
|
||||
windGenerationMin = dataStream.readDouble();
|
||||
windGenerationMax = dataStream.readDouble();
|
||||
windGenerationMinY = dataStream.readInt();
|
||||
windGenerationMaxY = dataStream.readInt();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -182,24 +182,26 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
|||
|
||||
public double getBoost()
|
||||
{
|
||||
int boost = 0;
|
||||
int lavaBoost = 0;
|
||||
double netherBoost = 0D;
|
||||
|
||||
if(isLava(xCoord+1, yCoord, zCoord))
|
||||
boost+=5;
|
||||
lavaBoost+=1;
|
||||
if(isLava(xCoord-1, yCoord, zCoord))
|
||||
boost+=5;
|
||||
lavaBoost+=1;
|
||||
if(isLava(xCoord, yCoord+1, zCoord))
|
||||
boost+=5;
|
||||
lavaBoost+=1;
|
||||
if(isLava(xCoord, yCoord-1, zCoord))
|
||||
boost+=5;
|
||||
lavaBoost+=1;
|
||||
if(isLava(xCoord, yCoord, zCoord+1))
|
||||
boost+=5;
|
||||
lavaBoost+=1;
|
||||
if(isLava(xCoord, yCoord, zCoord-1))
|
||||
boost+=5;
|
||||
if(worldObj.provider.dimensionId == -1)
|
||||
boost+=100;
|
||||
lavaBoost+=1;
|
||||
|
||||
return boost;
|
||||
if(worldObj.provider.dimensionId == -1)
|
||||
netherBoost = MekanismGenerators.heatGenerationNether;
|
||||
|
||||
return (MekanismGenerators.heatGenerationLava * lavaBoost) + netherBoost;
|
||||
}
|
||||
|
||||
private boolean isLava(int x, int y, int z)
|
||||
|
|
|
@ -18,7 +18,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
|
|||
|
||||
public TileEntityWindTurbine()
|
||||
{
|
||||
super("WindTurbine", 200000, (MekanismGenerators.windGeneration*8)*2);
|
||||
super("WindTurbine", 200000, (MekanismGenerators.windGenerationMax)*2);
|
||||
inventory = new ItemStack[1];
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
|
|||
if(canOperate())
|
||||
{
|
||||
setActive(true);
|
||||
setEnergy(electricityStored + (MekanismGenerators.windGeneration*getMultiplier()));
|
||||
setEnergy(electricityStored + (MekanismGenerators.windGenerationMin*getMultiplier()));
|
||||
}
|
||||
else {
|
||||
setActive(false);
|
||||
|
@ -42,10 +42,25 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
|
|||
}
|
||||
}
|
||||
|
||||
/** 0 - 8 **/
|
||||
/** Determines the current output multiplier, taking sky visibility and height into account. **/
|
||||
public float getMultiplier()
|
||||
{
|
||||
return worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord) ? (((float)yCoord+4)/(float)256)*8 : 0;
|
||||
if (worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord)) {
|
||||
final float minY = (float) MekanismGenerators.windGenerationMinY;
|
||||
final float maxY = (float) MekanismGenerators.windGenerationMaxY;
|
||||
final float minG = (float) MekanismGenerators.windGenerationMin;
|
||||
final float maxG = (float) MekanismGenerators.windGenerationMax;
|
||||
|
||||
final float slope = (maxG - minG) / (maxY - minY);
|
||||
final float intercept = minG - slope * minY;
|
||||
|
||||
final float clampedY = Math.min(maxY, Math.max(minY, (float)(yCoord+4)));
|
||||
final float toGen = slope * clampedY + intercept;
|
||||
|
||||
return toGen / minG;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue