2019-09-10 22:51:26 +02:00
package com.simibubi.create ;
import java.nio.file.InvalidPathException ;
import java.nio.file.Paths ;
import org.apache.commons.lang3.tuple.Pair ;
import net.minecraftforge.common.ForgeConfigSpec ;
2019-09-12 10:00:15 +02:00
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue ;
2019-09-10 22:51:26 +02:00
import net.minecraftforge.common.ForgeConfigSpec.Builder ;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue ;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue ;
import net.minecraftforge.common.ForgeConfigSpec.IntValue ;
public class CreateConfig {
public static final ForgeConfigSpec specification ;
public static final CreateConfig parameters ;
static {
final Pair < CreateConfig , ForgeConfigSpec > specPair = new ForgeConfigSpec . Builder ( ) . configure ( CreateConfig : : new ) ;
specification = specPair . getRight ( ) ;
parameters = specPair . getLeft ( ) ;
}
2019-09-12 10:00:15 +02:00
// Modules
public BooleanValue enableSchematics ;
public BooleanValue enableCuriosities ;
public BooleanValue enableContraptions ;
public BooleanValue enablePalettes ;
public BooleanValue enableLogistics ;
public BooleanValue enableGardens ;
// Damage Control
public BooleanValue freezeRotationPropagator ;
public BooleanValue freezeCrushing ;
public BooleanValue freezeInWorldProcessing ;
public BooleanValue freezeRotationConstructs ;
public BooleanValue freezePistonConstructs ;
public BooleanValue freezeExtractors ;
2019-09-10 22:51:26 +02:00
// Schematics
public IntValue maxSchematics , maxTotalSchematicSize , maxSchematicPacketSize , schematicIdleTimeout ;
public IntValue schematicannonDelay , schematicannonSkips ;
public DoubleValue schematicannonGunpowderWorth , schematicannonFuelUsage ;
public ConfigValue < String > schematicPath ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
// Curiosities
public IntValue maxSymmetryWandRange ;
2019-09-24 14:40:01 +02:00
public BooleanValue allowGlassPanesInPartialBlocks ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
// Contraptions
public IntValue maxBeltLength , crushingDamage , maxMotorSpeed , maxRotationSpeed ;
2019-09-12 14:32:11 +02:00
public IntValue fanMaxPushDistance , fanMaxPullDistance , fanBlockCheckRate , fanRotationArgmax , generatingFanSpeed ,
inWorldProcessingTime ;
2019-09-10 22:51:26 +02:00
public IntValue maxChassisForTranslation , maxChassisForRotation , maxChassisRange , maxPistonPoles ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
// Logistics
public IntValue extractorDelay , extractorAmount , linkRange ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
// Gardens
public DoubleValue cocoaLogGrowthSpeed ;
CreateConfig ( final ForgeConfigSpec . Builder builder ) {
2019-09-12 10:00:15 +02:00
initGeneral ( builder ) ;
2019-09-10 22:51:26 +02:00
initContraptions ( builder ) ;
2019-09-14 18:21:30 +02:00
initSchematics ( builder ) ;
2019-09-10 22:51:26 +02:00
initCuriosities ( builder ) ;
initLogistics ( builder ) ;
initGardens ( builder ) ;
}
2019-09-12 10:00:15 +02:00
private void initGeneral ( Builder builder ) {
builder . comment (
" Configure which Modules should be accessible. This only affects Creative Menus and Recipes - any blocks and items already present will not stop working or disappear. " )
. push ( " modules " ) ;
String basePath = " create.config.modules. " ;
String name = " " ;
name = " enableSchematics " ;
enableSchematics = builder . translation ( basePath + name ) . define ( name , true ) ;
name = " enableContraptions " ;
enableContraptions = builder . translation ( basePath + name ) . define ( name , true ) ;
name = " enableCuriosities " ;
enableCuriosities = builder . translation ( basePath + name ) . define ( name , true ) ;
name = " enableGardens " ;
enableGardens = builder . translation ( basePath + name ) . define ( name , true ) ;
name = " enableLogistics " ;
enableLogistics = builder . translation ( basePath + name ) . define ( name , true ) ;
2019-09-12 14:32:11 +02:00
2019-09-12 10:00:15 +02:00
name = " enablePalettes " ;
enablePalettes = builder . translation ( basePath + name ) . define ( name , true ) ;
builder . pop ( ) ;
builder . comment ( " In case of repeated crashing, you can inhibit related game mechanics for Troubleshooting. " )
. push ( " damageControl " ) ;
basePath = " create.config.damageControl. " ;
name = " freezeCrushing " ;
freezeCrushing = builder . comment ( " " , " In case Crushing Wheels crushed your server. " )
. translation ( basePath + name ) . define ( name , false ) ;
name = " freezeExtractors " ;
freezeExtractors = builder . comment ( " " , " In case Extractors pulled the plug. " ) . translation ( basePath + name )
. define ( name , false ) ;
name = " freezeInWorldProcessing " ;
freezeInWorldProcessing = builder . comment ( " " , " In case Encased Fans tried smelting your hardware. " )
. translation ( basePath + name ) . define ( name , false ) ;
name = " freezeRotationPropagator " ;
freezeRotationPropagator = builder
. comment ( " " , " Pauses rotation logic altogether - Use if crash mentions RotationPropagators. " )
. translation ( basePath + name ) . define ( name , false ) ;
name = " freezeRotationConstructs " ;
freezeRotationConstructs = builder . comment ( " " , " In case Mechanical Bearings turned against you. " )
. translation ( basePath + name ) . define ( name , false ) ;
name = " freezePistonConstructs " ;
freezePistonConstructs = builder . comment ( " " , " In case Mechanical Pistons pushed it too far. " )
. translation ( basePath + name ) . define ( name , false ) ;
builder . pop ( ) ;
}
2019-09-10 22:51:26 +02:00
private void initGardens ( Builder builder ) {
builder . comment ( " The Gardens Module " ) . push ( " gardens " ) ;
2019-09-12 10:00:15 +02:00
String basePath = " create.config.gardens. " ;
2019-09-10 22:51:26 +02:00
String name = " " ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " cocoaLogGrowthSpeed " ;
2019-09-12 10:00:15 +02:00
cocoaLogGrowthSpeed = builder . comment ( " " , " % of random Ticks causing a Cocoa log to grow. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 0D , 20D , 100D ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
private void initLogistics ( Builder builder ) {
builder . comment ( " The Logistics Module " ) . push ( " logistics " ) ;
2019-09-12 10:00:15 +02:00
String basePath = " create.config.logistics. " ;
2019-09-10 22:51:26 +02:00
String name = " " ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " extractorDelay " ;
extractorDelay = builder
. comment ( " " , " The amount of game ticks an Extractor waits after pulling an item successfully. " )
. translation ( basePath + name ) . defineInRange ( name , 20 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " extractorAmount " ;
extractorAmount = builder
. comment ( " " , " The amount of items an extractor pulls at a time without an applied filter. " )
. translation ( basePath + name ) . defineInRange ( name , 16 , 1 , 64 ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " linkRange " ;
2019-09-12 10:00:15 +02:00
linkRange = builder . comment ( " " , " Maximum possible range in blocks of redstone link connections. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 128 , 4 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
private void initContraptions ( Builder builder ) {
builder . comment ( " The Contraptions Module " ) . push ( " contraptions " ) ;
2019-09-12 10:00:15 +02:00
String basePath = " create.config.contraptions. " ;
2019-09-10 22:51:26 +02:00
String name = " " ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxBeltLength " ;
2019-09-12 10:00:15 +02:00
maxBeltLength = builder . comment ( " " , " Maximum length in blocks of mechanical belts. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 20 , 5 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " crushingDamage " ;
2019-09-12 10:00:15 +02:00
crushingDamage = builder . comment ( " " , " Damage dealt by active Crushing Wheels. " ) . translation ( basePath + name )
. defineInRange ( name , 4 , 0 , Integer . MAX_VALUE ) ;
2019-09-10 22:51:26 +02:00
{
builder . comment ( " Encased Fan " ) . push ( " encasedFan " ) ;
basePath = " create.config.contraptions.encasedFan " ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " fanBlockCheckRate " ;
fanBlockCheckRate = builder
. comment ( " " , " Game ticks between Fans checking for anything blocking their air flow. " )
. translation ( basePath + name ) . defineInRange ( name , 100 , 20 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " fanMaxPushDistance " ;
2019-09-12 10:00:15 +02:00
fanMaxPushDistance = builder . comment ( " " , " Maximum distance in blocks Fans can push entities. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 20 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " fanMaxPullDistance " ;
2019-09-12 10:00:15 +02:00
fanMaxPullDistance = builder . comment ( " " , " Maximum distance in blocks from where Fans can pull entities. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 5 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " fanRotationArgmax " ;
2019-09-12 10:00:15 +02:00
fanRotationArgmax = builder . comment ( " " , " Rotation speed at which the maximum stats of fans are reached. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 8192 , 64 , Integer . MAX_VALUE ) ;
2019-09-12 14:32:11 +02:00
name = " generatingFanSpeed " ;
generatingFanSpeed = builder . comment ( " " , " Rotation speed generated by a vertical fan above fire. " )
. translation ( basePath + name ) . defineInRange ( name , 32 , 0 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
name = " inWorldProcessingTime " ;
inWorldProcessingTime = builder
. comment ( " " , " Game ticks required for a Fan-based processing recipe to take effect. " )
. translation ( basePath + name ) . defineInRange ( name , 150 , 0 , Integer . MAX_VALUE ) ;
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
{
builder . comment ( " Mechanical Pistons and Bearings " ) . push ( " constructs " ) ;
2019-09-12 10:00:15 +02:00
basePath = " create.config.contraptions.constructs. " ;
2019-09-10 22:51:26 +02:00
name = " maxChassisRange " ;
2019-09-12 10:00:15 +02:00
maxChassisRange = builder . comment ( " " , " Maximum value of a chassis attachment range. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 16 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxChassisForRotation " ;
maxChassisForRotation = builder
. comment ( " " , " Maximum amount of chassis blocks movable by a Mechanical Bearing. " )
. translation ( basePath + name ) . defineInRange ( name , 16 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxChassisForTranslation " ;
maxChassisForTranslation = builder
. comment ( " " , " Maximum amount of chassis blocks movable by a Mechanical Piston. " )
. translation ( basePath + name ) . defineInRange ( name , 16 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxPistonPoles " ;
2019-09-12 10:00:15 +02:00
maxPistonPoles = builder . comment ( " " , " Maximum amount of extension poles behind a Mechanical Piston. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 64 , 1 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxMotorSpeed " ;
2019-09-12 10:00:15 +02:00
maxMotorSpeed = builder . comment ( " " , " Maximum allowed speed of a configurable motor. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 4096 , 64 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxRotationSpeed " ;
2019-09-12 10:00:15 +02:00
maxRotationSpeed = builder . comment ( " " , " Maximum allowed rotation speed for any Kinetic Tile. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 16384 , 64 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
private void initCuriosities ( Builder builder ) {
builder . comment ( " The Curiosities Module " ) . push ( " curiosities " ) ;
2019-09-12 10:00:15 +02:00
String basePath = " create.config.curiosities. " ;
2019-09-10 22:51:26 +02:00
String name = " " ;
2019-09-12 10:00:15 +02:00
2019-09-10 22:51:26 +02:00
name = " maxSymmetryWandRange " ;
maxSymmetryWandRange = builder
. comment ( " " , " The Maximum Distance to an active mirror for the symmetry wand to trigger. " )
. translation ( basePath + name ) . defineInRange ( name , 50 , 10 , Integer . MAX_VALUE ) ;
2019-09-12 10:00:15 +02:00
2019-09-24 14:40:01 +02:00
name = " allowGlassPanesInPartialBlocks " ;
allowGlassPanesInPartialBlocks = builder . comment ( " " , " Allow Glass Panes to be put inside Blocks like Stairs, Slabs, Fences etc. " )
. translation ( basePath + name ) . define ( name , true ) ;
2019-09-10 22:51:26 +02:00
builder . pop ( ) ;
}
2019-09-14 18:21:30 +02:00
private void initSchematics ( final ForgeConfigSpec . Builder builder ) {
2019-09-10 22:51:26 +02:00
builder . comment ( " The Schematics Module " ) . push ( " schematics " ) ;
2019-09-12 10:00:15 +02:00
String basePath = " create.config.schematics. " ;
2019-09-10 22:51:26 +02:00
String name = " " ;
name = " maxSchematics " ;
maxSchematics = builder
. comment ( " " , " The amount of Schematics a player can upload until previous ones are overwritten. " )
. translation ( basePath + name ) . defineInRange ( name , 10 , 1 , Integer . MAX_VALUE ) ;
name = " schematicPath " ;
schematicPath = builder . comment ( " " , " The file location where uploaded Schematics are stored. " ) . define ( name ,
" schematics/uploaded " , this : : isValidPath ) ;
name = " maxTotalSchematicSize " ;
maxTotalSchematicSize = builder
. comment ( " " , " [in KiloBytes] " , " The maximum allowed file size of uploaded Schematics. " )
. translation ( basePath + name ) . defineInRange ( name , 256 , 16 , Integer . MAX_VALUE ) ;
name = " maxSchematicPacketSize " ;
maxSchematicPacketSize = builder
. comment ( " " , " [in Bytes] " , " The maximum packet size uploaded Schematics are split into. " )
. translation ( basePath + name ) . defineInRange ( name , 1024 , 256 , 32767 ) ;
name = " schematicIdleTimeout " ;
schematicIdleTimeout = builder . comment ( " " ,
" Amount of game ticks without new packets arriving until an active schematic upload process is discarded. " )
. translation ( basePath + name ) . defineInRange ( name , 600 , 100 , Integer . MAX_VALUE ) ;
{
builder . comment ( " Schematicannon " ) . push ( " schematicannon " ) ;
basePath = " create.config.schematics.schematicannon " ;
name = " schematicannonDelay " ;
2019-09-12 10:00:15 +02:00
schematicannonDelay = builder
. comment ( " " , " Amount of game ticks between shots of the cannon. Higher => Slower " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 10 , 1 , Integer . MAX_VALUE ) ;
name = " schematicannonSkips " ;
2019-09-12 10:00:15 +02:00
schematicannonSkips = builder
. comment ( " " , " Amount of block positions per tick scanned by a running cannon. Higher => Faster " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 10 , 1 , Integer . MAX_VALUE ) ;
name = " schematicannonGunpowderWorth " ;
2019-09-12 10:00:15 +02:00
schematicannonGunpowderWorth = builder . comment ( " " , " % of Schematicannon's Fuel filled by 1 Gunpowder. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 20D , 0D , 100D ) ;
name = " schematicannonFuelUsage " ;
2019-09-12 10:00:15 +02:00
schematicannonFuelUsage = builder . comment ( " " , " % of Schematicannon's Fuel used for each fired block. " )
2019-09-10 22:51:26 +02:00
. translation ( basePath + name ) . defineInRange ( name , 0 . 05D , 0D , 100D ) ;
builder . pop ( ) ;
}
builder . pop ( ) ;
}
private boolean isValidPath ( Object path ) {
if ( ! ( path instanceof String ) )
return false ;
try {
Paths . get ( ( String ) path ) ;
return true ;
} catch ( InvalidPathException e ) {
return false ;
}
}
}