Refactored AEConfig (#2633)

Added a singleton getter instead the public field.
Reduced all fields to private.
Replaced field access with getters.
Added setters where necessary (Dimension/Biome Registration)
Added config options to disable more features.
Splitted Enum name from the config key.
Changed FacadeConfig and Networkhandler similar to AEConfig.init().
This commit is contained in:
yueh
2016-11-26 14:07:34 +01:00
committed by GitHub
parent 6554e295d5
commit a665200c31
105 changed files with 1022 additions and 645 deletions
@@ -172,10 +172,10 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
for( final AEFeature f : mat.getFeature() )
{
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
enabled = enabled && AEConfig.instance().isFeatureEnabled( f );
}
mat.setStackSrc( new MaterialStackSrc( mat ) );
mat.setStackSrc( new MaterialStackSrc( mat, enabled ) );
if( enabled )
{
@@ -228,7 +228,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
}
}
if( replacement == null || AEConfig.instance.useAEVersion( mt ) )
if( replacement == null || AEConfig.instance().useAEVersion( mt ) )
{
// continue using the AE2 item.
for( final String name : names )
@@ -339,7 +339,8 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
try
{
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX, location.posY, location.posZ, itemstack );
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX,
location.posY, location.posZ, itemstack );
}
catch( final Throwable t )
{
@@ -20,6 +20,7 @@ package appeng.items.materials;
import java.util.EnumSet;
import java.util.Set;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
@@ -38,85 +39,85 @@ import appeng.entity.EntitySingularity;
public enum MaterialType
{
InvalidType( -1, "material_invalid_type", AEFeature.Core ),
InvalidType( -1, "material_invalid_type" ),
CertusQuartzCrystal( 0, "material_certus_quartz_crystal", AEFeature.Core, "crystalCertusQuartz" ),
CertusQuartzCrystalCharged( 1, "material_certus_quartz_crystal_charged", AEFeature.Core, EntityChargedQuartz.class ),
CertusQuartzCrystal( 0, "material_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS ), "crystalCertusQuartz" ),
CertusQuartzCrystalCharged( 1, "material_certus_quartz_crystal_charged", EnumSet.of( AEFeature.CERTUS ), EntityChargedQuartz.class ),
CertusQuartzDust( 2, "material_certus_quartz_dust", AEFeature.Core, "dustCertusQuartz" ),
NetherQuartzDust( 3, "material_nether_quartz_dust", AEFeature.Core, "dustNetherQuartz" ),
Flour( 4, "material_flour", AEFeature.Flour, "dustWheat" ),
GoldDust( 51, "material_gold_dust", AEFeature.Core, "dustGold" ),
IronDust( 49, "material_iron_dust", AEFeature.Core, "dustIron" ),
IronNugget( 50, "material_iron_nugget", AEFeature.Core, "nuggetIron" ),
CertusQuartzDust( 2, "material_certus_quartz_dust", EnumSet.of( AEFeature.DUSTS, AEFeature.CERTUS ), "dustCertusQuartz" ),
NetherQuartzDust( 3, "material_nether_quartz_dust", EnumSet.of( AEFeature.DUSTS ), "dustNetherQuartz" ),
Flour( 4, "material_flour", EnumSet.of( AEFeature.FLOUR ), "dustWheat" ),
GoldDust( 51, "material_gold_dust", EnumSet.of( AEFeature.DUSTS ), "dustGold" ),
IronDust( 49, "material_iron_dust", EnumSet.of( AEFeature.DUSTS ), "dustIron" ),
IronNugget( 50, "material_iron_nugget", EnumSet.of( AEFeature.NUGGETS ), "nuggetIron" ),
Silicon( 5, "material_silicon", AEFeature.Core, "itemSilicon" ),
MatterBall( 6, "material_matter_ball" ),
Silicon( 5, "material_silicon", EnumSet.of( AEFeature.SILICON ), "itemSilicon" ),
MatterBall( 6, "material_matter_ball", EnumSet.of( AEFeature.MATTER_BALL ) ),
FluixCrystal( 7, "material_fluix_crystal", AEFeature.Core, "crystalFluix" ),
FluixDust( 8, "material_fluix_dust", AEFeature.Core, "dustFluix" ),
FluixPearl( 9, "material_fluix_pearl", AEFeature.Core, "pearlFluix" ),
FluixCrystal( 7, "material_fluix_crystal", EnumSet.of( AEFeature.FLUIX ), "crystalFluix" ),
FluixDust( 8, "material_fluix_dust", EnumSet.of( AEFeature.FLUIX, AEFeature.DUSTS ), "dustFluix" ),
FluixPearl( 9, "material_fluix_pearl", EnumSet.of( AEFeature.FLUIX ), "pearlFluix" ),
PurifiedCertusQuartzCrystal( 10, "material_purified_certus_quartz_crystal" ),
PurifiedNetherQuartzCrystal( 11, "material_purified_nether_quartz_crystal" ),
PurifiedFluixCrystal( 12, "material_purified_fluix_crystal" ),
PurifiedCertusQuartzCrystal( 10, "material_purified_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS, AEFeature.PURE_CRYSTALS ) ),
PurifiedNetherQuartzCrystal( 11, "material_purified_nether_quartz_crystal", EnumSet.of( AEFeature.PURE_CRYSTALS ) ),
PurifiedFluixCrystal( 12, "material_purified_fluix_crystal", EnumSet.of( AEFeature.FLUIX, AEFeature.PURE_CRYSTALS ) ),
CalcProcessorPress( 13, "material_calc_processor_press" ),
EngProcessorPress( 14, "material_eng_processor_press" ),
LogicProcessorPress( 15, "material_logic_processor_press" ),
CalcProcessorPress( 13, "material_calc_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
EngProcessorPress( 14, "material_eng_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
LogicProcessorPress( 15, "material_logic_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
CalcProcessorPrint( 16, "material_calc_processor_print" ),
EngProcessorPrint( 17, "material_eng_processor_print" ),
LogicProcessorPrint( 18, "material_logic_processor_print" ),
CalcProcessorPrint( 16, "material_calc_processor_print", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
EngProcessorPrint( 17, "material_eng_processor_print", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
LogicProcessorPrint( 18, "material_logic_processor_print", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
SiliconPress( 19, "material_silicon_press" ),
SiliconPrint( 20, "material_silicon_print" ),
SiliconPress( 19, "material_silicon_press", EnumSet.of( AEFeature.PRESSES ) ),
SiliconPrint( 20, "material_silicon_print", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
NamePress( 21, "material_name_press" ),
NamePress( 21, "material_name_press", EnumSet.of( AEFeature.PRESSES ) ),
LogicProcessor( 22, "material_logic_processor" ),
CalcProcessor( 23, "material_calc_processor" ),
EngProcessor( 24, "material_eng_processor" ),
LogicProcessor( 22, "material_logic_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
CalcProcessor( 23, "material_calc_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
EngProcessor( 24, "material_eng_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
// Basic Cards
BasicCard( 25, "material_basic_card" ),
CardRedstone( 26, "material_card_redstone" ),
CardCapacity( 27, "material_card_capacity" ),
BasicCard( 25, "material_basic_card", EnumSet.of( AEFeature.BASIC_CARDS ) ),
CardRedstone( 26, "material_card_redstone", EnumSet.of( AEFeature.BASIC_CARDS ) ),
CardCapacity( 27, "material_card_capacity", EnumSet.of( AEFeature.BASIC_CARDS ) ),
// Adv Cards
AdvCard( 28, "material_adv_card" ),
CardFuzzy( 29, "material_card_fuzzy" ),
CardSpeed( 30, "material_card_speed" ),
CardInverter( 31, "material_card_inverter" ),
AdvCard( 28, "material_adv_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
CardFuzzy( 29, "material_card_fuzzy", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
CardSpeed( 30, "material_card_speed", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
CardInverter( 31, "material_card_inverter", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
Cell2SpatialPart( 32, "material_cell2_spatial_part", AEFeature.SpatialIO ),
Cell16SpatialPart( 33, "material_cell16_spatial_part", AEFeature.SpatialIO ),
Cell128SpatialPart( 34, "material_cell128_spatial_part", AEFeature.SpatialIO ),
Cell2SpatialPart( 32, "material_cell2_spatial_part", EnumSet.of( AEFeature.SPATIAL_IO ) ),
Cell16SpatialPart( 33, "material_cell16_spatial_part", EnumSet.of( AEFeature.SPATIAL_IO ) ),
Cell128SpatialPart( 34, "material_cell128_spatial_part", EnumSet.of( AEFeature.SPATIAL_IO ) ),
Cell1kPart( 35, "material_cell1k_part", AEFeature.StorageCells ),
Cell4kPart( 36, "material_cell4k_part", AEFeature.StorageCells ),
Cell16kPart( 37, "material_cell16k_part", AEFeature.StorageCells ),
Cell64kPart( 38, "material_cell64k_part", AEFeature.StorageCells ),
EmptyStorageCell( 39, "material_empty_storage_cell", AEFeature.StorageCells ),
Cell1kPart( 35, "material_cell1k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
Cell4kPart( 36, "material_cell4k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
Cell16kPart( 37, "material_cell16k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
Cell64kPart( 38, "material_cell64k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
EmptyStorageCell( 39, "material_empty_storage_cell", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
WoodenGear( 40, "material_wooden_gear", AEFeature.GrindStone, "gearWood" ),
WoodenGear( 40, "material_wooden_gear", EnumSet.of( AEFeature.GRIND_STONE ), "gearWood" ),
Wireless( 41, "material_wireless", AEFeature.WirelessAccessTerminal ),
WirelessBooster( 42, "material_wireless_booster", AEFeature.WirelessAccessTerminal ),
Wireless( 41, "material_wireless", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ),
WirelessBooster( 42, "material_wireless_booster", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ),
FormationCore( 43, "material_formation_core" ),
AnnihilationCore( 44, "material_annihilation_core" ),
FormationCore( 43, "material_formation_core", EnumSet.of( AEFeature.CORES ) ),
AnnihilationCore( 44, "material_annihilation_core", EnumSet.of( AEFeature.CORES ) ),
SkyDust( 45, "material_sky_dust", AEFeature.Core ),
SkyDust( 45, "material_sky_dust", EnumSet.of( AEFeature.DUSTS ) ),
EnderDust( 46, "material_ender_dust", AEFeature.QuantumNetworkBridge, "dustEnder,dustEnderPearl", EntitySingularity.class ),
Singularity( 47, "material_singularity", AEFeature.QuantumNetworkBridge, EntitySingularity.class ),
QESingularity( 48, "material_qesingularity", AEFeature.QuantumNetworkBridge, EntitySingularity.class ),
EnderDust( 46, "material_ender_dust", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), "dustEnder,dustEnderPearl", EntitySingularity.class ),
Singularity( 47, "material_singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ),
QESingularity( 48, "material_qesingularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ),
BlankPattern( 52, "material_blank_pattern" ),
CardCrafting( 53, "material_card_crafting" );
BlankPattern( 52, "material_blank_pattern", EnumSet.of( AEFeature.PATTERNS ) ),
CardCrafting( 53, "material_card_crafting", EnumSet.of( AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU ) );
private final EnumSet<AEFeature> features;
private final Set<AEFeature> features;
private final ModelResourceLocation model;
private Item itemInstance;
private int damageValue;
@@ -128,35 +129,37 @@ public enum MaterialType
MaterialType( final int metaValue, String modelName )
{
this( metaValue, modelName, AEFeature.Core );
this( metaValue, modelName, EnumSet.of( AEFeature.CORE ) );
}
MaterialType( final int metaValue, String modelName, final AEFeature part )
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features )
{
this.setDamageValue( metaValue );
this.features = EnumSet.of( part );
this.features = features;
this.model = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, modelName ), "inventory" );
}
MaterialType( final int metaValue, String modelName, final AEFeature part, final Class<? extends Entity> c )
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final Class<? extends Entity> c )
{
this( metaValue, modelName, part );
this( metaValue, modelName, features );
this.droppedEntity = c;
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4, true );
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4,
true );
}
MaterialType( final int metaValue, String modelName, final AEFeature part, final String oreDictionary, final Class<? extends Entity> c )
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary, final Class<? extends Entity> c )
{
this( metaValue, modelName, part );
this( metaValue, modelName, features );
this.oreName = oreDictionary;
this.droppedEntity = c;
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4, true );
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4,
true );
}
MaterialType( final int metaValue, String modelName, final AEFeature part, final String oreDictionary )
MaterialType( final int metaValue, String modelName, final Set<AEFeature> features, final String oreDictionary )
{
this( metaValue, modelName, part );
this( metaValue, modelName, features );
this.oreName = oreDictionary;
}
@@ -165,7 +168,7 @@ public enum MaterialType
return new ItemStack( this.getItemInstance(), size, this.getDamageValue() );
}
EnumSet<AEFeature> getFeature()
Set<AEFeature> getFeature()
{
return this.features;
}
@@ -225,7 +228,8 @@ public enum MaterialType
this.stackSrc = stackSrc;
}
public ModelResourceLocation getModel() {
public ModelResourceLocation getModel()
{
return model;
}