diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index e3b843adb..dfbc45751 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -71,7 +71,7 @@ import com.simibubi.create.modules.palettes.GlassPaneBlock; import com.simibubi.create.modules.palettes.HorizontalCTGlassBlock; import com.simibubi.create.modules.palettes.LayeredCTBlock; import com.simibubi.create.modules.palettes.VerticalCTGlassBlock; -import com.simibubi.create.modules.palettes.VolcanicRockBlock; +import com.simibubi.create.modules.palettes.ScoriaBlock; import com.simibubi.create.modules.schematics.block.CreativeCrateBlock; import com.simibubi.create.modules.schematics.block.SchematicTableBlock; import com.simibubi.create.modules.schematics.block.SchematicannonBlock; @@ -248,7 +248,7 @@ public enum AllBlocks { DOLOMITE_LAYERS( new LayeredCTBlock(Properties.from(DOLOMITE.block), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)), - VOLCANIC_ROCK(new VolcanicRockBlock()), + SCORIA(new ScoriaBlock()), __MATERIALS__(), COPPER_ORE(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)), diff --git a/src/main/java/com/simibubi/create/ClientEvents.java b/src/main/java/com/simibubi/create/ClientEvents.java index ace18d2e0..c2ecd4a6b 100644 --- a/src/main/java/com/simibubi/create/ClientEvents.java +++ b/src/main/java/com/simibubi/create/ClientEvents.java @@ -3,6 +3,7 @@ package com.simibubi.create; import java.util.ArrayList; import java.util.List; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.filtering.FilteringHandler; import com.simibubi.create.foundation.block.IHaveScrollableValue; import com.simibubi.create.foundation.gui.ScreenOpener; @@ -119,7 +120,7 @@ public class ClientEvents { @SubscribeEvent public static void addToItemTooltip(ItemTooltipEvent event) { - if (!CreateClientConfig.instance.enableTooltips.get()) + if (!AllConfigs.CLIENT.tooltips.get()) return; ItemStack stack = event.getItemStack(); diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 2df6af46f..2600b35fe 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -3,9 +3,9 @@ package com.simibubi.create; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.command.CreateCommand; import com.simibubi.create.foundation.command.ServerLagger; -import com.simibubi.create.foundation.world.OreGeneration; import com.simibubi.create.modules.ModuleLoadedCondition; import com.simibubi.create.modules.contraptions.TorquePropagator; import com.simibubi.create.modules.logistics.RedstoneLinkNetworkHandler; @@ -22,9 +22,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -43,8 +41,6 @@ public class Create { public static TorquePropagator torquePropagator; public static ServerLagger lagger; - public static ModConfig config; - public Create() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(Create::init); @@ -59,12 +55,10 @@ public class Create { modEventBus.addGenericListener(EntityType.class, AllEntities::register); modEventBus.addGenericListener(ParticleType.class, AllParticles::register); - modEventBus.addListener(Create::createConfigs); + AllConfigs.registerAll(); + modEventBus.addListener(AllConfigs::onLoad); + modEventBus.addListener(AllConfigs::onReload); CreateClient.addListeners(modEventBus); - OreGeneration.setupOreGeneration(); - - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CreateConfig.specification); - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CreateClientConfig.specification); } public static void init(final FMLCommonSetupEvent event) { @@ -77,15 +71,10 @@ public class Create { AllPackets.registerPackets(); } - public static void serverStarting(FMLServerStartingEvent event){ + public static void serverStarting(FMLServerStartingEvent event) { new CreateCommand(event.getCommandDispatcher()); } - public static void createConfigs(ModConfig.ModConfigEvent event) { - if (event.getConfig().getSpec() == CreateConfig.specification) - config = event.getConfig(); - } - public static void tick() { if (schematicReceiver == null) schematicReceiver = new ServerSchematicLoader(); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 39544be33..e75f16efc 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -33,7 +33,6 @@ import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateClient { @@ -45,12 +44,9 @@ public class CreateClient { public static SuperByteBufferCache bufferCache; public static int renderTicks; - public static ModConfig config; - public static void addListeners(IEventBus modEventBus) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { modEventBus.addListener(CreateClient::clientInit); - modEventBus.addListener(CreateClient::createConfigs); modEventBus.addListener(CreateClient::onModelBake); modEventBus.addListener(CreateClient::onModelRegistry); modEventBus.addListener(CreateClient::onTextureStitch); @@ -80,13 +76,6 @@ public class CreateClient { ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); } - public static void createConfigs(ModConfig.ModConfigEvent event) { - if (event.getConfig().getSpec() == CreateConfig.specification) - return; - - config = event.getConfig(); - } - public static void gameTick() { schematicSender.tick(); schematicAndQuillHandler.tick(); diff --git a/src/main/java/com/simibubi/create/CreateClientConfig.java b/src/main/java/com/simibubi/create/CreateClientConfig.java deleted file mode 100644 index fdf01dad5..000000000 --- a/src/main/java/com/simibubi/create/CreateClientConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.simibubi.create; - -import org.apache.commons.lang3.tuple.Pair; - -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; - -public class CreateClientConfig { - - public static final ForgeConfigSpec specification; - public static final CreateClientConfig instance; - - static { - final Pair specPair = new ForgeConfigSpec.Builder() - .configure(CreateClientConfig::new); - - specification = specPair.getRight(); - instance = specPair.getLeft(); - } - - public BooleanValue enableTooltips; - public DoubleValue fanParticleDensity; - public BooleanValue enableRainbowDebug; - - CreateClientConfig(final ForgeConfigSpec.Builder builder) { - builder.comment( - "Client-only settings - If you're looking for server/common settings, look inside your worlds serverconfig folder!") - .push("client"); - String basePath = "create.config.client."; - - String name = "enableTooltips"; - enableTooltips = builder.comment("", "Show item descriptions on Shift and controls on Ctrl.") - .translation(basePath + name).define(name, true); - - name = "fanParticleDensity"; - fanParticleDensity = builder.comment("", "Controls the average amount of fan particles spawned per tick.") - .translation(basePath + name).defineInRange(name, .5D, 0D, 1D); - - name = "enableRainbowDebug"; - enableRainbowDebug = builder.comment("", "Show colorful debug information while the F3-Menu is open.") - .translation(basePath + name).define(name, true); - - - builder.pop(); - } - -} diff --git a/src/main/java/com/simibubi/create/CreateConfig.java b/src/main/java/com/simibubi/create/CreateConfig.java deleted file mode 100644 index 27220f3e0..000000000 --- a/src/main/java/com/simibubi/create/CreateConfig.java +++ /dev/null @@ -1,442 +0,0 @@ -package com.simibubi.create; - -import java.nio.file.InvalidPathException; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang3.tuple.Pair; - -import com.simibubi.create.modules.contraptions.base.KineticBlock; - -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -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 specPair = new ForgeConfigSpec.Builder().configure(CreateConfig::new); - - specification = specPair.getRight(); - parameters = specPair.getLeft(); - } - - // Modules - public BooleanValue enableSchematics; - public BooleanValue enableCuriosities; - public BooleanValue enableContraptions; - public BooleanValue enablePalettes; - public BooleanValue enableLogistics; - - // Damage Control - public BooleanValue freezeRotationPropagator; - public BooleanValue freezeCrushing; - public BooleanValue freezeInWorldProcessing; - public BooleanValue freezeRotationConstructs; - public BooleanValue freezePistonConstructs; - public BooleanValue freezeExtractors; - - // Schematics - public IntValue maxSchematics, maxTotalSchematicSize, maxSchematicPacketSize, schematicIdleTimeout; - public IntValue schematicannonDelay, schematicannonSkips; - public DoubleValue schematicannonGunpowderWorth, schematicannonFuelUsage; - public ConfigValue schematicPath; - - // Curiosities - public IntValue maxSymmetryWandRange; - public BooleanValue allowGlassPanesInPartialBlocks; - public IntValue lightSourceCountForRefinedRadiance; - public BooleanValue enableRefinedRadianceRecipe; - public BooleanValue enableShadowSteelRecipe; - public BooleanValue enableSandPaperToolPolishing; - - // Contraptions - public IntValue maxBeltLength, crushingDamage, maxMotorSpeed, maxRotationSpeed; - public IntValue fanPushDistance, fanPullDistance, fanBlockCheckRate, fanRotationArgmax, generatingFanSpeed, - inWorldProcessingTime; - public IntValue maxChassisForTranslation, maxChassisForRotation, maxChassisRange, maxPistonPoles; - - public Map stressCapacityEntries = new HashMap<>(); - public Map stressEntries = new HashMap<>(); - - public DoubleValue mediumSpeed, fastSpeed; - public DoubleValue mediumStressImpact, highStressImpact; - public DoubleValue mediumCapacity, highCapacity; - - // Logistics - public IntValue extractorDelay, extractorInventoryScanDelay, extractorAmount, linkRange; - - // Gardens - public DoubleValue cocoaLogGrowthSpeed; - - CreateConfig(final ForgeConfigSpec.Builder builder) { - initGeneral(builder); - initContraptions(builder); - initSchematics(builder); - initCuriosities(builder); - initLogistics(builder); - initGardens(builder); - } - - 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 = "enableLogistics"; - enableLogistics = builder.translation(basePath + name).define(name, true); - - 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(); - } - - private void initGardens(Builder builder) { - builder.comment("The Gardens Module").push("gardens"); - String basePath = "create.config.gardens."; - String name = ""; - - name = "cocoaLogGrowthSpeed"; - cocoaLogGrowthSpeed = builder.comment("", "% of random Ticks causing a Cocoa log to grow.") - .translation(basePath + name).defineInRange(name, 20D, 0D, 100D); - - builder.pop(); - } - - private void initLogistics(Builder builder) { - builder.comment("The Logistics Module").push("logistics"); - String basePath = "create.config.logistics."; - String name = ""; - - 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); - - name = "extractorInventoryScanDelay"; - extractorInventoryScanDelay = builder.comment("", - "The amount of game ticks an Extractor waits before checking again if the attached inventory contains items to extract.") - .translation(basePath + name).defineInRange(name, 40, 1, Integer.MAX_VALUE); - - 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); - - name = "linkRange"; - linkRange = builder.comment("", "Maximum possible range in blocks of redstone link connections.") - .translation(basePath + name).defineInRange(name, 128, 4, Integer.MAX_VALUE); - - builder.pop(); - } - - private void initContraptions(Builder builder) { - builder.comment("The Contraptions Module").push("contraptions"); - String basePath = "create.config.contraptions."; - String name = ""; - - name = "maxBeltLength"; - maxBeltLength = builder.comment("", "Maximum length in blocks of mechanical belts.") - .translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE); - - name = "crushingDamage"; - crushingDamage = builder.comment("", "Damage dealt by active Crushing Wheels.").translation(basePath + name) - .defineInRange(name, 4, 0, Integer.MAX_VALUE); - - { - builder.comment("Encased Fan").push("encasedFan"); - basePath = "create.config.contraptions.encasedFan"; - - name = "fanBlockCheckRate"; - fanBlockCheckRate = builder - .comment("", "Game ticks between Fans checking for anything blocking their air flow.") - .translation(basePath + name).defineInRange(name, 30, 10, Integer.MAX_VALUE); - - name = "fanPushDistance"; - fanPushDistance = builder.comment("", "Maximum distance in blocks Fans can push entities.") - .translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE); - - name = "fanPullDistance"; - fanPullDistance = builder.comment("", "Maximum distance in blocks from where Fans can pull entities.") - .translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE); - - name = "fanRotationArgmax"; - fanRotationArgmax = builder.comment("", "Rotation speed at which the maximum stats of fans are reached.") - .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); - - name = "generatingFanSpeed"; - generatingFanSpeed = builder.comment("", "Rotation speed generated by a vertical fan above fire.") - .translation(basePath + name).defineInRange(name, 16, 0, Integer.MAX_VALUE); - - 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); - - builder.pop(); - } - - { - builder.comment("Mechanical Pistons and Bearings").push("constructs"); - basePath = "create.config.contraptions.constructs."; - - name = "maxChassisRange"; - maxChassisRange = builder.comment("", "Maximum value of a chassis attachment range.") - .translation(basePath + name).defineInRange(name, 16, 1, Integer.MAX_VALUE); - - 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); - - 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); - - name = "maxPistonPoles"; - maxPistonPoles = builder.comment("", "Maximum amount of extension poles behind a Mechanical Piston.") - .translation(basePath + name).defineInRange(name, 64, 1, Integer.MAX_VALUE); - - initStress(builder); - - builder.pop(); - } - - name = "maxMotorSpeed"; - maxMotorSpeed = builder.comment("", "Maximum allowed speed of a configurable motor.") - .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); - - name = "maxRotationSpeed"; - maxRotationSpeed = builder.comment("", "Maximum allowed rotation speed for any Kinetic Tile.") - .translation(basePath + name).defineInRange(name, 256, 64, Integer.MAX_VALUE); - - builder.pop(); - } - - private void initCuriosities(Builder builder) { - builder.comment("The Curiosities Module").push("curiosities"); - String basePath = "create.config.curiosities."; - String name = ""; - - 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); - - name = "allowGlassPanesInPartialBlocks"; - allowGlassPanesInPartialBlocks = builder - .comment("", "Allow Glass Panes to be put inside Blocks like Stairs, Slabs, Fences etc.") - .translation(basePath + name).define(name, true); - - name = "enableShadowSteelRecipe"; - enableShadowSteelRecipe = builder - .comment("", "Allow the standard Shadow Steel recipe.") - .translation(basePath + name).define(name, true); - - name = "enableRefinedRadianceRecipe"; - enableRefinedRadianceRecipe = builder - .comment("", "Allow the standard Refined Radiance recipes.") - .translation(basePath + name).define(name, true); - - name = "lightSourceCountForRefinedRadiance"; - lightSourceCountForRefinedRadiance = builder - .comment("", "The amount of Light sources destroyed before Chromatic Compound turns into Refined Radiance.") - .translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE); - - name = "enableSandPaperToolPolishing"; - enableSandPaperToolPolishing = builder - .comment("", "Enable the tool repairing mechanic involving sand paper.") - .translation(basePath + name).define(name, true); - - builder.pop(); - } - - private void initSchematics(final ForgeConfigSpec.Builder builder) { - builder.comment("The Schematics Module").push("schematics"); - String basePath = "create.config.schematics."; - 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"; - schematicannonDelay = builder - .comment("", "Amount of game ticks between shots of the cannon. Higher => Slower") - .translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE); - - name = "schematicannonSkips"; - schematicannonSkips = builder - .comment("", "Amount of block positions per tick scanned by a running cannon. Higher => Faster") - .translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE); - - name = "schematicannonGunpowderWorth"; - schematicannonGunpowderWorth = builder.comment("", "% of Schematicannon's Fuel filled by 1 Gunpowder.") - .translation(basePath + name).defineInRange(name, 20D, 0D, 100D); - - name = "schematicannonFuelUsage"; - schematicannonFuelUsage = builder.comment("", "% of Schematicannon's Fuel used for each fired block.") - .translation(basePath + name).defineInRange(name, 0.05D, 0D, 100D); - builder.pop(); - } - - builder.pop(); - } - - private void initStress(final ForgeConfigSpec.Builder builder) { - builder.comment("Configure speed/capacity levels for requirements and indicators.").push("rotationLevels"); - String basePath = "create.config.rotationLevels."; - String name = ""; - - name = "mediumSpeed"; - mediumSpeed = builder.comment("", "[in Degrees/Tick]", "Minimum speed of rotation to be considered 'medium'") - .translation(basePath + name).defineInRange(name, 30D, 0D, 4096D); - - name = "fastSpeed"; - fastSpeed = builder.comment("", "[in Degrees/Tick]", "Minimum speed of rotation to be considered 'fast'") - .translation(basePath + name).defineInRange(name, 100D, 0D, 65535D); - - name = "mediumStressImpact"; - mediumStressImpact = builder.comment("", "Minimum stress impact to be considered 'medium'") - .translation(basePath + name).defineInRange(name, 8D, 0D, 4096D); - - name = "highStressImpact"; - highStressImpact = builder.comment("", "Minimum stress impact to be considered 'high'") - .translation(basePath + name).defineInRange(name, 32D, 0D, 65535D); - - name = "mediumCapacity"; - mediumCapacity = builder.comment("", "Minimum added Capacity by sources to be considered 'medium'") - .translation(basePath + name).defineInRange(name, 128D, 0D, 4096D); - - name = "highCapacity"; - highCapacity = builder.comment("", "Minimum added Capacity by sources to be considered 'high'") - .translation(basePath + name).defineInRange(name, 512D, 0D, 65535D); - - builder.pop(); - - builder.comment( - "Configure the individual stress impact of mechanical blocks. Note that this cost is doubled for every speed increase it receives.") - .push("stress"); - - for (AllBlocks block : AllBlocks.values()) { - if (block.get() instanceof KineticBlock) - initStressEntry(block, builder); - } - - builder.pop(); - - builder.comment("Configure how much stress a source can accommodate.").push("capacity"); - - for (AllBlocks block : AllBlocks.values()) { - if (block.get() instanceof KineticBlock) - initStressCapacityEntry(block, builder); - } - - builder.pop(); - - } - - private void initStressEntry(AllBlocks block, final ForgeConfigSpec.Builder builder) { - String basePath = "create.config.stress."; - String name = block.name(); - stressEntries.put(block.get().getRegistryName(), builder.comment("").translation(basePath + name) - .defineInRange(name, StressConfigDefaults.getDefaultStressImpact(block), 0, 2048)); - } - - private void initStressCapacityEntry(AllBlocks block, final ForgeConfigSpec.Builder builder) { - double defaultStressCapacity = StressConfigDefaults.getDefaultStressCapacity(block); - if (defaultStressCapacity == -1) - return; - String basePath = "create.config.stressCapacity."; - String name = block.name(); - stressCapacityEntries.put(block.get().getRegistryName(), - builder.comment("").translation(basePath + name).defineInRange(name, defaultStressCapacity, 0, 4096D)); - } - - private boolean isValidPath(Object path) { - if (!(path instanceof String)) - return false; - try { - Paths.get((String) path); - return true; - } catch (InvalidPathException e) { - return false; - } - } - -} diff --git a/src/main/java/com/simibubi/create/Events.java b/src/main/java/com/simibubi/create/Events.java index 886345fe9..cc7de9bac 100644 --- a/src/main/java/com/simibubi/create/Events.java +++ b/src/main/java/com/simibubi/create/Events.java @@ -2,6 +2,7 @@ package com.simibubi.create; import java.util.Arrays; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity; import net.minecraft.block.BlockState; @@ -64,7 +65,7 @@ public class Events { return; if (!event.getPlayer().isAllowEdit()) return; - if (!CreateConfig.parameters.allowGlassPanesInPartialBlocks.get()) + if (!AllConfigs.SERVER.curiosities.allowGlassPanesInPartialBlocks.get()) return; ItemStack stack = event.getItemStack(); diff --git a/src/main/java/com/simibubi/create/config/AllConfigs.java b/src/main/java/com/simibubi/create/config/AllConfigs.java new file mode 100644 index 000000000..de8d357e5 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/AllConfigs.java @@ -0,0 +1,52 @@ +package com.simibubi.create.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.config.ModConfig.Type; + +public class AllConfigs { + + static List> configs = new ArrayList<>(); + + public static CClient CLIENT = register(CClient::new, ModConfig.Type.CLIENT); + public static CCommon COMMON = register(CCommon::new, ModConfig.Type.COMMON); + public static CServer SERVER = register(CServer::new, ModConfig.Type.SERVER); + + private static T register(Supplier factory, ModConfig.Type side) { + Pair specPair = new ForgeConfigSpec.Builder().configure(builder -> { + T config = factory.get(); + config.registerAll(builder); + return config; + }); + + T config = specPair.getLeft(); + config.specification = specPair.getRight(); + configs.add(Pair.of(config, side)); + return config; + } + + public static void registerAll() { + ModLoadingContext ctx = ModLoadingContext.get(); + for (Pair pair : configs) + ctx.registerConfig(pair.getValue(), pair.getKey().specification); + } + + public static void onLoad(ModConfig.Loading event) { + for (Pair pair : configs) + if (pair.getKey().specification == event.getConfig().getSpec()) + pair.getKey().onLoad(); + } + + public static void onReload(ModConfig.ConfigReloading event) { + for (Pair pair : configs) + if (pair.getKey().specification == event.getConfig().getSpec()) + pair.getKey().onReload(); + } +} diff --git a/src/main/java/com/simibubi/create/config/CClient.java b/src/main/java/com/simibubi/create/config/CClient.java new file mode 100644 index 000000000..84f667ed8 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CClient.java @@ -0,0 +1,17 @@ +package com.simibubi.create.config; + +public class CClient extends ConfigBase { + + public ConfigGroup client = group(0, "client", + "Client-only settings - If you're looking for general settings, look inside your worlds serverconfig folder!"); + public ConfigBool tooltips = b(true, "enableTooltips", "Show item descriptions on Shift and controls on Ctrl."); + public ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity"); + public ConfigBool rainbowDebug = + b(true, "enableRainbowDebug", "Show colourful debug information while the F3-Menu is open."); + + @Override + public String getName() { + return "client"; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CCommon.java b/src/main/java/com/simibubi/create/config/CCommon.java new file mode 100644 index 000000000..34d02f115 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CCommon.java @@ -0,0 +1,16 @@ +package com.simibubi.create.config; + +public class CCommon extends ConfigBase { + + public CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen); + + @Override + public String getName() { + return "common"; + } + + private static class Comments { + static String worldGen = "Modify Create's impact on your terrain"; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CCuriosities.java b/src/main/java/com/simibubi/create/config/CCuriosities.java new file mode 100644 index 000000000..90928dff2 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CCuriosities.java @@ -0,0 +1,32 @@ +package com.simibubi.create.config; + +public class CCuriosities extends ConfigBase { + + public ConfigInt maxSymmetryWandRange = i(50, 10, "maxSymmetryWandRange", Comments.symmetryRange); + public ConfigInt lightSourceCountForRefinedRadiance = + i(10, 1, "lightSourceCountForRefinedRadiance", Comments.refinedRadiance); + public ConfigBool allowGlassPanesInPartialBlocks = + b(true, "allowGlassPanesInPartialBlocks", Comments.windowsInBlocks); + public ConfigBool enableRefinedRadianceRecipe = + b(true, "enableRefinedRadianceRecipe", Comments.refinedRadianceRecipe); + public ConfigBool enableShadowSteelRecipe = b(true, "enableShadowSteelRecipe", Comments.shadowSteelRecipe); + public ConfigBool enableSandPaperToolPolishing = b(true, "enableSandPaperToolPolishing", Comments.sandPaperOnTools); + public ConfigFloat cocoaLogGrowthSpeed = f(20, 0, 100, "cocoaLogGrowthSpeed", Comments.cocoa); + + @Override + public String getName() { + return "curiosities"; + } + + private static class Comments { + static String symmetryRange = "The Maximum Distance to an active mirror for the symmetry wand to trigger."; + static String refinedRadiance = + "The amount of Light sources destroyed before Chromatic Compound turns into Refined Radiance."; + static String refinedRadianceRecipe = "Allow the standard Refined Radiance recipes."; + static String shadowSteelRecipe = "Allow the standard Shadow Steel recipe."; + static String sandPaperOnTools = "Enable the tool repairing mechanic involving sand paper."; + static String windowsInBlocks = "Allow Glass Panes to be put inside Blocks like Stairs, Slabs, Fences etc."; + static String cocoa = "% of random Ticks causing a Cocoa log to grow."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CDamageControl.java b/src/main/java/com/simibubi/create/config/CDamageControl.java new file mode 100644 index 000000000..e62192518 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CDamageControl.java @@ -0,0 +1,27 @@ +package com.simibubi.create.config; + +public class CDamageControl extends ConfigBase { + + public ConfigBool freezeCrushing = b(false, "freezeCrushing", Comments.freezeCrushing); + public ConfigBool freezeExtractors = b(false, "freezeExtractors", Comments.freezeExtractors); + public ConfigBool freezeInWorldProcessing = b(false, "freezeInWorldProcessing", Comments.freezeInWorldProcessing); + public ConfigBool freezeRotationPropagator = b(false, "freezeRotationPropagator", Comments.freezeRotationPropagator); + public ConfigBool freezeBearingConstructs = b(false, "freezeBearingConstructs", Comments.freezeBearingConstructs); + public ConfigBool freezePistonConstructs = b(false, "freezePistonConstructs", Comments.freezePistonConstructs); + + @Override + public String getName() { + return "damageControl"; + } + + private static class Comments { + static String freezeCrushing = "In case Crushing Wheels crushed your server."; + static String freezeExtractors = "In case Extractors pulled the plug."; + static String freezeInWorldProcessing = "In case Encased Fans tried smelting your hardware."; + static String freezeRotationPropagator = + "Pauses rotation logic altogether - Use if crash mentions RotationPropagators."; + static String freezeBearingConstructs = "In case Mechanical Bearings turned against you."; + static String freezePistonConstructs = "In case Mechanical Pistons pushed it too far."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CKinetics.java b/src/main/java/com/simibubi/create/config/CKinetics.java new file mode 100644 index 000000000..bdb8c6e1e --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CKinetics.java @@ -0,0 +1,66 @@ +package com.simibubi.create.config; + +public class CKinetics extends ConfigBase { + + public ConfigInt maxBeltLength = i(20, 5, "maxBeltLength", Comments.maxBeltLength); + public ConfigInt crushingDamage = i(4, 0, "crushingDamage", Comments.crushingDamage); + public ConfigInt maxMotorSpeed = i(256, 64, "maxMotorSpeed", Comments.rpm, Comments.maxMotorSpeed); + public ConfigInt maxRotationSpeed = i(256, 64, "maxRotationSpeed", Comments.rpm, Comments.maxRotationSpeed); + + public ConfigGroup fan = group(0, "encasedFan", "Encased Fan"); + public ConfigInt fanPushDistance = i(20, 5, "fanPushDistance", Comments.fanPushDistance); + public ConfigInt fanPullDistance = i(20, 5, "fanPullDistance", Comments.fanPullDistance); + public ConfigInt fanBlockCheckRate = i(30, 10, "fanBlockCheckRate", Comments.fanBlockCheckRate); + public ConfigInt fanRotationArgmax = i(256, 64, "fanRotationArgmax", Comments.rpm, Comments.fanRotationArgmax); + public ConfigInt generatingFanSpeed = i(16, 0, "generatingFanSpeed", Comments.rpm, Comments.generatingFanSpeed); + public ConfigInt inWorldProcessingTime = i(150, 0, "inWorldProcessingTime", Comments.inWorldProcessingTime); + + public ConfigGroup contraptions = group(0, "contraptions", "Moving Contraptions"); + public ConfigInt maxChassisForTranslation = i(16, 1, "maxChassisForTranslation", Comments.maxChassisForTranslation); + public ConfigInt maxChassisForRotation = i(16, 1, "maxChassisForRotation", Comments.maxChassisForRotation); + public ConfigInt maxChassisRange = i(16, 1, "maxChassisRange", Comments.maxChassisRange); + public ConfigInt maxPistonPoles = i(64, 1, "maxPistonPoles", Comments.maxPistonPoles); + + public ConfigGroup state = group(0, "stats", Comments.stats); + public ConfigFloat mediumSpeed = f(30, 0, 4096, "mediumSpeed", Comments.rpm, Comments.mediumSpeed); + public ConfigFloat fastSpeed = f(100, 0, 65535, "fastSpeed", Comments.rpm, Comments.fastSpeed); + public ConfigFloat mediumStressImpact = f(8, 0, 4096, "mediumStressImpact", Comments.su, Comments.mediumStressImpact); + public ConfigFloat highStressImpact = f(32, 0, 65535, "highStressImpact", Comments.su, Comments.highStressImpact); + public ConfigFloat mediumCapacity = f(128, 0, 4096, "mediumCapacity", Comments.su, Comments.mediumCapacity); + public ConfigFloat highCapacity = f(512, 0, 65535, "highCapacity", Comments.su, Comments.highCapacity); + + public CStress stressValues = nested(0, CStress::new, Comments.stress); + + @Override + public String getName() { + return "kinetics"; + } + + private static class Comments { + static String maxBeltLength = "Maximum length in blocks of mechanical belts."; + static String crushingDamage = "Damage dealt by active Crushing Wheels."; + static String maxMotorSpeed = "Maximum allowed speed of a configurable motor."; + static String maxRotationSpeed = "Maximum allowed rotation speed for any Kinetic Tile."; + static String fanPushDistance = "Maximum distance in blocks Fans can push entities."; + static String fanPullDistance = "Maximum distance in blocks from where Fans can pull entities."; + static String fanBlockCheckRate = "Game ticks between Fans checking for anything blocking their air flow."; + static String fanRotationArgmax = "Rotation speed at which the maximum stats of fans are reached."; + static String generatingFanSpeed = "Rotation speed generated by a vertical fan above fire."; + static String inWorldProcessingTime = "Game ticks required for a Fan-based processing recipe to take effect."; + static String maxChassisForTranslation = "Maximum amount of chassis blocks movable by a Mechanical Piston."; + static String maxChassisForRotation = "Maximum amount of chassis blocks movable by a Mechanical Bearing."; + static String maxChassisRange = "Maximum value of a chassis attachment range."; + static String maxPistonPoles = "Maximum amount of extension poles behind a Mechanical Piston."; + static String stats = "Configure speed/capacity levels for requirements and indicators."; + static String rpm = "[in Revolutions per Minute]"; + static String su = "[in Stress Units]"; + static String mediumSpeed = "Minimum speed of rotation to be considered 'medium'"; + static String fastSpeed = "Minimum speed of rotation to be considered 'fast'"; + static String mediumStressImpact = "Minimum stress impact to be considered 'medium'"; + static String highStressImpact = "Minimum stress impact to be considered 'high'"; + static String mediumCapacity = "Minimum added Capacity by sources to be considered 'medium'"; + static String highCapacity = "Minimum added Capacity by sources to be considered 'high'"; + static String stress = "Fine tune the kinetic stats of individual components"; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CLogistics.java b/src/main/java/com/simibubi/create/config/CLogistics.java new file mode 100644 index 000000000..1ce2c7240 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CLogistics.java @@ -0,0 +1,22 @@ +package com.simibubi.create.config; + +public class CLogistics extends ConfigBase { + + public ConfigInt extractorDelay = i(20, 10, "extractorDelay", Comments.extractorDelay); + public ConfigInt extractorInventoryScanDelay = i(40, 10, "extractorInventoryScanDelay", Comments.extractorInventoryScanDelay); + public ConfigInt extractorAmount = i(16, 1, 64, "extractorAmount", Comments.extractorAmount); + public ConfigInt linkRange = i(128, 1, "extractorDelay", Comments.linkRange); + + @Override + public String getName() { + return "logistics"; + } + + private static class Comments { + static String extractorDelay = "The amount of game ticks an Extractor waits after pulling an item successfully."; + static String extractorInventoryScanDelay = "The amount of game ticks an Extractor waits before checking again if the attached inventory contains items to extract."; + static String extractorAmount = "The amount of items an extractor pulls at a time without an applied filter."; + static String linkRange = "Maximum possible range in blocks of redstone link connections."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CSchematics.java b/src/main/java/com/simibubi/create/config/CSchematics.java new file mode 100644 index 000000000..a09a7d65b --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CSchematics.java @@ -0,0 +1,37 @@ +package com.simibubi.create.config; + +public class CSchematics extends ConfigBase { + + public ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics); + public ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize); + public ConfigInt maxSchematicPacketSize = + i(1024, 256, 32767, "maxSchematicPacketSize", Comments.b, Comments.maxPacketSize); + public ConfigInt schematicIdleTimeout = i(600, 100, "schematicIdleTimeout", Comments.idleTimeout); + + public ConfigGroup schematicannon = group(0, "schematicannon", "Schematicannon"); + public ConfigInt schematicannonDelay = i(10, 1, "schematicannonDelay", Comments.delay); + public ConfigInt schematicannonSkips = i(10, 1, "schematicannonSkips", Comments.skips); + public ConfigFloat schematicannonGunpowderWorth = f(20, 0, 100, "schematicannonGunpowderWorth", Comments.gunpowderWorth); + public ConfigFloat schematicannonFuelUsage = f(0.05f, 0, 100, "schematicannonFuelUsage", Comments.fuelUsage); + + @Override + public String getName() { + return "schematics"; + } + + private static class Comments { + static String kb = "[in KiloBytes]"; + static String b = "[in Bytes]"; + static String maxSchematics = + "The amount of Schematics a player can upload until previous ones are overwritten."; + static String maxSize = "The maximum allowed file size of uploaded Schematics."; + static String maxPacketSize = "The maximum packet size uploaded Schematics are split into."; + static String idleTimeout = + "Amount of game ticks without new packets arriving until an active schematic upload process is discarded."; + static String delay = "Amount of game ticks between shots of the cannon. Higher => Slower"; + static String skips = "Amount of block positions per tick scanned by a running cannon. Higher => Faster"; + static String gunpowderWorth = "% of Schematicannon's Fuel filled by 1 Gunpowder."; + static String fuelUsage = "% of Schematicannon's Fuel used for each fired block."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CServer.java b/src/main/java/com/simibubi/create/config/CServer.java new file mode 100644 index 000000000..5e48aa40a --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CServer.java @@ -0,0 +1,31 @@ +package com.simibubi.create.config; + +public class CServer extends ConfigBase { + + public ConfigGroup modules = group(0, "modules", Comments.modules); + public ConfigBool enableSchematics = b(true, "enableSchematics"); + public ConfigBool enableCuriosities = b(true, "enableCuriosities"); + public ConfigBool enablePalettes = b(true, "enablePalettes"); + public ConfigBool enableLogistics = b(true, "enableLogistics"); + + public CKinetics kinetics = nested(0, CKinetics::new, Comments.kinetics); + public CLogistics logistics = nested(0, CLogistics::new, Comments.logistics); + public CSchematics schematics = nested(0, CSchematics::new, Comments.schematics); + public CCuriosities curiosities = nested(0, CCuriosities::new, Comments.curiosities); + public CDamageControl control = nested(0, CDamageControl::new, Comments.control); + + @Override + public String getName() { + return "server"; + } + + private static class Comments { + static String schematics = "The Schematics Module"; + static String kinetics = "The Contraptions Module"; + static String logistics = "The Logistics Module"; + static String curiosities = "Everything that spins"; + static String modules = "Configure which Modules should be accessible in recipes and creative menus."; + static String control = "You can try inhibiting related game mechanics for troubleshooting repeated crashes."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CStress.java b/src/main/java/com/simibubi/create/config/CStress.java new file mode 100644 index 000000000..4fa303a02 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CStress.java @@ -0,0 +1,61 @@ +package com.simibubi.create.config; + +import java.util.HashMap; +import java.util.Map; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.base.KineticBlock; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.Builder; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; + +public class CStress extends ConfigBase { + + public Map> impacts = new HashMap<>(); + public Map> capacities = new HashMap<>(); + + @Override + protected void registerAll(Builder builder) { + builder.comment("", Comments.su, Comments.impact).push("impact"); + for (AllBlocks block : AllBlocks.values()) + if (block.get() instanceof KineticBlock) + initStressEntry(block, builder); + builder.pop(); + + builder.comment("", Comments.su, Comments.capacity).push("capacity"); + for (AllBlocks block : AllBlocks.values()) + if (block.get() instanceof KineticBlock) + initStressCapacityEntry(block, builder); + builder.pop(); + } + + private void initStressEntry(AllBlocks block, final ForgeConfigSpec.Builder builder) { + String name = Lang.asId(block.name()); + double defaultStressImpact = StressConfigDefaults.getDefaultStressImpact(block); + capacities.put(block.get().getRegistryName(), builder.define(name, defaultStressImpact)); + } + + private void initStressCapacityEntry(AllBlocks block, final ForgeConfigSpec.Builder builder) { + double defaultStressCapacity = StressConfigDefaults.getDefaultStressCapacity(block); + if (defaultStressCapacity == -1) + return; + String name = Lang.asId(block.name()); + impacts.put(block.get().getRegistryName(), builder.define(name, defaultStressCapacity)); + } + + @Override + public String getName() { + return "stressValues"; + } + + private static class Comments { + static String su = "[in Stress Units]"; + static String impact = + "Configure the individual stress impact of mechanical blocks. Note that this cost is doubled for every speed increase it receives."; + static String capacity = "Configure how much stress a source can accommodate for."; + } + +} diff --git a/src/main/java/com/simibubi/create/config/CWorldGen.java b/src/main/java/com/simibubi/create/config/CWorldGen.java new file mode 100644 index 000000000..7464e6859 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/CWorldGen.java @@ -0,0 +1,32 @@ +package com.simibubi.create.config; + +import com.simibubi.create.foundation.world.AllWorldFeatures; + +import net.minecraftforge.common.ForgeConfigSpec.Builder; + +public class CWorldGen extends ConfigBase { + + public ConfigBool disable = b(false, "disableWorldGen", Comments.disable); + + @Override + protected void registerAll(Builder builder) { + super.registerAll(builder); + AllWorldFeatures.fillConfig(builder); + } + + @Override + public void onReload() { + AllWorldFeatures.reload(); + super.onReload(); + } + + @Override + public String getName() { + return "world"; + } + + private static class Comments { + static String disable = "Prevents all worldgen added by Create from taking effect"; + } + +} diff --git a/src/main/java/com/simibubi/create/config/ConfigBase.java b/src/main/java/com/simibubi/create/config/ConfigBase.java new file mode 100644 index 000000000..8af7f4ac6 --- /dev/null +++ b/src/main/java/com/simibubi/create/config/ConfigBase.java @@ -0,0 +1,175 @@ +package com.simibubi.create.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; +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 abstract class ConfigBase { + + public ForgeConfigSpec specification; + + protected int depth; + protected List> allValues; + protected List children; + + protected void registerAll(final ForgeConfigSpec.Builder builder) { + for (CValue cValue : allValues) + cValue.register(builder); + } + + public void onLoad() { + if (children != null) + children.forEach(ConfigBase::onLoad); + } + + public void onReload() { + if (children != null) + children.forEach(ConfigBase::onReload); + } + + public abstract String getName(); + + @FunctionalInterface + protected static interface IValueProvider> + extends Function { + } + + protected ConfigBool b(boolean current, String name, String... comment) { + return new ConfigBool(name, current, comment); + } + + protected ConfigFloat f(float current, float min, float max, String name, String... comment) { + return new ConfigFloat(name, current, min, max, comment); + } + + protected ConfigFloat f(float current, float min, String name, String... comment) { + return f(current, min, Float.MAX_VALUE, name, comment); + } + + protected ConfigInt i(int current, int min, int max, String name, String... comment) { + return new ConfigInt(name, current, min, max, comment); + } + + protected ConfigInt i(int current, int min, String name, String... comment) { + return i(current, min, Integer.MAX_VALUE, name, comment); + } + + protected ConfigGroup group(int depth, String name, String... comment) { + return new ConfigGroup(name, depth, comment); + } + + protected T nested(int depth, Supplier constructor, String... comment) { + T config = constructor.get(); + new ConfigGroup(config.getName(), depth, comment); + new CValue(config.getName(), builder -> { + config.registerAll(builder); + if (config.depth > 0) + builder.pop(config.depth); + return null; + }); + if (children == null) + children = new ArrayList<>(); + children.add(config); + return config; + } + + public class CValue> { + protected ConfigValue value; + protected String name; + private IValueProvider provider; + + public CValue(String name, IValueProvider provider, String... comment) { + this.name = name; + this.provider = builder -> { + addComments(builder, comment); + return provider.apply(builder); + }; + if (allValues == null) + allValues = new ArrayList<>(); + allValues.add(this); + } + + public void addComments(Builder builder, String... comment) { + if (comment.length > 0) { + String[] comments = new String[comment.length + 1]; + comments[0] = ""; + for (int i = 0; i < comment.length; i++) + comments[i + 1] = comment[i]; + builder.comment(comments); + } else + builder.comment(""); + } + + public void register(ForgeConfigSpec.Builder builder) { + value = provider.apply(builder); + } + + public V get() { + return value.get(); + } + + public void set(V value) { + this.value.set(value); + } + } + + /** + * Marker for config subgroups + */ + public class ConfigGroup extends CValue { + + private int groupDepth; + private String[] comment; + + public ConfigGroup(String name, int depth, String... comment) { + super(name, builder -> null, comment); + groupDepth = depth; + this.comment = comment; + } + + @Override + public void register(Builder builder) { + if (depth > groupDepth) + builder.pop(depth - groupDepth); + depth = groupDepth; + addComments(builder, comment); + builder.push(name); + depth++; + } + + } + + public class ConfigBool extends CValue { + + public ConfigBool(String name, boolean def, String... comment) { + super(name, builder -> builder.define(name, def), comment); + } + } + + public class ConfigFloat extends CValue { + + public ConfigFloat(String name, float current, float min, float max, String... comment) { + super(name, builder -> builder.defineInRange(name, current, min, max), comment); + } + + public float getF() { + return get().floatValue(); + } + } + + public class ConfigInt extends CValue { + + public ConfigInt(String name, int current, int min, int max, String... comment) { + super(name, builder -> builder.defineInRange(name, current, min, max), comment); + } + } + +} diff --git a/src/main/java/com/simibubi/create/StressConfigDefaults.java b/src/main/java/com/simibubi/create/config/StressConfigDefaults.java similarity index 91% rename from src/main/java/com/simibubi/create/StressConfigDefaults.java rename to src/main/java/com/simibubi/create/config/StressConfigDefaults.java index 26199d33e..f47eac99d 100644 --- a/src/main/java/com/simibubi/create/StressConfigDefaults.java +++ b/src/main/java/com/simibubi/create/config/StressConfigDefaults.java @@ -1,4 +1,6 @@ -package com.simibubi.create; +package com.simibubi.create.config; + +import com.simibubi.create.AllBlocks; public class StressConfigDefaults { diff --git a/src/main/java/com/simibubi/create/foundation/behaviour/inventory/ExtractingBehaviour.java b/src/main/java/com/simibubi/create/foundation/behaviour/inventory/ExtractingBehaviour.java index 6340f8c78..89a52e9bc 100644 --- a/src/main/java/com/simibubi/create/foundation/behaviour/inventory/ExtractingBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/behaviour/inventory/ExtractingBehaviour.java @@ -8,6 +8,7 @@ import java.util.function.Supplier; import org.apache.commons.lang3.tuple.Pair; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.base.IBehaviourType; import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; @@ -56,6 +57,8 @@ public class ExtractingBehaviour extends InventoryManagementBehaviour { public boolean extract(int exactAmount) { if (getWorld().isRemote) return false; + if (AllConfigs.SERVER.control.freezeExtractors.get()) + return false; Predicate test = customFilter; FilteringBehaviour filter = get(tileEntity, FilteringBehaviour.TYPE); diff --git a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java index b7cbb38d4..571f220c4 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java @@ -1,14 +1,15 @@ package com.simibubi.create.foundation.command; -import com.simibubi.create.CreateClientConfig; +import java.util.function.Supplier; + +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.packet.SimplePacketBase; + import net.minecraft.network.PacketBuffer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent; -import java.util.function.Supplier; - public class ConfigureConfigPacket extends SimplePacketBase { private String option; @@ -20,8 +21,8 @@ public class ConfigureConfigPacket extends SimplePacketBase { } public ConfigureConfigPacket(PacketBuffer buffer) { - this.option = buffer.readString(); - this.value = buffer.readString(); + this.option = buffer.readString(32767); + this.value = buffer.readString(32767); } @Override @@ -33,8 +34,8 @@ public class ConfigureConfigPacket extends SimplePacketBase { @Override public void handle(Supplier ctx) { ctx.get().enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - if (option.equals("rainbowDebug")){ - CreateClientConfig.instance.enableRainbowDebug.set(Boolean.parseBoolean(value)); + if (option.equals("rainbowDebug")) { + AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value)); } })); diff --git a/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java b/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java index 9c9b104af..d8cdfa182 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java @@ -3,7 +3,8 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.AllPackets; -import com.simibubi.create.CreateClientConfig; +import com.simibubi.create.config.AllConfigs; + import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.entity.player.ServerPlayerEntity; @@ -15,23 +16,23 @@ import net.minecraftforge.fml.network.PacketDistributor; public class ToggleDebugCommand { static ArgumentBuilder register() { - return Commands.literal("toggleDebug") - .requires(cs -> cs.hasPermissionLevel(0)) - .then(Commands.argument("value", BoolArgumentType.bool()) - .executes(ctx -> { - boolean value = BoolArgumentType.getBool(ctx, "value"); - System.out.println("Command toggleDebug " + value); + return Commands.literal("toggleDebug").requires(cs -> cs.hasPermissionLevel(0)) + .then(Commands.argument("value", BoolArgumentType.bool()).executes(ctx -> { + boolean value = BoolArgumentType.getBool(ctx, "value"); + System.out.println("Command toggleDebug " + value); - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> CreateClientConfig.instance.enableRainbowDebug.set(value)); + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> AllConfigs.CLIENT.rainbowDebug.set(value)); - DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> - AllPackets.channel.send( - PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()), - new ConfigureConfigPacket("rainbowDebug", String.valueOf(value)))); + DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, + () -> () -> AllPackets.channel.send( + PacketDistributor.PLAYER + .with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()), + new ConfigureConfigPacket("rainbowDebug", String.valueOf(value)))); - ctx.getSource().sendFeedback(new StringTextComponent((value ? "enabled" : "disabled") + " rainbow debug"), true); + ctx.getSource().sendFeedback( + new StringTextComponent((value ? "enabled" : "disabled") + " rainbow debug"), true); - return 1; - })); + return 1; + })); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java index ed4816d1c..b321b5f36 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.item; -import static com.simibubi.create.CreateConfig.parameters; import static com.simibubi.create.foundation.item.TooltipHelper.cutString; import static net.minecraft.util.text.TextFormatting.AQUA; import static net.minecraft.util.text.TextFormatting.BLUE; @@ -20,8 +19,11 @@ import static net.minecraft.util.text.TextFormatting.YELLOW; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import com.simibubi.create.AllItems; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CKinetics; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; @@ -35,12 +37,13 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; public class ItemDescription { public static final ItemDescription MISSING = new ItemDescription(null); - public static ITextComponent trim = new StringTextComponent( - WHITE + "" + STRIKETHROUGH + " "); + public static ITextComponent trim = + new StringTextComponent(WHITE + "" + STRIKETHROUGH + " "); public enum Palette { @@ -80,21 +83,23 @@ public class ItemDescription { } public ItemDescription withKineticStats(IRotate block) { + CKinetics config = AllConfigs.SERVER.kinetics; SpeedLevel minimumRequiredSpeedLevel = block.getMinimumRequiredSpeedLevel(); boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE; ResourceLocation id = ((Block) block).getRegistryName(); - boolean hasStressImpact = parameters.stressEntries.containsKey(id) - && parameters.stressEntries.get(id).get() > 0; - boolean hasStressCapacity = parameters.stressCapacityEntries.containsKey(id); - boolean hasGlasses = AllItems.GOGGLES - .typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD)); + Map> impacts = config.stressValues.capacities; + Map> capacities = config.stressValues.impacts; + boolean hasStressImpact = impacts.containsKey(id) && impacts.get(id).get() > 0; + boolean hasStressCapacity = capacities.containsKey(id); + boolean hasGlasses = + AllItems.GOGGLES.typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD)); String rpmUnit = Lang.translate("generic.unit.rpm"); if (hasSpeedRequirement) { List speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); int index = minimumRequiredSpeedLevel.ordinal(); - String level = minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) - + speedLevels.get(index); + String level = + minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) + speedLevels.get(index); if (hasGlasses) level += " (" + minimumRequiredSpeedLevel.getSpeedValue() + rpmUnit + "+)"; @@ -105,33 +110,33 @@ public class ItemDescription { String stressUnit = Lang.translate("generic.unit.stress"); if (hasStressImpact && !block.hideStressImpact()) { List stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); - double impact = parameters.stressEntries.get(id).get(); - StressImpact impactId = impact >= parameters.highStressImpact.get() ? StressImpact.HIGH - : (impact >= parameters.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); + double impact = impacts.get(id).get(); + StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH + : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); int index = impactId.ordinal(); String level = impactId.getColor() + makeProgressBar(3, index) + stressLevels.get(index); if (hasGlasses) - level += " (" + parameters.stressEntries.get(id).get() + stressUnit + ")"; + level += " (" + impacts.get(id).get() + stressUnit + ")"; add(linesOnShift, GRAY + Lang.translate("tooltip.stressImpact")); add(linesOnShift, level); } if (hasStressCapacity) { - List stressCapacityLevels = Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", - "high"); - double capacity = parameters.stressCapacityEntries.get(id).get(); - StressImpact impactId = capacity >= parameters.highCapacity.get() ? StressImpact.LOW - : (capacity >= parameters.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); + List stressCapacityLevels = + Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high"); + double capacity = capacities.get(id).get(); + StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW + : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); int index = StressImpact.values().length - 1 - impactId.ordinal(); String level = impactId.getColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index); if (hasGlasses) level += " (" + capacity + stressUnit + ")"; if (block.showCapacityWithAnnotation()) - level += " " + DARK_GRAY + TextFormatting.ITALIC - + Lang.translate("tooltip.capacityProvided.asGenerator"); + level += + " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator"); add(linesOnShift, GRAY + Lang.translate("tooltip.capacityProvided")); add(linesOnShift, level); diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java index d6ea75998..6ebc10ffd 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java @@ -8,7 +8,7 @@ import java.util.function.Predicate; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.Pair; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -98,9 +98,9 @@ public class ItemHelper { boolean amountRequired = exactAmount != -1; boolean checkHasEnoughItems = amountRequired; boolean hasEnoughItems = !checkHasEnoughItems; - int maxExtractionCount = hasEnoughItems ? CreateConfig.parameters.extractorAmount.get() : exactAmount; + int maxExtractionCount = hasEnoughItems ? AllConfigs.SERVER.logistics.extractorAmount.get() : exactAmount; boolean potentialOtherMatch = false; - + Extraction: do { extracting = ItemStack.EMPTY; @@ -134,18 +134,18 @@ public class ItemHelper { } } } - + if (!extracting.isEmpty() && !hasEnoughItems && potentialOtherMatch) { ItemStack blackListed = extracting.copy(); test = test.and(i -> !ItemHandlerHelper.canItemStacksStack(i, blackListed)); continue; } - + if (checkHasEnoughItems) checkHasEnoughItems = false; else break Extraction; - + } while (true); if (amountRequired && extracting.getCount() < exactAmount) @@ -157,7 +157,7 @@ public class ItemHelper { public static ItemStack extract(IItemHandler inv, Predicate test, Function amountFunction, boolean simulate) { ItemStack extracting = ItemStack.EMPTY; - int maxExtractionCount = CreateConfig.parameters.extractorAmount.get(); + int maxExtractionCount = AllConfigs.SERVER.logistics.extractorAmount.get(); for (int slot = 0; slot < inv.getSlots(); slot++) { if (extracting.isEmpty()) { diff --git a/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java new file mode 100644 index 000000000..ffec97bd6 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java @@ -0,0 +1,68 @@ +package com.simibubi.create.foundation.world; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.registries.ForgeRegistries; + +public enum AllWorldFeatures { + + COPPER_ORE(new CountedOreFeature(AllBlocks.COPPER_ORE.get(), 21, 1).between(40, 96)), + COPPER_ORE_OCEAN( + new CountedOreFeature(AllBlocks.COPPER_ORE.get(), 15, 4).between(20, 55).inBiomes(Biome.Category.OCEAN)), + + ZINC_ORE(new CountedOreFeature(AllBlocks.ZINC_ORE.get(), 17, 1).between(55, 80)), + ZINC_ORE_DESERT( + new CountedOreFeature(AllBlocks.ZINC_ORE.get(), 17, 5).between(50, 85).inBiomes(Biome.Category.DESERT)), + + LIMESTONE(new ChanceOreFeature(AllBlocks.LIMESTONE.get(), 128, 1 / 32f).between(30, 70)), + WEATHERED_LIMESTONE(new ChanceOreFeature(AllBlocks.WEATHERED_LIMESTONE.get(), 128, 1 / 32f).between(10, 30)), + DOLOMITE(new ChanceOreFeature(AllBlocks.DOLOMITE.get(), 128, 1 / 64f).between(20, 70)), + GABBRO(new ChanceOreFeature(AllBlocks.GABBRO.get(), 128, 1 / 64f).between(20, 70)), + SCORIA(new ChanceOreFeature(AllBlocks.SCORIA.get(), 128, 1 / 32f).between(0, 10)), + + ; + + public IFeature feature; + private Map> featureInstances; + + AllWorldFeatures(IFeature feature) { + this.feature = feature; + this.featureInstances = new HashMap<>(); + this.feature.setId(Lang.asId(name())); + } + + public static void reload() { + for (AllWorldFeatures entry : AllWorldFeatures.values()) { + for (Biome biome : ForgeRegistries.BIOMES) { + + if (entry.featureInstances.containsKey(biome)) + biome.getFeatures(entry.feature.getGenerationStage()).remove(entry.featureInstances.remove(biome)); + + Optional> createFeature = entry.feature.createFeature(biome); + if (!createFeature.isPresent()) + continue; + + entry.featureInstances.put(biome, createFeature.get()); + biome.addFeature(entry.feature.getGenerationStage(), createFeature.get()); + } + } + } + + public static void fillConfig(ForgeConfigSpec.Builder builder) { + Arrays.stream(values()).forEach(entry -> { + builder.push(Lang.asId(entry.name())); + entry.feature.addToConfig(builder); + builder.pop(); + }); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/world/ChanceOreFeature.java b/src/main/java/com/simibubi/create/foundation/world/ChanceOreFeature.java new file mode 100644 index 000000000..67ccdc995 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/world/ChanceOreFeature.java @@ -0,0 +1,29 @@ +package com.simibubi.create.foundation.world; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.block.Block; +import net.minecraft.world.gen.placement.ChanceRangeConfig; +import net.minecraft.world.gen.placement.Placement; + +public class ChanceOreFeature extends OreFeature { + + private ConfigFloat clusterChance; + + public ChanceOreFeature(Block block, int clusterSize, float clusterChance) { + super(block, clusterSize); + this.clusterChance = f(clusterChance, 0, 1, "clusterChance"); + } + + @Override + protected boolean canGenerate() { + return super.canGenerate() && clusterChance.get() > 0; + } + + @Override + protected Pair, ChanceRangeConfig> getPlacement() { + return Pair.of(Placement.CHANCE_RANGE, + new ChanceRangeConfig(clusterChance.getF(), minHeight.get(), 0, maxHeight.get() - minHeight.get())); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java b/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java new file mode 100644 index 000000000..de069f8d0 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java @@ -0,0 +1,29 @@ +package com.simibubi.create.foundation.world; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.block.Block; +import net.minecraft.world.gen.placement.CountRangeConfig; +import net.minecraft.world.gen.placement.Placement; + +public class CountedOreFeature extends OreFeature { + + private ConfigInt clusterCount; + + public CountedOreFeature(Block block, int clusterSize, int clusterCount) { + super(block, clusterSize); + this.clusterCount = i(clusterCount, 0, "clusterCount"); + } + + @Override + protected boolean canGenerate() { + return super.canGenerate() && clusterCount.get() > 0; + } + + @Override + protected Pair, CountRangeConfig> getPlacement() { + return Pair.of(Placement.COUNT_RANGE, + new CountRangeConfig(clusterCount.get(), minHeight.get(), 0, maxHeight.get() - minHeight.get())); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/world/IFeature.java b/src/main/java/com/simibubi/create/foundation/world/IFeature.java new file mode 100644 index 000000000..18320bf07 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/world/IFeature.java @@ -0,0 +1,20 @@ +package com.simibubi.create.foundation.world; + +import java.util.Optional; + +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStage.Decoration; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraftforge.common.ForgeConfigSpec; + +public interface IFeature { + + public void setId(String id); + + public void addToConfig(ForgeConfigSpec.Builder builder); + + public Optional> createFeature(Biome biome); + + public Decoration getGenerationStage(); + +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/foundation/world/OreFeature.java b/src/main/java/com/simibubi/create/foundation/world/OreFeature.java new file mode 100644 index 000000000..a4ecaa7ed --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/world/OreFeature.java @@ -0,0 +1,114 @@ +package com.simibubi.create.foundation.world; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; + +import org.apache.commons.lang3.tuple.Pair; + +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.ConfigBase; + +import net.minecraft.block.Block; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.GenerationStage.Decoration; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.OreFeatureConfig; +import net.minecraft.world.gen.placement.IPlacementConfig; +import net.minecraft.world.gen.placement.Placement; +import net.minecraftforge.common.ForgeConfigSpec.Builder; +import net.minecraftforge.registries.ForgeRegistries; + +public abstract class OreFeature extends ConfigBase implements IFeature { + + public String id; + + protected ConfigBool enable; + protected ConfigInt clusterSize; + protected ConfigInt minHeight; + protected ConfigInt maxHeight; + + private Block block; + private List biomeWhitelist; + + public OreFeature(Block block, int clusterSize) { + this.block = block; + this.enable = b(true, "enable", "Whether to spawn this in your World"); + this.clusterSize = i(clusterSize, 0, "clusterSize"); + this.minHeight = i(0, 0, "minHeight"); + this.maxHeight = i(256, 0, "maxHeight"); + } + + public OreFeature between(int minHeight, int maxHeight) { + allValues.remove(this.minHeight); + allValues.remove(this.maxHeight); + this.minHeight = i(minHeight, 0, "minHeight"); + this.maxHeight = i(maxHeight, 0, "maxHeight"); + return this; + } + + public OreFeature inBiomes(Biome... biomes) { + biomeWhitelist = Arrays.asList(biomes); + return this; + } + + public OreFeature inBiomes(Biome.Category category) { + biomeWhitelist = new LinkedList<>(); + for (Biome biome : ForgeRegistries.BIOMES) + if (biome.getCategory() == category) + biomeWhitelist.add(biome); + return this; + } + + @Override + public void onReload() { + + } + + @Override + public Optional> createFeature(Biome biome) { + if (biomeWhitelist != null && !biomeWhitelist.contains(biome)) + return Optional.empty(); + if (!canGenerate()) + return Optional.empty(); + + Pair, T> placement = getPlacement(); + ConfiguredFeature createdFeature = Biome.createDecoratedFeature(Feature.ORE, + new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, block.getDefaultState(), + clusterSize.get()), + placement.getKey(), placement.getValue()); + + return Optional.of(createdFeature); + } + + @Override + public Decoration getGenerationStage() { + return GenerationStage.Decoration.UNDERGROUND_ORES; + } + + protected boolean canGenerate() { + return minHeight.get() < maxHeight.get() && clusterSize.get() > 0 && enable.get() + && !AllConfigs.COMMON.worldGen.disable.get(); + } + + protected abstract Pair, T> getPlacement(); + + @Override + public void addToConfig(Builder builder) { + registerAll(builder); + } + + @Override + public String getName() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java b/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java deleted file mode 100644 index 203234673..000000000 --- a/src/main/java/com/simibubi/create/foundation/world/OreGeneration.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.simibubi.create.foundation.world; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import com.simibubi.create.AllBlocks; - -import net.minecraft.block.Block; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.OreFeatureConfig; -import net.minecraft.world.gen.placement.ChanceRangeConfig; -import net.minecraft.world.gen.placement.CountRangeConfig; -import net.minecraft.world.gen.placement.Placement; -import net.minecraftforge.registries.ForgeRegistries; - -public enum OreGeneration { - - COPPER_ORE_GENERAL(new BasicOreGenConfig(AllBlocks.COPPER_ORE.get(), 21, 3, 40, 96)), - COPPER_ORE_OCEAN(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.COPPER_ORE.get(), 15, 3, 20, 55), Biome.Category.OCEAN)), - - ZINC_ORE_GENERAL(new BasicOreGenConfig(AllBlocks.ZINC_ORE.get(), 17, 1, 55, 80)), - ZINC_ORE_DESERT(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.ZINC_ORE.get(), 17, 5, 50, 85),Biome.Category.DESERT)), - - BASALT_ROCK(new BasicOreGenConfig(AllBlocks.VOLCANIC_ROCK.get(), 39, 0.2f, 0, 10)), - - //TEST_BLOB_1(new BasicOreGenConfig(Blocks.EMERALD_BLOCK, 25, 2, 0, 128)), - //TEST_BLOB_2(new BasicOreGenConfig(Blocks.QUARTZ_BLOCK, 41, 3, 0, 25)), - //TEST_BLOB_3(new OnlyInBiomes(new BasicOreGenConfig(Blocks.BLUE_GLAZED_TERRACOTTA, 5, 10, 0, 30), Biome.Category.OCEAN)), - //TEST_BLOB_4(new OnlyInBiomes(new BasicOreGenConfig(AllBlocks.GABBRO.get(), 31, 2, 0, 128), Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS)), - - ; - - IOreGenConfig config; - - OreGeneration(IOreGenConfig oreGenConfig) { - this.config = oreGenConfig; - } - - public static void setupOreGeneration() { - - for (Biome biome : - ForgeRegistries.BIOMES) { - - Arrays.stream(values()).forEach(oreGen -> oreGen.config.addFeature(biome)); - } - } - - private static class BasicOreGenConfig implements IOreGenConfig { - - Block block; - //im not 100% certain that these names are accurate but at least they seem that way - private int clusterSize, clusterCount, minHeight, maxHeight; - private float clusterChance; - - private BasicOreGenConfig(Block block, int clusterSize, int clusterCount, int minHeight, int maxHeight) { - this.block = block; - this.clusterSize = clusterSize; - this.clusterCount = clusterCount; - this.clusterChance = 1.0f; - this.minHeight = minHeight; - this.maxHeight = maxHeight; - } - - private BasicOreGenConfig(Block block, int clusterSize, float clusterChance, int minHeight, int maxHeight) { - this.block = block; - this.clusterSize = clusterSize; - this.clusterCount = 0; - this.clusterChance = clusterChance; - this.minHeight = minHeight; - this.maxHeight = maxHeight; - } - - @Override - public void addFeature(Biome biome) { - if (clusterCount > 0) { - biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, - Biome.createDecoratedFeature(Feature.ORE, - new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, - block.getDefaultState(), clusterSize), - Placement.COUNT_RANGE, new CountRangeConfig(clusterCount, minHeight, 0, maxHeight))); - } else { - biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, - Biome.createDecoratedFeature(Feature.ORE, - new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, - block.getDefaultState(), clusterSize), - Placement.CHANCE_RANGE, new ChanceRangeConfig(clusterChance, minHeight, 0, maxHeight))); - } - } - - } - - private static class OnlyInBiomes implements IOreGenConfig { - - //not sure if this is really needed but w/e - - IOreGenConfig config; - List biomes; - - private OnlyInBiomes(IOreGenConfig config, Biome... biomes) { - this.config = config; - this.biomes = Arrays.asList(biomes); - } - - private OnlyInBiomes(IOreGenConfig config, Biome.Category category){ - this.config = config; - this.biomes = new LinkedList<>(); - for (Biome biome: - ForgeRegistries.BIOMES) { - if (biome.getCategory() == category) - biomes.add(biome); - } - } - - @Override - public void addFeature(Biome biome) { - if (biomes.contains(biome)) { - config.addFeature(biome); - } - } - } - - private interface IOreGenConfig { - - void addFeature(Biome biome); - - } -} diff --git a/src/main/java/com/simibubi/create/modules/IModule.java b/src/main/java/com/simibubi/create/modules/IModule.java index 1918f0a2e..77b55b191 100644 --- a/src/main/java/com/simibubi/create/modules/IModule.java +++ b/src/main/java/com/simibubi/create/modules/IModule.java @@ -2,7 +2,8 @@ package com.simibubi.create.modules; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CServer; import com.simibubi.create.foundation.item.ItemDescription.Palette; import net.minecraft.block.Block; @@ -16,10 +17,10 @@ public interface IModule { if (module.equals("materials")) return true; - CreateConfig conf = CreateConfig.parameters; + CServer conf = AllConfigs.SERVER; switch (module) { case "contraptions": - return conf.enableContraptions.get(); + return true; case "palettes": return conf.enablePalettes.get(); case "curiosities": diff --git a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java index d2395f80d..54bfd52d8 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.contraptions; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.CreateClientConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.utility.TessellatorHelper; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; @@ -45,8 +45,7 @@ public class KineticDebugger { } public static boolean isActive() { - return Minecraft.getInstance().gameSettings.showDebugInfo - && CreateClientConfig.instance.enableRainbowDebug.get(); + return Minecraft.getInstance().gameSettings.showDebugInfo && AllConfigs.CLIENT.rainbowDebug.get(); } public static KineticTileEntity getSelectedTE() { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java index bb0cdb6d2..29d3312f1 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java @@ -3,13 +3,12 @@ package com.simibubi.create.modules.contraptions; import static com.simibubi.create.AllBlocks.BELT; import static com.simibubi.create.AllBlocks.COGWHEEL; import static com.simibubi.create.AllBlocks.LARGE_COGWHEEL; -import static com.simibubi.create.CreateConfig.parameters; import static net.minecraft.state.properties.BlockStateProperties.AXIS; import java.util.LinkedList; import java.util.List; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; @@ -51,9 +50,9 @@ public class RotationPropagator { if (axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0) alignedAxes = false; - boolean connectedByAxis = alignedAxes - && definitionFrom.hasShaftTowards(world, from.getPos(), stateFrom, direction) - && definitionTo.hasShaftTowards(world, to.getPos(), stateTo, direction.getOpposite()); + boolean connectedByAxis = + alignedAxes && definitionFrom.hasShaftTowards(world, from.getPos(), stateFrom, direction) + && definitionTo.hasShaftTowards(world, to.getPos(), stateTo, direction.getOpposite()); boolean connectedByGears = definitionFrom.hasCogsTowards(world, from.getPos(), stateFrom, direction) && definitionTo.hasCogsTowards(world, to.getPos(), stateTo, direction.getOpposite()); @@ -206,10 +205,10 @@ public class RotationPropagator { final float newSpeed = updateTE.speed * modFromTo; float oppositeSpeed = neighbourTE.speed * modToFrom; - boolean incompatible = Math.signum(newSpeed) != Math.signum(neighbourTE.speed) - && (newSpeed != 0 && neighbourTE.speed != 0); + boolean incompatible = + Math.signum(newSpeed) != Math.signum(neighbourTE.speed) && (newSpeed != 0 && neighbourTE.speed != 0); - boolean tooFast = Math.abs(newSpeed) > parameters.maxRotationSpeed.get(); + boolean tooFast = Math.abs(newSpeed) > AllConfigs.SERVER.kinetics.maxRotationSpeed.get(); boolean speedChangedTooOften = updateTE.speedChangeCounter > MAX_FLICKER_SCORE; if (tooFast || speedChangedTooOften) { world.destroyBlock(pos, true); @@ -397,7 +396,7 @@ public class RotationPropagator { } public static boolean isFrozen() { - return CreateConfig.parameters.freezeRotationPropagator.get(); + return AllConfigs.SERVER.control.freezeRotationPropagator.get(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java index 5a674862f..88cf88172 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java @@ -1,6 +1,6 @@ package com.simibubi.create.modules.contraptions.base; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.IWrenchable; import net.minecraft.block.BlockState; @@ -13,7 +13,9 @@ import net.minecraft.world.IWorldReader; public interface IRotate extends IWrenchable { public enum SpeedLevel { - NONE, MEDIUM, FAST; + NONE, + MEDIUM, + FAST; public TextFormatting getTextColor() { return this == NONE ? TextFormatting.GREEN @@ -31,9 +33,9 @@ public interface IRotate extends IWrenchable { public static SpeedLevel of(float speed) { speed = Math.abs(speed); - if (speed >= CreateConfig.parameters.fastSpeed.get()) { + if (speed >= AllConfigs.SERVER.kinetics.fastSpeed.get()) { return FAST; - } else if (speed >= CreateConfig.parameters.mediumSpeed.get()) { + } else if (speed >= AllConfigs.SERVER.kinetics.mediumSpeed.get()) { return MEDIUM; } return NONE; @@ -42,9 +44,9 @@ public interface IRotate extends IWrenchable { public float getSpeedValue() { switch (this) { case FAST: - return CreateConfig.parameters.fastSpeed.get().floatValue(); + return AllConfigs.SERVER.kinetics.fastSpeed.get().floatValue(); case MEDIUM: - return CreateConfig.parameters.mediumSpeed.get().floatValue(); + return AllConfigs.SERVER.kinetics.mediumSpeed.get().floatValue(); case NONE: default: return 0; @@ -54,7 +56,9 @@ public interface IRotate extends IWrenchable { } public enum StressImpact { - LOW, MEDIUM, HIGH; + LOW, + MEDIUM, + HIGH; public TextFormatting getColor() { return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java index b80726221..2767db839 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java @@ -10,7 +10,7 @@ import java.util.Random; import java.util.UUID; import com.simibubi.create.Create; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.utility.VecHelper; @@ -33,7 +33,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; public abstract class KineticTileEntity extends SmartTileEntity implements ITickableTileEntity { @@ -81,7 +81,7 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick } public float getAddedStressCapacity() { - Map capacityMap = CreateConfig.parameters.stressCapacityEntries; + Map> capacityMap = AllConfigs.SERVER.kinetics.stressValues.impacts; ResourceLocation path = getBlockState().getBlock().getRegistryName(); if (!capacityMap.containsKey(path)) return 0; @@ -89,7 +89,7 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick } public float getStressApplied() { - Map stressEntries = CreateConfig.parameters.stressEntries; + Map> stressEntries = AllConfigs.SERVER.kinetics.stressValues.capacities; ResourceLocation path = getBlockState().getBlock().getRegistryName(); if (!stressEntries.containsKey(path)) return 1; @@ -347,9 +347,9 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick if (minimumRequiredSpeedLevel == null) return true; if (minimumRequiredSpeedLevel == SpeedLevel.MEDIUM) - return Math.abs(getSpeed()) >= CreateConfig.parameters.mediumSpeed.get(); + return Math.abs(getSpeed()) >= AllConfigs.SERVER.kinetics.mediumSpeed.get(); if (minimumRequiredSpeedLevel == SpeedLevel.FAST) - return Math.abs(getSpeed()) >= CreateConfig.parameters.fastSpeed.get(); + return Math.abs(getSpeed()) >= AllConfigs.SERVER.kinetics.fastSpeed.get(); return true; } @@ -402,8 +402,8 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick particleSpeed *= Math.signum(getSpeed()); if (getWorld() instanceof ServerWorld) { - RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, - radius1, radius2, 10, axisChar); + RotationIndicatorParticleData particleData = + new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar); ((ServerWorld) getWorld()).spawnParticle(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java index db16a3cee..87d82193d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java @@ -1,6 +1,5 @@ package com.simibubi.create.modules.contraptions.components.contraptions; -import static com.simibubi.create.CreateConfig.parameters; import static net.minecraft.state.properties.BlockStateProperties.AXIS; import static net.minecraft.state.properties.BlockStateProperties.FACING; @@ -17,7 +16,7 @@ import java.util.function.Function; import org.apache.commons.lang3.tuple.MutablePair; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.components.contraptions.IHaveMovementBehavior.MovementContext; import com.simibubi.create.modules.contraptions.components.contraptions.bearing.BearingContraption; import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock; @@ -72,7 +71,7 @@ public class Contraption { search.add(pos); while (!search.isEmpty()) { - if (chassis.size() > parameters.maxChassisForTranslation.get()) + if (chassis.size() > AllConfigs.SERVER.kinetics.maxChassisForTranslation.get()) return null; BlockPos current = search.remove(0); @@ -202,13 +201,13 @@ public class Contraption { BlockInfo anchorChassis = cluster.get(0); Axis chassisAxis = anchorChassis.state.get(AXIS); - int chassisCoord = chassisAxis.getCoordinate(anchorChassis.pos.getX(), anchorChassis.pos.getY(), - anchorChassis.pos.getZ()); + int chassisCoord = + chassisAxis.getCoordinate(anchorChassis.pos.getX(), anchorChassis.pos.getY(), anchorChassis.pos.getZ()); - Function getChassisPos = position -> new BlockPos( - chassisAxis == Axis.X ? chassisCoord : position.getX(), - chassisAxis == Axis.Y ? chassisCoord : position.getY(), - chassisAxis == Axis.Z ? chassisCoord : position.getZ()); + Function getChassisPos = + position -> new BlockPos(chassisAxis == Axis.X ? chassisCoord : position.getX(), + chassisAxis == Axis.Y ? chassisCoord : position.getY(), + chassisAxis == Axis.Z ? chassisCoord : position.getZ()); // Collect blocks on both sides for (AxisDirection axisDirection : AxisDirection.values()) { @@ -268,8 +267,8 @@ public class Contraption { continue; // Skip if pushed column ended already - for (BlockPos posInbetween = currentPos; !posInbetween.equals( - currentChassisPos); posInbetween = posInbetween.offset(chassisDirection.getOpposite())) { + for (BlockPos posInbetween = currentPos; !posInbetween.equals(currentChassisPos); posInbetween = + posInbetween.offset(chassisDirection.getOpposite())) { BlockState blockState = world.getBlockState(posInbetween); if (!chassisSticky && (blockState.getMaterial().isReplaceable())) @@ -322,7 +321,7 @@ public class Contraption { // Collect chain of chassis for (int offset : new int[] { -1, 1 }) { - for (int distance = 1; distance <= parameters.maxChassisForTranslation.get(); distance++) { + for (int distance = 1; distance <= AllConfigs.SERVER.kinetics.maxChassisForRotation.get(); distance++) { Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); BlockPos currentPos = pos.offset(direction, distance * offset); if (!world.isBlockPresent(currentPos)) @@ -547,7 +546,7 @@ public class Contraption { } public static boolean isFrozen() { - return CreateConfig.parameters.freezePistonConstructs.get(); + return AllConfigs.SERVER.control.freezePistonConstructs.get(); } public void disassemble(IWorld world, BlockPos offset, float yaw, float pitch) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/ChassisTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/ChassisTileEntity.java index fcd28bf15..3da4d9b89 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/ChassisTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/ChassisTileEntity.java @@ -1,10 +1,8 @@ package com.simibubi.create.modules.contraptions.components.contraptions.chassis; -import static com.simibubi.create.CreateConfig.parameters; - import com.simibubi.create.AllPackets; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.block.SyncedTileEntity; import net.minecraft.nbt.CompoundNBT; @@ -19,7 +17,7 @@ public class ChassisTileEntity extends SyncedTileEntity implements ITickableTile public ChassisTileEntity() { super(AllTileEntities.CHASSIS.type); - newRange = range = CreateConfig.parameters.maxChassisRange.get() / 2; + newRange = range = AllConfigs.SERVER.kinetics.maxChassisRange.get() / 2; } @Override @@ -46,7 +44,7 @@ public class ChassisTileEntity extends SyncedTileEntity implements ITickableTile } public void setRangeLazily(int range) { - this.newRange = MathHelper.clamp(range, 1, parameters.maxChassisRange.get()); + this.newRange = MathHelper.clamp(range, 1, AllConfigs.SERVER.kinetics.maxChassisRange.get()); if (newRange == this.range) return; this.lastModified = 0; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java index 5f0b1c75d..34ab16bd0 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; @@ -99,7 +99,9 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock { } public enum PistonState implements IStringSerializable { - RETRACTED, MOVING, EXTENDED; + RETRACTED, + MOVING, + EXTENDED; @Override public String getName() { @@ -114,7 +116,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock { BlockPos pistonBase = pos; boolean dropBlocks = player == null || !player.isCreative(); - Integer maxPoles = CreateConfig.parameters.maxPistonPoles.get(); + Integer maxPoles = maxAllowedPistonPoles(); for (int offset = 1; offset < maxPoles; offset++) { BlockPos currentPos = pos.offset(direction, offset); BlockState block = worldIn.getBlockState(currentPos); @@ -151,6 +153,10 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock { super.onBlockHarvested(worldIn, pos, state, player); } + public static int maxAllowedPistonPoles() { + return AllConfigs.SERVER.kinetics.maxPistonPoles.get(); + } + @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonHeadBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonHeadBlock.java index 9540617e5..7a7367232 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonHeadBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonHeadBlock.java @@ -1,7 +1,6 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateConfig; import com.simibubi.create.foundation.block.IHaveNoBlockItem; import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.utility.AllShapes; @@ -50,7 +49,7 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements BlockPos pistonHead = pos; BlockPos pistonBase = null; - for (int offset = 1; offset < CreateConfig.parameters.maxPistonPoles.get(); offset++) { + for (int offset = 1; offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset++) { BlockPos currentPos = pos.offset(direction.getOpposite(), offset); BlockState block = worldIn.getBlockState(currentPos); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonContraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonContraption.java index c867d471e..4c75fe697 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonContraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonContraption.java @@ -3,13 +3,13 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston; import static com.simibubi.create.AllBlocks.MECHANICAL_PISTON_HEAD; import static com.simibubi.create.AllBlocks.PISTON_POLE; import static com.simibubi.create.AllBlocks.STICKY_MECHANICAL_PISTON; -import static com.simibubi.create.CreateConfig.parameters; import static net.minecraft.state.properties.BlockStateProperties.FACING; import java.util.ArrayList; import java.util.List; import com.simibubi.create.AllBlocks; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.components.contraptions.Contraption; import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState; @@ -63,7 +63,7 @@ public class PistonContraption extends Contraption { extensionsInFront++; nextBlock = world.getBlockState(actualStart.offset(direction)); - if (extensionsInFront > parameters.maxPistonPoles.get()) + if (extensionsInFront > MechanicalPistonBlock.maxAllowedPistonPoles()) return false; } } @@ -87,7 +87,7 @@ public class PistonContraption extends Contraption { extensionsInBack++; nextBlock = world.getBlockState(end.offset(direction.getOpposite())); - if (extensionsInFront + extensionsInBack > parameters.maxPistonPoles.get()) + if (extensionsInFront + extensionsInBack > MechanicalPistonBlock.maxAllowedPistonPoles()) return false; } @@ -112,7 +112,7 @@ public class PistonContraption extends Contraption { @Override protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, List frontier) { - for (int offset = 1; offset <= parameters.maxChassisRange.get(); offset++) { + for (int offset = 1; offset <= AllConfigs.SERVER.kinetics.maxChassisRange.get(); offset++) { BlockPos currentPos = pos.offset(direction, offset); if (!world.isAreaLoaded(currentPos, 1)) return false; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonPoleBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonPoleBlock.java index 08d35aa31..e0fe41c39 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonPoleBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/PistonPoleBlock.java @@ -1,7 +1,6 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateConfig; import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState; @@ -35,8 +34,8 @@ public class PistonPoleBlock extends ProperDirectionalBlock { BlockPos pistonBase = null; for (int modifier : new int[] { 1, -1 }) { - for (int offset = modifier; modifier * offset < CreateConfig.parameters.maxPistonPoles - .get(); offset += modifier) { + for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset += + modifier) { BlockPos currentPos = pos.offset(direction, offset); BlockState block = worldIn.getBlockState(currentPos); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index 0138a98e7..1a3652556 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -7,7 +7,7 @@ import java.util.UUID; import com.simibubi.create.AllRecipes; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.block.SyncedTileEntity; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.modules.contraptions.processing.ProcessingInventory; @@ -117,7 +117,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen if (!(processingEntity instanceof ItemEntity)) { processingEntity.attackEntityFrom(CrushingWheelTileEntity.damageSource, - CreateConfig.parameters.crushingDamage.get()); + AllConfigs.SERVER.kinetics.crushingDamage.get()); if (!processingEntity.isAlive()) { processingEntity.setPosition(outPos.x, outPos.y - .75f, outPos.z); } @@ -232,7 +232,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen } public static boolean isFrozen() { - return CreateConfig.parameters.freezeCrushing.get(); + return AllConfigs.SERVER.control.freezeCrushing.get(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java index 716a0c516..904e4c1d3 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java @@ -6,7 +6,7 @@ import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import com.simibubi.create.CreateClientConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.modules.contraptions.particle.AirFlowParticleData; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; @@ -60,7 +60,7 @@ public class AirCurrent { if (world.isRemote) { float offset = pushing ? 0.5f : maxDistance + .5f; Vec3d pos = VecHelper.getCenterOf(source.getPos()).add(new Vec3d(facing.getDirectionVec()).scale(offset)); - if (world.rand.nextFloat() < CreateClientConfig.instance.fanParticleDensity.get()) + if (world.rand.nextFloat() < AllConfigs.CLIENT.fanParticleDensity.get()) world.addParticle(new AirFlowParticleData(source.getPos()), pos.x, pos.y, pos.z, 0, 0, 0); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanTileEntity.java index 4e18cf587..246c49e87 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanTileEntity.java @@ -1,10 +1,9 @@ package com.simibubi.create.modules.contraptions.components.fan; -import static com.simibubi.create.CreateConfig.parameters; - import com.simibubi.create.AllBlockTags; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CKinetics; import com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity; import net.minecraft.nbt.CompoundNBT; @@ -49,7 +48,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity { public float getAddedStressCapacity() { return isGenerator ? super.getAddedStressCapacity() : 0; } - + @Override public float getStressApplied() { return isGenerator ? 0 : super.getStressApplied(); @@ -57,7 +56,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity { @Override public float getGeneratedSpeed() { - return isGenerator ? CreateConfig.parameters.generatingFanSpeed.get() : 0; + return isGenerator ? AllConfigs.SERVER.kinetics.generatingFanSpeed.get() : 0; } public void updateGenerator() { @@ -75,9 +74,10 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity { public float getMaxDistance() { float speed = Math.abs(this.getSpeed()); - float distanceFactor = Math.min(speed / parameters.fanRotationArgmax.get(), 1); - float pushDistance = MathHelper.lerp(distanceFactor, 3, parameters.fanPushDistance.get()); - float pullDistance = MathHelper.lerp(distanceFactor, 3f, parameters.fanPullDistance.get()); + CKinetics config = AllConfigs.SERVER.kinetics; + float distanceFactor = Math.min(speed / config.fanRotationArgmax.get(), 1); + float pushDistance = MathHelper.lerp(distanceFactor, 3, config.fanPushDistance.get()); + float pullDistance = MathHelper.lerp(distanceFactor, 3f, config.fanPullDistance.get()); return this.getSpeed() > 0 ? pushDistance : pullDistance; } @@ -103,7 +103,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity { super.tick(); if (!world.isRemote && airCurrentUpdateCooldown-- <= 0) { - airCurrentUpdateCooldown = parameters.fanBlockCheckRate.get(); + airCurrentUpdateCooldown = AllConfigs.SERVER.kinetics.fanBlockCheckRate.get(); updateAirFlow = true; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/NozzleTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/NozzleTileEntity.java index ec1847e29..2657ce22f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/NozzleTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/NozzleTileEntity.java @@ -5,7 +5,7 @@ import java.util.Iterator; import java.util.List; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.utility.VecHelper; @@ -69,12 +69,14 @@ public class NozzleTileEntity extends SmartTileEntity { float range = calcRange(); if (this.range != range) setRange(range); - + Vec3d center = VecHelper.getCenterOf(pos); if (world.isRemote && range != 0) { - if (world.rand.nextInt(MathHelper.clamp((CreateConfig.parameters.fanPushDistance.get() - (int) range), 1, 10)) == 0) { + if (world.rand.nextInt( + MathHelper.clamp((AllConfigs.SERVER.kinetics.fanPushDistance.get() - (int) range), 1, 10)) == 0) { Vec3d start = VecHelper.offsetRandomly(center, world.rand, pushing ? 1 : range / 2); - Vec3d motion = center.subtract(start).normalize().scale(MathHelper.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1)); + Vec3d motion = center.subtract(start).normalize() + .scale(MathHelper.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1)); world.addParticle(ParticleTypes.POOF, start.x, start.y, start.z, motion.x, motion.y, motion.z); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java index e24f068a2..363d996c2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java @@ -4,7 +4,7 @@ import java.util.UUID; import com.simibubi.create.AllPackets; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity; import net.minecraft.nbt.CompoundNBT; @@ -52,7 +52,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity { public void setSpeedValueLazily(int speed) { if (newGeneratedSpeed == speed) return; - Integer max = CreateConfig.parameters.maxMotorSpeed.get(); + Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get(); newGeneratedSpeed = MathHelper.clamp(speed, -max, max); this.lastModified = 0; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java index 509373a90..6bba3385b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java @@ -4,7 +4,7 @@ import java.util.LinkedList; import java.util.List; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.item.IAddedByOther; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part; @@ -29,12 +29,12 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { public BeltConnectorItem(Properties properties) { super(AllBlocks.BELT.block, properties); } - + @Override public String getTranslationKey() { return getDefaultTranslationKey(); } - + @Override public ActionResultType onItemUse(ItemUseContext context) { if (context.isPlacerSneaking()) { @@ -175,7 +175,7 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { return false; if (!world.isAreaLoaded(second, 1)) return false; - if (!second.withinDistance(first, CreateConfig.parameters.maxBeltLength.get())) + if (!second.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get())) return false; BlockPos diff = second.subtract(first); @@ -201,8 +201,8 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { BlockPos step = new BlockPos(Math.signum(diff.getX()), Math.signum(diff.getY()), Math.signum(diff.getZ())); int limit = 1000; - for (BlockPos currentPos = first.add(step); !currentPos.equals(second) - && limit-- > 0; currentPos = currentPos.add(step)) { + for (BlockPos currentPos = first.add(step); !currentPos.equals(second) && limit-- > 0; currentPos = + currentPos.add(step)) { BlockState blockState = world.getBlockState(currentPos); if (AllBlocks.SHAFT.typeOf(blockState) && blockState.get(ShaftBlock.AXIS) == axis) continue; @@ -224,5 +224,4 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { return true; } - } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItemHandler.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItemHandler.java index b7210dd91..19760cd15 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItemHandler.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItemHandler.java @@ -6,7 +6,7 @@ import java.util.Random; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; @@ -70,10 +70,11 @@ public class BeltConnectorItemHandler { return; if (!AllBlocks.SHAFT.typeOf(world.getBlockState(selected))) selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace()); - if (!selected.withinDistance(first, CreateConfig.parameters.maxBeltLength.get())) + if (!selected.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get())) return; - boolean canConnect = BeltConnectorItem.validateAxis(world, selected) && BeltConnectorItem.canConnect(world, first, selected); + boolean canConnect = + BeltConnectorItem.validateAxis(world, selected) && BeltConnectorItem.canConnect(world, first, selected); Vec3d start = new Vec3d(first); Vec3d end = new Vec3d(selected); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/SpeedGaugeTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/SpeedGaugeTileEntity.java index a2dc93a4f..70876994a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/SpeedGaugeTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/SpeedGaugeTileEntity.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.contraptions.relays.gauge; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; @@ -17,9 +17,9 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity { public void onSpeedChanged(float prevSpeed) { super.onSpeedChanged(prevSpeed); float speed = Math.abs(getSpeed()); - float medium = CreateConfig.parameters.mediumSpeed.get().floatValue(); - float fast = CreateConfig.parameters.fastSpeed.get().floatValue(); - float max = CreateConfig.parameters.maxRotationSpeed.get().floatValue(); + float medium = AllConfigs.SERVER.kinetics.mediumSpeed.get().floatValue(); + float fast = AllConfigs.SERVER.kinetics.fastSpeed.get().floatValue(); + float max = AllConfigs.SERVER.kinetics.maxRotationSpeed.get().floatValue(); color = ColorHelper.mixColors(SpeedLevel.of(speed).getColor(), 0xffffff, .25f); if (speed == 0) { diff --git a/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java b/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java index 1da15168a..3d668afce 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/ChromaticCompoundCubeItem.java @@ -3,7 +3,8 @@ package com.simibubi.create.modules.curiosities; import java.util.Random; import com.simibubi.create.AllItems; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CCuriosities; import com.simibubi.create.foundation.item.IItemWithColorHandler; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; @@ -40,8 +41,8 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan public int getColor(ItemStack stack, int layer) { Minecraft mc = Minecraft.getInstance(); float pt = mc.getRenderPartialTicks(); - float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) - + (AnimationTickHolder.getRenderTick() / 10f); + float progress = + (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTick() / 10f); if (layer == 0) return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); if (layer == 1) @@ -66,7 +67,7 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan @Override public double getDurabilityForDisplay(ItemStack stack) { int light = stack.getOrCreateTag().getInt("CollectingLight"); - return 1 - light / (float) CreateConfig.parameters.lightSourceCountForRefinedRadiance.get(); + return 1 - light / (float) AllConfigs.SERVER.curiosities.lightSourceCountForRefinedRadiance.get(); } @Override @@ -94,9 +95,10 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan CompoundNBT itemData = entity.getItem().getOrCreateTag(); Vec3d positionVec = entity.getPositionVec(); + CCuriosities config = AllConfigs.SERVER.curiosities; if (world.isRemote) { int light = itemData.getInt("CollectingLight"); - if (random.nextInt(CreateConfig.parameters.lightSourceCountForRefinedRadiance.get() + 20) < light) { + if (random.nextInt(config.lightSourceCountForRefinedRadiance.get() + 20) < light) { Vec3d start = VecHelper.offsetRandomly(positionVec, random, 3); Vec3d motion = positionVec.subtract(start).normalize().scale(.2f); world.addParticle(ParticleTypes.END_ROD, start.x, start.y, start.z, motion.x, motion.y, motion.z); @@ -105,18 +107,18 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan } // Convert to Shadow steel if in void - if (y < 0 && y - yMotion < -10 && CreateConfig.parameters.enableShadowSteelRecipe.get()) { + if (y < 0 && y - yMotion < -10 && config.enableShadowSteelRecipe.get()) { ItemStack newStack = AllItems.SHADOW_STEEL.asStack(); newStack.setCount(stack.getCount()); data.putBoolean("FromVoid", true); entity.setItem(newStack); } - if (!CreateConfig.parameters.enableRefinedRadianceRecipe.get()) + if (!config.enableRefinedRadianceRecipe.get()) return false; // Convert to Refined Radiance if eaten enough light sources - if (itemData.getInt("CollectingLight") >= CreateConfig.parameters.lightSourceCountForRefinedRadiance.get()) { + if (itemData.getInt("CollectingLight") >= config.lightSourceCountForRefinedRadiance.get()) { ItemStack newStack = AllItems.REFINED_RADIANCE.asStack(); ItemEntity newEntity = new ItemEntity(world, entity.posX, entity.posY, entity.posZ, newStack); newEntity.setMotion(entity.getMotion()); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java index 4cd9864e0..0bfa46d21 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java @@ -1,13 +1,12 @@ package com.simibubi.create.modules.curiosities.symmetry; -import static com.simibubi.create.CreateConfig.parameters; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.simibubi.create.AllPackets; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.item.IHaveCustomItemModel; @@ -174,7 +173,7 @@ public class SymmetryWandItem extends Item implements IHaveCustomItemModel { SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound(SYMMETRY)); Vec3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(new Vec3d(pos)) > parameters.maxSymmetryWandRange.get()) + if (mirrorPos.distanceTo(new Vec3d(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; if (!player.isCreative() && isHoldingBlock(player, block) && BlockHelper.findAndRemoveInInventory(block, player, 1) == 0) @@ -236,7 +235,7 @@ public class SymmetryWandItem extends Item implements IHaveCustomItemModel { SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound(SYMMETRY)); Vec3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(new Vec3d(pos)) > parameters.maxSymmetryWandRange.get()) + if (mirrorPos.distanceTo(new Vec3d(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; symmetry.process(blockSet); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java index 4f8a2c460..92eaf69c2 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import com.simibubi.create.AllRecipes; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.processing.ProcessingIngredient; import com.simibubi.create.modules.contraptions.processing.ProcessingOutput; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe; @@ -34,15 +34,18 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { } public static boolean canPolish(World world, ItemStack stack) { - return (stack.isDamageable() && CreateConfig.parameters.enableSandPaperToolPolishing.get()) - || !getMatchingRecipes(world, stack).isEmpty(); + return (stack.isDamageable() && isPolishingEnabled()) || !getMatchingRecipes(world, stack).isEmpty(); + } + + public static Boolean isPolishingEnabled() { + return AllConfigs.SERVER.curiosities.enableSandPaperToolPolishing.get(); } public static ItemStack applyPolish(World world, Vec3d position, ItemStack stack, ItemStack sandPaperStack) { List> matchingRecipes = getMatchingRecipes(world, stack); if (!matchingRecipes.isEmpty()) return matchingRecipes.get(0).getCraftingResult(new SandPaperInv(stack)).copy(); - if (stack.isDamageable() && CreateConfig.parameters.enableSandPaperToolPolishing.get()) { + if (stack.isDamageable() && isPolishingEnabled()) { stack.setDamage(stack.getDamage() - (stack.getMaxDamage() - stack.getDamage()) / 2); diff --git a/src/main/java/com/simibubi/create/modules/gardens/CocoaLogBlock.java b/src/main/java/com/simibubi/create/modules/gardens/CocoaLogBlock.java index 200552d29..e2edf3efd 100644 --- a/src/main/java/com/simibubi/create/modules/gardens/CocoaLogBlock.java +++ b/src/main/java/com/simibubi/create/modules/gardens/CocoaLogBlock.java @@ -5,7 +5,7 @@ import java.util.Collections; import java.util.List; import java.util.Random; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -53,7 +53,7 @@ public class CocoaLogBlock extends RotatedPillarBlock implements IGrowable { @Override public void grow(World world, Random random, BlockPos pos, BlockState state) { - if (random.nextDouble() > CreateConfig.parameters.cocoaLogGrowthSpeed.get() / 100D) + if (random.nextDouble() > AllConfigs.SERVER.curiosities.cocoaLogGrowthSpeed.get() / 100D) return; int age = state.get(AGE); diff --git a/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java b/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java index 35ac58c43..6d0994a67 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java +++ b/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Optional; import com.simibubi.create.AllRecipes; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe; @@ -51,7 +51,9 @@ public class InWorldProcessing { public static SplashingInv splashingInv = new SplashingInv(); public enum Type { - SMOKING, BLASTING, SPLASHING + SMOKING, + BLASTING, + SPLASHING ; @@ -105,8 +107,8 @@ public class InWorldProcessing { if (type == Type.SPLASHING) { splashingInv.setInventorySlotContents(0, stack); - Optional recipe = world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), - splashingInv, world); + Optional recipe = + world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), splashingInv, world); return recipe.isPresent(); } @@ -135,7 +137,7 @@ public class InWorldProcessing { Type type) { if (transported.processedBy != type) { transported.processedBy = type; - transported.processingTime = CreateConfig.parameters.inWorldProcessingTime.get() + 1; + transported.processingTime = AllConfigs.SERVER.kinetics.inWorldProcessingTime.get() + 1; if (!canProcess(transported.stack, type, belt.getWorld())) transported.processingTime = -1; return null; @@ -158,8 +160,8 @@ public class InWorldProcessing { private static List process(ItemStack stack, Type type, World world) { if (type == Type.SPLASHING) { splashingInv.setInventorySlotContents(0, stack); - Optional recipe = world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), - splashingInv, world); + Optional recipe = + world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), splashingInv, world); if (recipe.isPresent()) return applyRecipeOn(stack, recipe.get()); return null; @@ -174,8 +176,8 @@ public class InWorldProcessing { FurnaceTileEntity furnace = new FurnaceTileEntity(); furnace.setWorld(world); furnace.setInventorySlotContents(0, stack); - Optional smeltingRecipe = world.getRecipeManager().getRecipe(IRecipeType.SMELTING, furnace, - world); + Optional smeltingRecipe = + world.getRecipeManager().getRecipe(IRecipeType.SMELTING, furnace, world); if (!smokingRecipe.isPresent()) { if (smeltingRecipe.isPresent()) @@ -184,8 +186,8 @@ public class InWorldProcessing { BlastFurnaceTileEntity blastFurnace = new BlastFurnaceTileEntity(); blastFurnace.setWorld(world); blastFurnace.setInventorySlotContents(0, stack); - Optional blastingRecipe = world.getRecipeManager().getRecipe(IRecipeType.BLASTING, - blastFurnace, world); + Optional blastingRecipe = + world.getRecipeManager().getRecipe(IRecipeType.BLASTING, blastFurnace, world); if (blastingRecipe.isPresent()) return applyRecipeOn(stack, blastingRecipe.get()); @@ -213,7 +215,7 @@ public class InWorldProcessing { if (!processing.contains("Type") || Type.valueOf(processing.getString("Type")) != type) { processing.putString("Type", type.name()); - processing.putInt("Time", CreateConfig.parameters.inWorldProcessingTime.get() + 1); + processing.putInt("Time", AllConfigs.SERVER.kinetics.inWorldProcessingTime.get() + 1); } int value = processing.getInt("Time") - 1; @@ -288,7 +290,7 @@ public class InWorldProcessing { } public static boolean isFrozen() { - return CreateConfig.parameters.freezeInWorldProcessing.get(); + return AllConfigs.SERVER.control.freezeInWorldProcessing.get(); } } diff --git a/src/main/java/com/simibubi/create/modules/logistics/RedstoneLinkNetworkHandler.java b/src/main/java/com/simibubi/create/modules/logistics/RedstoneLinkNetworkHandler.java index 8d445a3b6..84068e0d5 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/modules/logistics/RedstoneLinkNetworkHandler.java @@ -9,7 +9,7 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.Create; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.linked.LinkBehaviour; import net.minecraft.item.Item; @@ -115,7 +115,7 @@ public class RedstoneLinkNetworkHandler { } public static boolean withinRange(LinkBehaviour from, LinkBehaviour to) { - return from.getPos().withinDistance(to.getPos(), CreateConfig.parameters.linkRange.get()); + return from.getPos().withinDistance(to.getPos(), AllConfigs.SERVER.logistics.linkRange.get()); } public Map, Set> networksIn(IWorld world) { diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/extractor/ExtractorTileEntity.java b/src/main/java/com/simibubi/create/modules/logistics/block/extractor/ExtractorTileEntity.java index 1289048fb..83de2c4c9 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/extractor/ExtractorTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/extractor/ExtractorTileEntity.java @@ -4,7 +4,7 @@ import java.util.List; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.CreateConfig; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; @@ -47,17 +47,17 @@ public class ExtractorTileEntity extends SmartTileEntity { @Override public void addBehaviours(List behaviours) { - int delay = CreateConfig.parameters.extractorDelay.get(); - extracting = new SingleTargetAutoExtractingBehaviour(this, - () -> AttachedLogisticalBlock.getBlockFacing(getBlockState()), this::onExtract, delay) - .pauseWhen(this::isPowered).waitUntil(this::canExtract); + int delay = AllConfigs.SERVER.logistics.extractorDelay.get(); + extracting = + new SingleTargetAutoExtractingBehaviour(this, () -> AttachedLogisticalBlock.getBlockFacing(getBlockState()), + this::onExtract, delay).pauseWhen(this::isPowered).waitUntil(this::canExtract); behaviours.add(extracting); if (slots == null) slots = new SlotPositioning(ExtractorBlock::getFilterSlotPosition, ExtractorBlock::getFilterSlotOrientation) .scale(.4f); - filtering = new FilteringBehaviour(this).withCallback(this::filterChanged).withSlotPositioning(slots) - .showCount(); + filtering = + new FilteringBehaviour(this).withCallback(this::filterChanged).withSlotPositioning(slots).showCount(); behaviours.add(filtering); } @@ -127,7 +127,8 @@ public class ExtractorTileEntity extends SmartTileEntity { boolean onBelt = isTargetingBelt(); if (extractingToBelt != onBelt) { extractingToBelt = onBelt; - ((AutoExtractingBehaviour) extracting).setDelay(onBelt ? 0 : CreateConfig.parameters.extractorDelay.get()); + ((AutoExtractingBehaviour) extracting) + .setDelay(onBelt ? 0 : AllConfigs.SERVER.logistics.extractorDelay.get()); } } diff --git a/src/main/java/com/simibubi/create/modules/palettes/VolcanicRockBlock.java b/src/main/java/com/simibubi/create/modules/palettes/ScoriaBlock.java similarity index 91% rename from src/main/java/com/simibubi/create/modules/palettes/VolcanicRockBlock.java rename to src/main/java/com/simibubi/create/modules/palettes/ScoriaBlock.java index c877130aa..caa4801d9 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/VolcanicRockBlock.java +++ b/src/main/java/com/simibubi/create/modules/palettes/ScoriaBlock.java @@ -10,9 +10,9 @@ import net.minecraft.block.material.MaterialColor; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; -public class VolcanicRockBlock extends Block implements IHaveColoredVertices { +public class ScoriaBlock extends Block implements IHaveColoredVertices { - public VolcanicRockBlock() { + public ScoriaBlock() { super(Properties.from(Blocks.ANDESITE)); } diff --git a/src/main/java/com/simibubi/create/modules/schematics/ClientSchematicLoader.java b/src/main/java/com/simibubi/create/modules/schematics/ClientSchematicLoader.java index 185443205..e2b215f62 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/ClientSchematicLoader.java +++ b/src/main/java/com/simibubi/create/modules/schematics/ClientSchematicLoader.java @@ -1,7 +1,5 @@ package com.simibubi.create.modules.schematics; -import static com.simibubi.create.CreateConfig.parameters; - import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -18,6 +16,7 @@ import java.util.Map; import com.simibubi.create.AllPackets; import com.simibubi.create.Create; +import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket; @@ -67,7 +66,7 @@ public class ClientSchematicLoader { long size = Files.size(path); // Too big - Integer maxSize = parameters.maxTotalSchematicSize.get(); + Integer maxSize = AllConfigs.SERVER.schematics.maxTotalSchematicSize.get(); if (size > maxSize * 1000) { Minecraft.getInstance().player.sendMessage(new StringTextComponent( Lang.translate("schematics.uploadTooLarge") + " (" + size / 1000 + " KB).")); @@ -86,7 +85,7 @@ public class ClientSchematicLoader { private void continueUpload(String schematic) { if (activeUploads.containsKey(schematic)) { - Integer maxPacketSize = parameters.maxSchematicPacketSize.get(); + Integer maxPacketSize = AllConfigs.SERVER.schematics.maxSchematicPacketSize.get(); byte[] data = new byte[maxPacketSize]; try { int status = activeUploads.get(schematic).read(data); diff --git a/src/main/java/com/simibubi/create/modules/schematics/ServerSchematicLoader.java b/src/main/java/com/simibubi/create/modules/schematics/ServerSchematicLoader.java index 67eaff271..af7c9afc7 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/ServerSchematicLoader.java +++ b/src/main/java/com/simibubi/create/modules/schematics/ServerSchematicLoader.java @@ -1,7 +1,5 @@ package com.simibubi.create.modules.schematics; -import static com.simibubi.create.CreateConfig.parameters; - import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; @@ -18,6 +16,8 @@ import java.util.stream.Stream; import com.simibubi.create.AllBlocks; import com.simibubi.create.Create; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CSchematics; import com.simibubi.create.foundation.type.DimensionPos; import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity; @@ -54,7 +54,7 @@ public class ServerSchematicLoader { } public String getSchematicPath() { - return parameters.schematicPath.get(); + return "schematics/uploaded"; } public void tick() { @@ -63,7 +63,7 @@ public class ServerSchematicLoader { for (String upload : activeUploads.keySet()) { SchematicUploadEntry entry = activeUploads.get(upload); - if (entry.idleTime++ > parameters.schematicIdleTimeout.get()) { + if (entry.idleTime++ > getConfig().schematicIdleTimeout.get()) { Create.logger.warn("Schematic Upload timed out: " + upload); deadEntries.add(upload); } @@ -90,7 +90,7 @@ public class ServerSchematicLoader { } // Too big - Integer maxFileSize = parameters.maxTotalSchematicSize.get(); + Integer maxFileSize = getConfig().maxTotalSchematicSize.get(); if (size > maxFileSize * 1000) { player.sendMessage(new TranslationTextComponent("create.schematics.uploadTooLarge") .appendSibling(new StringTextComponent(" (" + size / 1000 + " KB)."))); @@ -114,7 +114,7 @@ public class ServerSchematicLoader { // Too many Schematics Stream list = Files.list(Paths.get(playerPath)); - if (list.count() >= parameters.maxSchematics.get()) { + if (list.count() >= getConfig().maxSchematics.get()) { Stream list2 = Files.list(Paths.get(playerPath)); Optional lastFilePath = list2.filter(f -> !Files.isDirectory(f)) .min(Comparator.comparingLong(f -> f.toFile().lastModified())); @@ -126,8 +126,8 @@ public class ServerSchematicLoader { list.close(); // Open Stream - OutputStream writer = Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), - StandardOpenOption.CREATE_NEW); + OutputStream writer = + Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW); activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, dimPos)); // Notify Tile Entity @@ -140,6 +140,10 @@ public class ServerSchematicLoader { } } + public CSchematics getConfig() { + return AllConfigs.SERVER.schematics; + } + public void handleWriteRequest(ServerPlayerEntity player, String schematic, byte[] data) { String playerSchematicId = player.getName().getFormattedText() + "/" + schematic; @@ -148,7 +152,7 @@ public class ServerSchematicLoader { entry.bytesUploaded += data.length; // Size Validations - if (data.length > parameters.maxSchematicPacketSize.get()) { + if (data.length > getConfig().maxSchematicPacketSize.get()) { Create.logger.warn("Oversized Upload Packet received: " + playerSchematicId); cancelUpload(playerSchematicId); return; @@ -167,8 +171,8 @@ public class ServerSchematicLoader { if (!AllBlocks.SCHEMATIC_TABLE.typeOf(blockState)) return; - SchematicTableTileEntity tileEntity = (SchematicTableTileEntity) entry.tablePos.world - .getTileEntity(entry.tablePos.pos); + SchematicTableTileEntity tileEntity = + (SchematicTableTileEntity) entry.tablePos.world.getTileEntity(entry.tablePos.pos); tileEntity.uploadingProgress = (float) ((double) entry.bytesUploaded / entry.totalBytes); tileEntity.sendUpdate = true; diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java index 984311569..4b5be5323 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java @@ -1,7 +1,5 @@ package com.simibubi.create.modules.schematics.block; -import static com.simibubi.create.CreateConfig.parameters; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -9,6 +7,8 @@ import java.util.List; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllTileEntities; +import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.config.CSchematics; import com.simibubi.create.foundation.block.SyncedTileEntity; import com.simibubi.create.foundation.type.Cuboid; import com.simibubi.create.modules.schematics.MaterialChecklist; @@ -363,7 +363,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka refillFuelIfPossible(); // Update Printer - skipsLeft = parameters.schematicannonSkips.get(); + skipsLeft = config().schematicannonSkips.get(); blockSkipped = true; while (blockSkipped && skipsLeft-- > 0) @@ -380,6 +380,10 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka } } + public CSchematics config() { + return AllConfigs.SERVER.schematics; + } + protected void tickPrinter() { ItemStack blueprint = inventory.getStackInSlot(0); blockSkipped = false; @@ -492,14 +496,14 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka else statusMsg = "clearing"; launchBlock(target, blockState); - printerCooldown = parameters.schematicannonDelay.get(); + printerCooldown = config().schematicannonDelay.get(); fuelLevel -= getFuelUsageRate(); sendUpdate = true; missingBlock = null; } public double getFuelUsageRate() { - return parameters.schematicannonFuelUsage.get() / 100f; + return config().schematicannonFuelUsage.get() / 100f; } protected void initializePrinter(ItemStack blueprint) { @@ -706,7 +710,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka } public double getFuelAddedByGunPowder() { - return parameters.schematicannonGunpowderWorth.get() / 100f; + return config().schematicannonGunpowderWorth.get() / 100f; } protected void tickPaperPrinter() { diff --git a/src/main/java/com/simibubi/create/modules/schematics/item/SchematicItem.java b/src/main/java/com/simibubi/create/modules/schematics/item/SchematicItem.java index 32a9309a5..fe23c977e 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/item/SchematicItem.java +++ b/src/main/java/com/simibubi/create/modules/schematics/item/SchematicItem.java @@ -10,7 +10,6 @@ import java.util.List; import org.apache.commons.io.IOUtils; import com.simibubi.create.AllItems; -import com.simibubi.create.CreateConfig; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.schematics.client.SchematicEditScreen; @@ -99,7 +98,7 @@ public class SchematicItem extends Item { String filepath = ""; if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER) - filepath = CreateConfig.parameters.schematicPath.get() + "/" + owner + "/" + schematic; + filepath = "schematics/uploaded/" + owner + "/" + schematic; else filepath = "schematics/" + schematic; diff --git a/src/main/resources/assets/create/blockstates/scoria.json b/src/main/resources/assets/create/blockstates/scoria.json new file mode 100644 index 000000000..0557c00d7 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/scoria.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "create:block/palettes/scoria" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/blockstates/volcanic_rock.json b/src/main/resources/assets/create/blockstates/volcanic_rock.json deleted file mode 100644 index d6580ce19..000000000 --- a/src/main/resources/assets/create/blockstates/volcanic_rock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "": { "model": "create:block/palettes/volcanic_rock" } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/palettes/volcanic_rock.json b/src/main/resources/assets/create/models/block/palettes/scoria.json similarity index 57% rename from src/main/resources/assets/create/models/block/palettes/volcanic_rock.json rename to src/main/resources/assets/create/models/block/palettes/scoria.json index 42d465d29..dfb033708 100644 --- a/src/main/resources/assets/create/models/block/palettes/volcanic_rock.json +++ b/src/main/resources/assets/create/models/block/palettes/scoria.json @@ -1,6 +1,6 @@ { "parent": "block/cube_all", "textures": { - "all": "create:block/volcanic_rock" + "all": "create:block/scoria" } } diff --git a/src/main/resources/assets/create/models/item/scoria.json b/src/main/resources/assets/create/models/item/scoria.json new file mode 100644 index 000000000..4cee5b4aa --- /dev/null +++ b/src/main/resources/assets/create/models/item/scoria.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/palettes/scoria" +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/volcanic_rock.json b/src/main/resources/assets/create/models/item/volcanic_rock.json deleted file mode 100644 index b3e8cc133..000000000 --- a/src/main/resources/assets/create/models/item/volcanic_rock.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "create:block/palettes/volcanic_rock" -} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/block/volcanic_rock.png b/src/main/resources/assets/create/textures/block/scoria.png similarity index 100% rename from src/main/resources/assets/create/textures/block/volcanic_rock.png rename to src/main/resources/assets/create/textures/block/scoria.png