Merge branch 'development' of https://github.com/aidancbrady/Mekanism into development
This commit is contained in:
commit
66c74c6643
9 changed files with 175 additions and 21 deletions
src/main
java/mekanism
api
common
generators
resources/assets/mekanism/lang
|
@ -1,6 +1,7 @@
|
|||
package mekanism.api;
|
||||
|
||||
import mekanism.api.util.EnergyUtils.EnergyType;
|
||||
import mekanism.api.util.UnitDisplayUtils.EnergyType;
|
||||
import mekanism.api.util.UnitDisplayUtils.TempType;
|
||||
|
||||
public class MekanismConfig
|
||||
{
|
||||
|
@ -27,6 +28,7 @@ public class MekanismConfig
|
|||
public static int userWorldGenVersion = 0;
|
||||
public static double ENERGY_PER_REDSTONE = 10000;
|
||||
public static EnergyType activeType = EnergyType.J;
|
||||
public static TempType tempUnit = TempType.K;
|
||||
public static double TO_IC2;
|
||||
public static double TO_BC;
|
||||
public static double TO_TE;
|
||||
|
|
|
@ -3,7 +3,7 @@ package mekanism.api.util;
|
|||
/**
|
||||
* Code taken from UE and modified to fit Mekanism.
|
||||
*/
|
||||
public class EnergyUtils
|
||||
public class UnitDisplayUtils
|
||||
{
|
||||
public static enum ElectricUnit
|
||||
{
|
||||
|
@ -27,6 +27,38 @@ public class EnergyUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static enum TemperatureUnit
|
||||
{
|
||||
KELVIN("Kelvin", "K", 0, 1),
|
||||
CELSIUS("Celsius", "C", 273.15, 1),
|
||||
RANKINE("Rankine", "R", 0, 5/9),
|
||||
FAHRENHEIT("Fahrenheit", "F", 459.67, 5/9),
|
||||
AMBIENT("Ambient", "+STP", 300, 1);
|
||||
|
||||
public String name;
|
||||
public String symbol;
|
||||
double zeroOffset;
|
||||
double intervalSize;
|
||||
|
||||
private TemperatureUnit(String s, String s1, double offset, double size)
|
||||
{
|
||||
name = s;
|
||||
symbol = s1;
|
||||
zeroOffset = offset;
|
||||
intervalSize = size;
|
||||
}
|
||||
|
||||
public double convertFromK(double T)
|
||||
{
|
||||
return (T * intervalSize) - zeroOffset;
|
||||
}
|
||||
|
||||
public double convertToK(double T)
|
||||
{
|
||||
return (T + zeroOffset) / intervalSize;
|
||||
}
|
||||
}
|
||||
|
||||
/** Metric system of measurement. */
|
||||
public static enum MeasurementUnit
|
||||
{
|
||||
|
@ -174,6 +206,65 @@ public class EnergyUtils
|
|||
return roundDecimals(value, decimalPlaces) + " " + unit.name;
|
||||
}
|
||||
|
||||
public static String getDisplay(double T, TemperatureUnit unit, int decimalPlaces, boolean isShort)
|
||||
{
|
||||
String unitName = unit.name;
|
||||
String prefix = "";
|
||||
|
||||
double value = unit.convertFromK(T);
|
||||
|
||||
if(value < 0)
|
||||
{
|
||||
value = Math.abs(value);
|
||||
prefix = "-";
|
||||
}
|
||||
|
||||
if(isShort)
|
||||
{
|
||||
unitName = unit.symbol;
|
||||
}
|
||||
|
||||
if(value == 0)
|
||||
{
|
||||
return value + " " + unitName;
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < MeasurementUnit.values().length; i++)
|
||||
{
|
||||
MeasurementUnit lowerMeasure = MeasurementUnit.values()[i];
|
||||
|
||||
if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
if(lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1];
|
||||
|
||||
if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prefix + roundDecimals(value, decimalPlaces) + " " + unitName;
|
||||
}
|
||||
|
||||
public static String getDisplayShort(double value, TemperatureUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, true);
|
||||
}
|
||||
|
||||
public static String getDisplayShort(double value, TemperatureUnit unit, int decimalPlaces)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, true);
|
||||
}
|
||||
|
||||
public static double roundDecimals(double d, int decimalPlaces)
|
||||
{
|
||||
int j = (int)(d*Math.pow(10, decimalPlaces));
|
||||
|
@ -192,4 +283,13 @@ public class EnergyUtils
|
|||
EU,
|
||||
MJ
|
||||
}
|
||||
|
||||
public static enum TempType
|
||||
{
|
||||
K,
|
||||
C,
|
||||
R,
|
||||
F,
|
||||
STP
|
||||
}
|
||||
}
|
|
@ -6,7 +6,8 @@ import mekanism.api.MekanismAPI;
|
|||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.api.Pos3D;
|
||||
import mekanism.api.util.EnergyUtils.EnergyType;
|
||||
import mekanism.api.util.UnitDisplayUtils.EnergyType;
|
||||
import mekanism.api.util.UnitDisplayUtils.TempType;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.entity.EntityRobit;
|
||||
|
@ -244,6 +245,32 @@ public class CommonProxy
|
|||
}
|
||||
}
|
||||
|
||||
s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Temperature Units", "K", null, new String[]{"K", "C", "R", "F"}).getString();
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
if(s.trim().equalsIgnoreCase("k") || s.trim().equalsIgnoreCase("kelvin"))
|
||||
{
|
||||
general.tempUnit = TempType.K;
|
||||
}
|
||||
else if(s.trim().equalsIgnoreCase("c") || s.trim().equalsIgnoreCase("celsius") || s.trim().equalsIgnoreCase("centigrade"))
|
||||
{
|
||||
general.tempUnit = TempType.C;
|
||||
}
|
||||
else if(s.trim().equalsIgnoreCase("r") || s.trim().equalsIgnoreCase("rankine"))
|
||||
{
|
||||
general.tempUnit = TempType.R;
|
||||
}
|
||||
else if(s.trim().equalsIgnoreCase("f") || s.trim().equalsIgnoreCase("fahrenheit"))
|
||||
{
|
||||
general.tempUnit = TempType.F;
|
||||
}
|
||||
else if(s.trim().equalsIgnoreCase("a") || s.trim().equalsIgnoreCase("ambient") || s.trim().equalsIgnoreCase("stp"))
|
||||
{
|
||||
general.tempUnit = TempType.STP;
|
||||
}
|
||||
}
|
||||
|
||||
general.laserRange = Mekanism.configuration.get("general", "LaserRange", 64).getInt(64);
|
||||
general.laserEnergyNeededPerHardness = Mekanism.configuration.get("general", "LaserDiggingEnergy", 100000).getInt(100000);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package mekanism.common.network;
|
|||
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.api.util.EnergyUtils.EnergyType;
|
||||
import mekanism.api.util.UnitDisplayUtils.EnergyType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.network.PacketConfigSync.ConfigSyncMessage;
|
||||
|
|
|
@ -23,8 +23,9 @@ import mekanism.api.MekanismConfig.client;
|
|||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.util.EnergyUtils;
|
||||
import mekanism.api.util.EnergyUtils.ElectricUnit;
|
||||
import mekanism.api.util.UnitDisplayUtils;
|
||||
import mekanism.api.util.UnitDisplayUtils.ElectricUnit;
|
||||
import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.OreDictCache;
|
||||
|
@ -1142,13 +1143,37 @@ public final class MekanismUtils
|
|||
switch(general.activeType)
|
||||
{
|
||||
case J:
|
||||
return EnergyUtils.getDisplayShort(energy, ElectricUnit.JOULES);
|
||||
return UnitDisplayUtils.getDisplayShort(energy, ElectricUnit.JOULES);
|
||||
case RF:
|
||||
return EnergyUtils.getDisplayShort(energy * general.TO_TE, ElectricUnit.REDSTONE_FLUX, 0);
|
||||
return UnitDisplayUtils.getDisplayShort(energy * general.TO_TE, ElectricUnit.REDSTONE_FLUX, 0);
|
||||
case EU:
|
||||
return EnergyUtils.getDisplayShort(energy * general.TO_IC2, ElectricUnit.ELECTRICAL_UNITS, 0);
|
||||
return UnitDisplayUtils.getDisplayShort(energy * general.TO_IC2, ElectricUnit.ELECTRICAL_UNITS, 0);
|
||||
case MJ:
|
||||
return EnergyUtils.getDisplayShort(energy * general.TO_TE / 10, ElectricUnit.MINECRAFT_JOULES);
|
||||
return UnitDisplayUtils.getDisplayShort(energy * general.TO_TE / 10, ElectricUnit.MINECRAFT_JOULES);
|
||||
}
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a rounded energy display of a defined amount of energy.
|
||||
* @param T - temperature to display
|
||||
* @return rounded energy display
|
||||
*/
|
||||
public static String getTemperatureDisplay(double T)
|
||||
{
|
||||
switch(general.tempUnit)
|
||||
{
|
||||
case K:
|
||||
return UnitDisplayUtils.getDisplayShort(T, TemperatureUnit.KELVIN);
|
||||
case C:
|
||||
return UnitDisplayUtils.getDisplayShort(T, TemperatureUnit.CELSIUS);
|
||||
case R:
|
||||
return UnitDisplayUtils.getDisplayShort(T, TemperatureUnit.RANKINE);
|
||||
case F:
|
||||
return UnitDisplayUtils.getDisplayShort(T, TemperatureUnit.FAHRENHEIT);
|
||||
case STP:
|
||||
return UnitDisplayUtils.getDisplayShort(T, TemperatureUnit.AMBIENT);
|
||||
}
|
||||
|
||||
return "error";
|
||||
|
|
|
@ -78,7 +78,7 @@ public class GuiReactorHeat extends GuiMekanism
|
|||
@Override
|
||||
public String getText(double level)
|
||||
{
|
||||
return "Plasma: " + (int)level + "C";
|
||||
return "Plasma: " + MekanismUtils.getTemperatureDisplay(level);
|
||||
}
|
||||
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 7, 50));
|
||||
guiElements.add(new GuiProgress(new IProgressInfoHandler()
|
||||
|
@ -112,7 +112,7 @@ public class GuiReactorHeat extends GuiMekanism
|
|||
@Override
|
||||
public String getText(double level)
|
||||
{
|
||||
return "Case: " + (int)level + "C";
|
||||
return "Case: " + MekanismUtils.getTemperatureDisplay(level);
|
||||
}
|
||||
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 61, 50));
|
||||
guiElements.add(new GuiProgress(new IProgressInfoHandler()
|
||||
|
|
|
@ -58,16 +58,16 @@ public class GuiReactorStats extends GuiMekanism
|
|||
{
|
||||
fontRendererObj.drawString(EnumColor.DARK_GREEN + MekanismUtils.localize("gui.passive"), 6, 26, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.minInject") + ": " + (tileEntity.getReactor().getMinInjectionRate(false)), 16, 36, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.ignition") + ": " + (nf.format(tileEntity.getReactor().getIgnitionTemperature(false))), 16, 46, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxPlasma") + ": " + (nf.format(tileEntity.getReactor().getMaxPlasmaTemperature(false))), 16, 56, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxCasing") + ": " + (nf.format(tileEntity.getReactor().getMaxCasingTemperature(false))), 16, 66, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.ignition") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getIgnitionTemperature(false))), 16, 46, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxPlasma") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxPlasmaTemperature(false))), 16, 56, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxCasing") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxCasingTemperature(false))), 16, 66, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.passiveGeneration") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, false))+"/t", 16, 76, 0x404040);
|
||||
|
||||
fontRendererObj.drawString(EnumColor.DARK_BLUE + MekanismUtils.localize("gui.active"), 6, 92, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.minInject") + ": " + (tileEntity.getReactor().getMinInjectionRate(true)), 16, 102, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.ignition") + ": " + (nf.format(tileEntity.getReactor().getIgnitionTemperature(true))), 16, 112, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxPlasma") + ": " + (nf.format(tileEntity.getReactor().getMaxPlasmaTemperature(true))), 16, 122, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxCasing") + ": " + (nf.format(tileEntity.getReactor().getMaxCasingTemperature(true))), 16, 132, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.ignition") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getIgnitionTemperature(true))), 16, 112, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxPlasma") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxPlasmaTemperature(true))), 16, 122, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.maxCasing") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxCasingTemperature(true))), 16, 132, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.passiveGeneration") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(true, false))+"/t", 16, 142, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.steamProduction") + ": " + nf.format(tileEntity.getReactor().getSteamPerTick(false)) + "mB/t", 16, 152, 0x404040);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class FusionReactor implements IFusionReactor
|
|||
@Override
|
||||
public void addTemperatureFromEnergyInput(double energyAdded)
|
||||
{
|
||||
plasmaTemperature += energyAdded / plasmaHeatCapacity;
|
||||
plasmaTemperature += energyAdded / plasmaHeatCapacity * (isBurning() ? 1 : 10);
|
||||
}
|
||||
|
||||
public boolean hasHohlraum()
|
||||
|
|
|
@ -726,8 +726,8 @@ gui.solarGenerator.sun=Sun
|
|||
gui.bioGenerator.bioFuel=BioFuel
|
||||
gui.electrolyticSeparator.dump=Dump
|
||||
|
||||
gui.passive=Passive
|
||||
gui.active=Active
|
||||
gui.passive=Air-Cooled
|
||||
gui.active=Water-Cooled
|
||||
|
||||
gui.minInject=Min. Inject Rate
|
||||
gui.ignition=Ignition Temp
|
||||
|
|
Loading…
Add table
Reference in a new issue