First shot at starting.

This commit is contained in:
Sebastian Hartte
2020-05-31 17:16:25 +02:00
parent fdd67bbba4
commit 6a88728544
17 changed files with 146 additions and 272 deletions
+37 -23
View File
@@ -26,7 +26,7 @@ import appeng.core.features.AEFeature;
import appeng.core.settings.TickRates;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.google.common.base.Strings;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -34,7 +34,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import org.apache.commons.lang3.tuple.Pair;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -48,6 +47,16 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
public static final ClientConfig CLIENT;
public static final ForgeConfigSpec CLIENT_SPEC;
// Default Grindstone ores
private static final String[] ORES_VANILLA = { "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz" };
private static final String[] ORES_AE = { "CertusQuartz", "Wheat", "Fluix" };
private static final String[] ORES_COMMON = { "Copper", "Tin", "Silver", "Lead", "Bronze" };
private static final String[] ORES_MISC = { "Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc" };
// Default Energy Conversion Rates
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
private static final double DEFAULT_RF_EXCHANGE = 0.5;
static {
final Pair<ClientConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
CLIENT_SPEC = specPair.getRight();
@@ -61,16 +70,6 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
// Config instance
private static AEConfig instance;
// Default Grindstone ores
private static final String[] ORES_VANILLA = { "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz" };
private static final String[] ORES_AE = { "CertusQuartz", "Wheat", "Fluix" };
private static final String[] ORES_COMMON = { "Copper", "Tin", "Silver", "Lead", "Bronze" };
private static final String[] ORES_MISC = { "Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc" };
// Default Energy Conversion Rates
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
private static final double DEFAULT_RF_EXCHANGE = 0.5;
private final IConfigManager settings = new ConfigManager( this );
private final EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
@@ -139,7 +138,10 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
@SubscribeEvent
public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) {
if (configEvent.getConfig().getSpec() == CLIENT_SPEC) {
AEConfig.instance().syncConfig(CLIENT);
if (instance == null) {
instance = new AEConfig();
}
instance.syncConfig(CLIENT);
}
}
@@ -217,11 +219,12 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
for( final TickRates tr : TickRates.values() )
{
tr.Load( this );
tr.setMin(config.tickRateMin.get(tr).get());
tr.setMax(config.tickRateMin.get(tr).get());
}
this.storageProviderID = config.storageProviderID.get();
this.storageDimensionID = config.storageDimensionID.get();
this.storageProviderID = Strings.emptyToNull(config.storageProviderID.get());
this.storageDimensionID = Strings.emptyToNull(config.storageDimensionID.get());
this.spatialPowerMultiplier = config.spatialPowerMultiplier.get();
this.spatialPowerExponent = config.spatialPowerExponent.get();
@@ -341,8 +344,8 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
{
if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
{
CLIENT.storageProviderID.set(this.storageProviderID);
CLIENT.storageDimensionID.set(this.storageDimensionID);
CLIENT.storageProviderID.set(Strings.nullToEmpty(this.storageProviderID));
CLIENT.storageDimensionID.set(Strings.nullToEmpty(this.storageDimensionID));
}
CLIENT.selectedPowerUnit.set(this.selectedPowerUnit);
@@ -431,7 +434,7 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
public void nextPowerUnit( final boolean backwards )
{
this.selectedPowerUnit = Platform.rotateEnum( this.selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() );
// FIXME this.selectedPowerUnit = Platform.rotateEnum( this.selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() );
this.save();
}
@@ -711,6 +714,9 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
public final ConfigValue<Integer> condenserMatterBallsPower;
public final ConfigValue<Integer> condenserSingularityPower;
public final Map<TickRates, ConfigValue<Integer>> tickRateMin = new HashMap<>();
public final Map<TickRates, ConfigValue<Integer>> tickRateMax = new HashMap<>();
public ClientConfig(ForgeConfigSpec.Builder builder) {
// Feature switches
@@ -731,7 +737,7 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
for (AEFeature feature : featuresInGroup)
{
enabledFeatures.put(feature, builder
.comment(feature.comment())
.comment(Strings.nullToEmpty(feature.comment()))
.define(feature.key(), feature.isEnabled()));
}
builder.pop();
@@ -783,8 +789,8 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
builder.pop();
builder.push("spatialio");
this.storageProviderID = builder.define("storageProviderID", (String) null);
this.storageDimensionID = builder.define("storageDimensionID", (String) null);
this.storageProviderID = builder.define("storageProviderID", "");
this.storageDimensionID = builder.define("storageDimensionID", "");
this.spatialPowerMultiplier = builder.define("spatialPowerMultiplier", 1250.0);
this.spatialPowerExponent = builder.define("spatialPowerExponent", 1.35);
builder.pop();
@@ -793,7 +799,7 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
.comment("Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'")
.push("GrindStone");
List<String> defaultGrinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Stream::of ).collect(Collectors.toList());
List<String> defaultGrinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Arrays::stream ).collect(Collectors.toList());
this.grinderOres = builder
.comment("The list of types to handle. Specify without a prefix like ore or dust.")
.defineList("grinderOres", defaultGrinderOres, obj -> true); // FIXME: tag validation, is that even possible???
@@ -849,6 +855,14 @@ public final class AEConfig implements IConfigurableObject, IConfigManagerHost
condenserSingularityPower = builder.define("Singularity", 256000);
builder.pop();
builder
.comment(" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested.")
.push("tickRates");
for (TickRates tickRate : TickRates.values()) {
tickRateMin.put(tickRate, builder.define(tickRate.name() + "Min", tickRate.getDefaultMin()));
tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax()));
}
builder.pop();
}
}
+9 -10
View File
@@ -29,8 +29,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage;
import net.minecraft.util.math.BlockPos;
import appeng.core.features.AEFeature;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public final class AELog
@@ -57,7 +55,8 @@ public final class AELog
*/
private static Logger getLogger()
{
return Platform.isServer() ? SERVER : CLIENT;
// FIXME return Platform.isServer() ? SERVER : CLIENT;
throw new IllegalStateException();
}
/**
@@ -320,13 +319,13 @@ public final class AELog
* @param pos
* @param aeBaseTile
*/
public static void blockUpdate( @Nonnull final BlockPos pos, @Nonnull final AEBaseTile aeBaseTile )
{
if( AEConfig.instance().isFeatureEnabled( AEFeature.UPDATE_LOGGING ) )
{
info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos );
}
}
// FIXME public static void blockUpdate( @Nonnull final BlockPos pos, @Nonnull final AEBaseTile aeBaseTile )
// FIXME {
// FIXME if( AEConfig.instance().isFeatureEnabled( AEFeature.UPDATE_LOGGING ) )
// FIXME {
// FIXME info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos );
// FIXME }
// FIXME }
/**
* Use to check for an enabled crafting log.
+5 -9
View File
@@ -21,17 +21,13 @@ package appeng.core;
import java.io.File;
import appeng.client.ClientHelper;
import appeng.server.ServerHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.CrashReportExtender;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import appeng.core.crash.CrashInfo;
import appeng.core.crash.ModCrashEnhancement;
import appeng.services.export.ExportConfig;
@@ -52,7 +48,7 @@ public final class AppEng
private static AppEng INSTANCE;
private final Registration registration;
//FIXME private final Registration registration;
private File configDirectory;
@@ -69,12 +65,12 @@ public final class AppEng
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
// proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
CrashReportExtender.registerCrashCallable( new ModCrashEnhancement( CrashInfo.MOD_VERSION ) );
CrashReportExtender.registerCrashCallable( new ModCrashEnhancement() );
this.registration = new Registration();
MinecraftForge.EVENT_BUS.register( this.registration );
//FIXMEthis.registration = new Registration();
//FIXMEMinecraftForge.EVENT_BUS.register( this.registration );
}
// @Nonnull
+1 -2
View File
@@ -34,7 +34,6 @@ import appeng.api.parts.CableRenderMode;
import appeng.block.AEBaseBlock;
import appeng.client.ActionKey;
import appeng.client.EffectType;
import appeng.core.sync.AppEngPacket;
public abstract class CommonHelper
@@ -48,7 +47,7 @@ public abstract class CommonHelper
public abstract List<? extends PlayerEntity> getPlayers();
public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet );
// FIXME public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet );
public abstract void spawnEffect( EffectType effect, World world, double posX, double posY, double posZ, Object extra );
@@ -1,47 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.crash;
import net.minecraftforge.fml.common.ICrashCallable;
abstract class BaseCrashEnhancement implements ICrashCallable
{
private final String name;
private final String value;
public BaseCrashEnhancement( final String name, final String value )
{
this.name = name;
this.value = value;
}
@Override
public final String call() throws Exception
{
return this.value;
}
@Override
public final String getLabel()
{
return this.name;
}
}
@@ -1,25 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.crash;
public enum CrashInfo
{
MOD_VERSION, INTEGRATION
}
@@ -1,31 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.crash;
import appeng.integration.IntegrationRegistry;
public class IntegrationCrashEnhancement extends BaseCrashEnhancement
{
public IntegrationCrashEnhancement()
{
super( "AE2 Integration", IntegrationRegistry.INSTANCE.getStatus() );
}
}
@@ -20,18 +20,21 @@ package appeng.core.crash;
import appeng.core.AEConfig;
import net.minecraftforge.fml.common.ICrashCallable;
import net.minecraftforge.versions.forge.ForgeVersion;
public class ModCrashEnhancement extends BaseCrashEnhancement
{
private static final String MOD_VERSION = AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " + // WHAT?
net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
+ net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
+ net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
+ net.minecraftforge.common.ForgeVersion.buildVersion;
public class ModCrashEnhancement implements ICrashCallable {
@Override
public String getLabel() {
return "AE2 Version";
}
@Override
public String call() throws Exception {
return AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " +
ForgeVersion.getVersion();
}
public ModCrashEnhancement( final CrashInfo output )
{
super( "AE2 Version", MOD_VERSION );
}
}
@@ -18,10 +18,6 @@
package appeng.core.settings;
import appeng.core.AEConfig;
public enum TickRates
{
@@ -59,21 +55,25 @@ public enum TickRates
PressureTunnel( 1, 120 );
private final int defaultMin;
private final int defaultMax;
private int min;
private int max;
TickRates( final int min, final int max )
{
this.setMin( min );
this.setMax( max );
this.defaultMin = min;
this.defaultMax = max;
this.min = min;
this.max = max;
}
public void Load( final AEConfig config )
{
config.addCustomCategoryComment( "TickRates",
" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested." );
this.setMin( config.get( "TickRates", this.name() + ".min", this.getMin() ).getInt( this.getMin() ) );
this.setMax( config.get( "TickRates", this.name() + ".max", this.getMax() ).getInt( this.getMax() ) );
public int getDefaultMin() {
return defaultMin;
}
public int getDefaultMax() {
return defaultMax;
}
public int getMax()
@@ -28,7 +28,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.INetHandler;
import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import appeng.core.AEConfig;
import appeng.core.AELog;