2014-02-09 06:08:27 +01:00
|
|
|
package appeng.core;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
|
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
import net.minecraftforge.common.config.Property;
|
|
|
|
import appeng.api.config.CondenserOuput;
|
|
|
|
import appeng.api.config.PowerMultiplier;
|
|
|
|
import appeng.api.config.PowerUnits;
|
2014-02-16 10:09:20 +01:00
|
|
|
import appeng.api.config.SearchBoxMode;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.api.config.Settings;
|
2014-03-27 06:14:34 +01:00
|
|
|
import appeng.api.config.TerminalStyle;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.api.config.YesNo;
|
|
|
|
import appeng.api.util.IConfigManager;
|
|
|
|
import appeng.api.util.IConfigureableObject;
|
|
|
|
import appeng.core.features.AEFeature;
|
2014-03-17 20:59:50 +01:00
|
|
|
import appeng.core.settings.TickRates;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.util.ConfigManager;
|
|
|
|
import appeng.util.IConfigManagerHost;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.util.Platform;
|
2014-02-09 06:08:27 +01:00
|
|
|
|
|
|
|
public class AEConfig extends Configuration implements IConfigureableObject, IConfigManagerHost
|
|
|
|
{
|
|
|
|
|
|
|
|
public static AEConfig instance;
|
|
|
|
|
2014-05-02 07:40:46 +02:00
|
|
|
public static double TunnelPowerLoss = 0.05;
|
2014-02-09 06:08:27 +01:00
|
|
|
|
|
|
|
public String latestVersion = VERSION;
|
|
|
|
public long latestTimeStamp = 0;
|
|
|
|
|
|
|
|
public static final String VERSION = "@version@";
|
|
|
|
public static final String CHANNEL = "@aechannel@";
|
|
|
|
|
|
|
|
public final static String PACKET_CHANNEL = "AE";
|
|
|
|
|
|
|
|
public IConfigManager settings = new ConfigManager( this );
|
|
|
|
public EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
|
2014-03-06 06:45:14 +01:00
|
|
|
PowerUnits selectedPowerUnit = PowerUnits.AE;
|
2014-02-09 06:08:27 +01:00
|
|
|
|
2014-03-05 08:27:42 +01:00
|
|
|
public int storageBiomeID = -1;
|
|
|
|
public int storageProviderID = -1;
|
|
|
|
|
2014-03-15 07:58:21 +01:00
|
|
|
public float spawnChargedChance = 0.92f;
|
|
|
|
public int quartzOresPerCluster = 4;
|
|
|
|
public int chargedChange = 4;
|
|
|
|
public int minMeteoriteDistance = 707;
|
|
|
|
public int minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance;
|
2014-02-09 06:08:27 +01:00
|
|
|
|
|
|
|
private double WirelessBaseCost = 8;
|
|
|
|
private double WirelessCostMultiplier = 1;
|
|
|
|
private double WirelessHighWirelessCount = 64;
|
|
|
|
private double WirelessTerminalDrainMultiplier = 1;
|
|
|
|
|
|
|
|
private double WirelessBaseRange = 16;
|
|
|
|
private double WirelessBoosterRangeMultiplier = 1;
|
|
|
|
private double WirelessBoosterExp = 1.5;
|
|
|
|
|
|
|
|
public double wireless_getDrainRate(double range)
|
|
|
|
{
|
|
|
|
return WirelessTerminalDrainMultiplier * range;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double wireless_getMaxRange(int boosters)
|
|
|
|
{
|
|
|
|
return WirelessBaseRange + WirelessBoosterRangeMultiplier * Math.pow( boosters, WirelessBoosterExp );
|
|
|
|
}
|
|
|
|
|
|
|
|
public double wireless_getPowerDrain(int boosters)
|
|
|
|
{
|
|
|
|
return WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / WirelessHighWirelessCount );
|
|
|
|
}
|
|
|
|
|
|
|
|
public double spatialPowerScaler = 1.5;
|
|
|
|
public double spatialPowerMultiplier = 1500.0;
|
|
|
|
|
|
|
|
public String grinderOres[] = {
|
|
|
|
// Vanilla Items
|
|
|
|
"Obsidian", "Ender", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz",
|
|
|
|
// Common Mod Ores
|
|
|
|
"Copper", "Tin", "Silver", "Lead", "Bronze",
|
|
|
|
// AE
|
|
|
|
"CertusQuartz", "Wheat", "Fluix",
|
|
|
|
// Other Mod Ores
|
|
|
|
"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum" };
|
|
|
|
|
|
|
|
public double oreDoublePercentage = 90.0;
|
|
|
|
|
|
|
|
public boolean enableEffects = true;
|
2014-03-17 20:59:50 +01:00
|
|
|
public boolean useLargeFonts = false;
|
2014-02-09 06:08:27 +01:00
|
|
|
|
|
|
|
public int wireless_battery = 1600000;
|
|
|
|
public int manipulator_battery = 200000;
|
|
|
|
public int mattercannon_battery = 200000;
|
|
|
|
public int portablecell_battery = 20000;
|
2014-05-26 10:26:37 +02:00
|
|
|
public int colorapplicator_battery = 20000;
|
2014-02-09 06:08:27 +01:00
|
|
|
public int staff_battery = 8000;
|
|
|
|
|
2014-02-11 06:50:05 +01:00
|
|
|
public AEConfig(String path) {
|
|
|
|
super( new File( path + "AppliedEnergistics2.cfg" ) );
|
2014-02-09 06:08:27 +01:00
|
|
|
|
|
|
|
final double DEFAULT_BC_EXCHANGE = 5.0;
|
|
|
|
// final double DEFAULT_UE_EXCHANGE = 5.0;
|
|
|
|
final double DEFAULT_IC2_EXCHANGE = 2.0;
|
|
|
|
final double DEFAULT_RTC_EXCHANGE = 1.0 / 11256.0;
|
|
|
|
final double DEFAULT_RF_EXCHANGE = 0.5;
|
|
|
|
|
|
|
|
PowerUnits.MJ.conversionRatio = get( "PowerRatios", "BuildCraft", DEFAULT_BC_EXCHANGE ).getDouble( DEFAULT_BC_EXCHANGE );
|
|
|
|
// PowerUnits.KJ.conversionRatio = get( "PowerRatios",
|
|
|
|
// "UniversalElectricity", DEFAULT_UE_EXCHANGE ).getDouble(
|
|
|
|
// DEFAULT_UE_EXCHANGE );
|
|
|
|
PowerUnits.EU.conversionRatio = get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
|
|
|
|
PowerUnits.WA.conversionRatio = get( "PowerRatios", "RotaryCraft", DEFAULT_RTC_EXCHANGE ).getDouble( DEFAULT_RTC_EXCHANGE );
|
|
|
|
PowerUnits.RF.conversionRatio = get( "PowerRatios", "ThermalExpansion", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE );
|
|
|
|
|
|
|
|
double usageEffective = get( "PowerRatios", "UsageMultiplier", 1.0 ).getDouble( 1.0 );
|
|
|
|
PowerMultiplier.CONFIG.multiplier = Math.max( 0.01, usageEffective );
|
|
|
|
|
|
|
|
CondenserOuput.MATTER_BALLS.requiredPower = get( "Condenser", "MatterBalls", 256 ).getInt( 256 );
|
|
|
|
CondenserOuput.SINGULARITY.requiredPower = get( "Condenser", "Singularity", 256000 ).getInt( 256000 );
|
|
|
|
|
|
|
|
grinderOres = get( "GrindStone", "grinderOres", grinderOres ).getStringList();
|
|
|
|
oreDoublePercentage = get( "GrindStone", "oreDoublePercentage", oreDoublePercentage ).getDouble( oreDoublePercentage );
|
|
|
|
enableEffects = get( "Client", "enableEffects", true ).getBoolean( true );
|
2014-03-27 06:14:34 +01:00
|
|
|
useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
|
2014-03-27 06:14:34 +01:00
|
|
|
settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL );
|
2014-02-16 10:09:20 +01:00
|
|
|
settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
|
2014-02-09 06:08:27 +01:00
|
|
|
|
2014-03-15 07:58:21 +01:00
|
|
|
spawnChargedChance = (float) (1.0 - get( "worldGen", "spawnChargedChance", 1.0 - spawnChargedChance ).getDouble( 1.0 - spawnChargedChance ));
|
|
|
|
minMeteoriteDistance = get( "worldGen", "minMeteoriteDistance", minMeteoriteDistance ).getInt( minMeteoriteDistance );
|
|
|
|
quartzOresPerCluster = get( "worldGen", "quartzOresPerCluster", quartzOresPerCluster ).getInt( quartzOresPerCluster );
|
|
|
|
|
|
|
|
minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance;
|
|
|
|
|
2014-05-26 10:26:37 +02:00
|
|
|
addCustomCategoryComment(
|
|
|
|
"wireless",
|
|
|
|
"Range= WirelessBaseRange + WirelessBoosterRangeMultiplier * Math.pow( boosters, WirelessBoosterExp )\nPowerDrain= WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / WirelessHighWirelessCount )" );
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
|
|
|
|
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
|
|
|
|
WirelessBaseRange = get( "wireless", "WirelessBaseRange", WirelessBaseRange ).getDouble( WirelessBaseRange );
|
|
|
|
WirelessBoosterRangeMultiplier = get( "wireless", "WirelessBoosterRangeMultiplier", WirelessBoosterRangeMultiplier ).getDouble(
|
|
|
|
WirelessBoosterRangeMultiplier );
|
|
|
|
WirelessBoosterExp = get( "wireless", "WirelessBoosterExp", WirelessBoosterExp ).getDouble( WirelessBoosterExp );
|
|
|
|
WirelessTerminalDrainMultiplier = get( "wireless", "WirelessTerminalDrainMultiplier", WirelessTerminalDrainMultiplier ).getDouble(
|
|
|
|
WirelessTerminalDrainMultiplier );
|
|
|
|
|
|
|
|
wireless_battery = get( "battery", "wireless", wireless_battery ).getInt( wireless_battery );
|
|
|
|
staff_battery = get( "battery", "staff", staff_battery ).getInt( staff_battery );
|
|
|
|
manipulator_battery = get( "battery", "manipulator", manipulator_battery ).getInt( manipulator_battery );
|
|
|
|
portablecell_battery = get( "battery", "portablecell", portablecell_battery ).getInt( portablecell_battery );
|
2014-05-26 10:26:37 +02:00
|
|
|
colorapplicator_battery = get( "battery", "colorapplicator", colorapplicator_battery ).getInt( colorapplicator_battery );
|
2014-02-09 06:08:27 +01:00
|
|
|
mattercannon_battery = get( "battery", "mattercannon", mattercannon_battery ).getInt( mattercannon_battery );
|
|
|
|
|
|
|
|
for (AEFeature feature : AEFeature.values())
|
|
|
|
{
|
|
|
|
if ( feature.isVisible() )
|
|
|
|
{
|
|
|
|
if ( get( "Features." + feature.getCategory(), feature.name(), feature.defaultVaue() ).getBoolean( feature.defaultVaue() ) )
|
|
|
|
featureFlags.add( feature );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
featureFlags.add( feature );
|
|
|
|
}
|
|
|
|
|
2014-03-09 22:39:30 +01:00
|
|
|
if ( featureFlags.contains( AEFeature.WebsiteRecipes ) )
|
|
|
|
featureFlags.add( AEFeature.DuplicateItems );
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
for (Enum e : settings.getSettings())
|
|
|
|
{
|
|
|
|
String Category = e.getClass().getSimpleName();
|
2014-04-20 06:12:25 +02:00
|
|
|
Enum value = settings.getSetting( e );
|
2014-05-26 10:26:37 +02:00
|
|
|
|
2014-05-22 23:29:10 +02:00
|
|
|
Property p = this.get( Category, e.name(), value.name(), getListComment( value ) );
|
2014-05-26 10:26:37 +02:00
|
|
|
|
2014-04-20 06:12:25 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
value = Enum.valueOf( value.getClass(), p.getString() );
|
|
|
|
}
|
|
|
|
catch (IllegalArgumentException er)
|
|
|
|
{
|
|
|
|
AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" );
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.putSetting( e, value );
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
try
|
|
|
|
{
|
2014-05-26 10:26:37 +02:00
|
|
|
selectedPowerUnit = PowerUnits.valueOf( get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment( selectedPowerUnit ) ).getString() );
|
2014-03-06 06:45:14 +01:00
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
selectedPowerUnit = PowerUnits.AE;
|
|
|
|
}
|
|
|
|
|
2014-03-27 06:14:34 +01:00
|
|
|
for (TickRates tr : TickRates.values())
|
2014-03-17 20:59:50 +01:00
|
|
|
{
|
2014-03-27 06:14:34 +01:00
|
|
|
tr.Load( this );
|
2014-03-17 20:59:50 +01:00
|
|
|
}
|
2014-03-27 06:14:34 +01:00
|
|
|
|
2014-03-05 08:27:42 +01:00
|
|
|
if ( isFeatureEnabled( AEFeature.SpatialIO ) )
|
|
|
|
{
|
|
|
|
storageBiomeID = get( "spatialio", "storageBiomeID", storageBiomeID ).getInt( storageBiomeID );
|
|
|
|
storageProviderID = get( "spatialio", "storageProviderID", storageProviderID ).getInt( storageProviderID );
|
|
|
|
}
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
latestVersion = get( "VersionChecker", "LatestVersion", "" ).getString();
|
|
|
|
latestTimeStamp = Long.parseLong( get( "VersionChecker", "LatestTimeStamp", "" ).getString() );
|
|
|
|
}
|
|
|
|
catch (NumberFormatException err)
|
|
|
|
{
|
|
|
|
latestTimeStamp = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 23:29:10 +02:00
|
|
|
private String getListComment(Enum value)
|
|
|
|
{
|
|
|
|
String comment = null;
|
2014-05-26 10:26:37 +02:00
|
|
|
|
2014-05-22 23:29:10 +02:00
|
|
|
if ( value != null )
|
|
|
|
{
|
2014-05-26 10:26:37 +02:00
|
|
|
EnumSet set = EnumSet.allOf( value.getClass() );
|
|
|
|
|
|
|
|
for (Object Oeg : set)
|
2014-05-22 23:29:10 +02:00
|
|
|
{
|
2014-05-26 10:26:37 +02:00
|
|
|
Enum eg = (Enum) Oeg;
|
2014-05-22 23:29:10 +02:00
|
|
|
if ( comment == null )
|
|
|
|
comment = "Possible Values: " + eg.name();
|
|
|
|
else
|
2014-05-26 10:26:37 +02:00
|
|
|
comment += ", " + eg.name();
|
2014-05-22 23:29:10 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-26 10:26:37 +02:00
|
|
|
|
2014-05-22 23:29:10 +02:00
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
@Override
|
2014-02-17 01:50:25 +01:00
|
|
|
public void updateSetting(IConfigManager manager, Enum setting, Enum newValue)
|
2014-02-09 06:08:27 +01:00
|
|
|
{
|
|
|
|
for (Enum e : settings.getSettings())
|
|
|
|
{
|
2014-04-20 06:12:25 +02:00
|
|
|
if ( e == setting )
|
|
|
|
{
|
|
|
|
String Category = e.getClass().getSimpleName();
|
2014-05-22 23:29:10 +02:00
|
|
|
Property p = this.get( Category, e.name(), settings.getSetting( e ).name(), getListComment( newValue ) );
|
2014-04-20 06:12:25 +02:00
|
|
|
p.set( newValue.name() );
|
|
|
|
}
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void save()
|
|
|
|
{
|
|
|
|
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
|
|
|
{
|
|
|
|
get( "VersionChecker", "LatestVersion", latestVersion ).set( latestVersion );
|
|
|
|
get( "VersionChecker", "LatestTimeStamp", "" ).set( Long.toString( latestTimeStamp ) );
|
|
|
|
}
|
|
|
|
|
2014-03-05 08:27:42 +01:00
|
|
|
if ( isFeatureEnabled( AEFeature.SpatialIO ) )
|
|
|
|
{
|
|
|
|
get( "spatialio", "storageBiomeID", storageBiomeID ).set( storageBiomeID );
|
|
|
|
get( "spatialio", "storageProviderID", storageProviderID ).set( storageProviderID );
|
|
|
|
}
|
|
|
|
|
2014-05-26 10:26:37 +02:00
|
|
|
get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment( selectedPowerUnit ) ).set( selectedPowerUnit.name() );
|
2014-03-06 06:45:14 +01:00
|
|
|
|
2014-02-09 06:08:27 +01:00
|
|
|
if ( hasChanged() )
|
|
|
|
super.save();
|
|
|
|
}
|
|
|
|
|
2014-04-06 08:51:44 +02:00
|
|
|
public int getFreeIDSLot(int varID, String Category)
|
2014-02-09 06:08:27 +01:00
|
|
|
{
|
2014-04-06 08:51:44 +02:00
|
|
|
boolean alreadyUsed = false;
|
2014-02-09 06:08:27 +01:00
|
|
|
int min = 0;
|
2014-04-06 08:51:44 +02:00
|
|
|
|
|
|
|
for (Property p : getCategory( Category ).getValues().values())
|
|
|
|
{
|
|
|
|
int thisInt = p.getInt();
|
|
|
|
|
|
|
|
if ( varID == thisInt )
|
|
|
|
alreadyUsed = true;
|
|
|
|
|
|
|
|
min = Math.max( min, thisInt + 1 );
|
|
|
|
}
|
2014-05-02 07:40:46 +02:00
|
|
|
|
2014-04-06 08:51:44 +02:00
|
|
|
if ( alreadyUsed )
|
|
|
|
{
|
2014-04-28 22:00:53 +02:00
|
|
|
if ( min < 16383 )
|
|
|
|
min = 16383;
|
2014-04-06 08:51:44 +02:00
|
|
|
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
|
|
|
|
return varID;
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|
|
|
|
|
2014-04-06 08:51:44 +02:00
|
|
|
public int getFreeMaterial(int varID)
|
2014-02-09 06:08:27 +01:00
|
|
|
{
|
2014-04-06 08:51:44 +02:00
|
|
|
return getFreeIDSLot( varID, "materials" );
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFreePart(int varID)
|
|
|
|
{
|
|
|
|
return getFreeIDSLot( varID, "parts" );
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager()
|
|
|
|
{
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isFeatureEnabled(AEFeature f)
|
|
|
|
{
|
|
|
|
return featureFlags.contains( f );
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean useTerminalUseLargeFont()
|
|
|
|
{
|
2014-03-17 20:59:50 +01:00
|
|
|
return useLargeFonts;
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|
|
|
|
|
2014-02-16 10:09:20 +01:00
|
|
|
public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
|
|
|
|
{
|
|
|
|
String name = class1.getSimpleName();
|
|
|
|
Property p = get( Category, name, myDefault.name() );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return (Enum) class1.getField( p.toString() ).get( class1 );
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
// :{
|
|
|
|
}
|
|
|
|
|
|
|
|
return myDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSetting(String Category, Enum s)
|
|
|
|
{
|
|
|
|
String name = s.getClass().getSimpleName();
|
|
|
|
get( Category, name, s.name() ).set( s.name() );
|
|
|
|
save();
|
|
|
|
}
|
2014-03-06 06:45:14 +01:00
|
|
|
|
|
|
|
public PowerUnits selectedPowerUnit()
|
|
|
|
{
|
|
|
|
return selectedPowerUnit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void nextPowerUnit(boolean backwards)
|
|
|
|
{
|
|
|
|
selectedPowerUnit = Platform.rotateEnum( selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() );
|
|
|
|
save();
|
|
|
|
}
|
2014-02-09 06:08:27 +01:00
|
|
|
}
|