The Config Rework

- Created a new config foundation
- Moved all configurable values to the new system
- Worldgen can now be controlled by the config
- Worldgen reloads dynamically when the config file changes
- Tweaked Worldgen parameters and reworked feature registration
- Added Create's stone variants to World gen
This commit is contained in:
simibubi 2020-02-07 19:25:38 +01:00
parent 378a1566e4
commit 394263c04f
68 changed files with 1090 additions and 871 deletions

View file

@ -71,7 +71,7 @@ import com.simibubi.create.modules.palettes.GlassPaneBlock;
import com.simibubi.create.modules.palettes.HorizontalCTGlassBlock; import com.simibubi.create.modules.palettes.HorizontalCTGlassBlock;
import com.simibubi.create.modules.palettes.LayeredCTBlock; import com.simibubi.create.modules.palettes.LayeredCTBlock;
import com.simibubi.create.modules.palettes.VerticalCTGlassBlock; 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.CreativeCrateBlock;
import com.simibubi.create.modules.schematics.block.SchematicTableBlock; import com.simibubi.create.modules.schematics.block.SchematicTableBlock;
import com.simibubi.create.modules.schematics.block.SchematicannonBlock; import com.simibubi.create.modules.schematics.block.SchematicannonBlock;
@ -248,7 +248,7 @@ public enum AllBlocks {
DOLOMITE_LAYERS( DOLOMITE_LAYERS(
new LayeredCTBlock(Properties.from(DOLOMITE.block), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)), new LayeredCTBlock(Properties.from(DOLOMITE.block), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)),
VOLCANIC_ROCK(new VolcanicRockBlock()), SCORIA(new ScoriaBlock()),
__MATERIALS__(), __MATERIALS__(),
COPPER_ORE(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)), COPPER_ORE(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)),

View file

@ -3,6 +3,7 @@ package com.simibubi.create;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.config.AllConfigs;
import com.simibubi.create.foundation.behaviour.filtering.FilteringHandler; import com.simibubi.create.foundation.behaviour.filtering.FilteringHandler;
import com.simibubi.create.foundation.block.IHaveScrollableValue; import com.simibubi.create.foundation.block.IHaveScrollableValue;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
@ -119,7 +120,7 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public static void addToItemTooltip(ItemTooltipEvent event) { public static void addToItemTooltip(ItemTooltipEvent event) {
if (!CreateClientConfig.instance.enableTooltips.get()) if (!AllConfigs.CLIENT.tooltips.get())
return; return;
ItemStack stack = event.getItemStack(); ItemStack stack = event.getItemStack();

View file

@ -3,9 +3,9 @@ package com.simibubi.create;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; 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.CreateCommand;
import com.simibubi.create.foundation.command.ServerLagger; 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.ModuleLoadedCondition;
import com.simibubi.create.modules.contraptions.TorquePropagator; import com.simibubi.create.modules.contraptions.TorquePropagator;
import com.simibubi.create.modules.logistics.RedstoneLinkNetworkHandler; 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.MinecraftForge;
import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@ -43,8 +41,6 @@ public class Create {
public static TorquePropagator torquePropagator; public static TorquePropagator torquePropagator;
public static ServerLagger lagger; public static ServerLagger lagger;
public static ModConfig config;
public Create() { public Create() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
modEventBus.addListener(Create::init); modEventBus.addListener(Create::init);
@ -59,12 +55,10 @@ public class Create {
modEventBus.addGenericListener(EntityType.class, AllEntities::register); modEventBus.addGenericListener(EntityType.class, AllEntities::register);
modEventBus.addGenericListener(ParticleType.class, AllParticles::register); modEventBus.addGenericListener(ParticleType.class, AllParticles::register);
modEventBus.addListener(Create::createConfigs); AllConfigs.registerAll();
modEventBus.addListener(AllConfigs::onLoad);
modEventBus.addListener(AllConfigs::onReload);
CreateClient.addListeners(modEventBus); 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) { public static void init(final FMLCommonSetupEvent event) {
@ -77,15 +71,10 @@ public class Create {
AllPackets.registerPackets(); AllPackets.registerPackets();
} }
public static void serverStarting(FMLServerStartingEvent event){ public static void serverStarting(FMLServerStartingEvent event) {
new CreateCommand(event.getCommandDispatcher()); new CreateCommand(event.getCommandDispatcher());
} }
public static void createConfigs(ModConfig.ModConfigEvent event) {
if (event.getConfig().getSpec() == CreateConfig.specification)
config = event.getConfig();
}
public static void tick() { public static void tick() {
if (schematicReceiver == null) if (schematicReceiver == null)
schematicReceiver = new ServerSchematicLoader(); schematicReceiver = new ServerSchematicLoader();

View file

@ -33,7 +33,6 @@ import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
public class CreateClient { public class CreateClient {
@ -45,12 +44,9 @@ public class CreateClient {
public static SuperByteBufferCache bufferCache; public static SuperByteBufferCache bufferCache;
public static int renderTicks; public static int renderTicks;
public static ModConfig config;
public static void addListeners(IEventBus modEventBus) { public static void addListeners(IEventBus modEventBus) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
modEventBus.addListener(CreateClient::clientInit); modEventBus.addListener(CreateClient::clientInit);
modEventBus.addListener(CreateClient::createConfigs);
modEventBus.addListener(CreateClient::onModelBake); modEventBus.addListener(CreateClient::onModelBake);
modEventBus.addListener(CreateClient::onModelRegistry); modEventBus.addListener(CreateClient::onModelRegistry);
modEventBus.addListener(CreateClient::onTextureStitch); modEventBus.addListener(CreateClient::onTextureStitch);
@ -80,13 +76,6 @@ public class CreateClient {
((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); ((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() { public static void gameTick() {
schematicSender.tick(); schematicSender.tick();
schematicAndQuillHandler.tick(); schematicAndQuillHandler.tick();

View file

@ -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<CreateClientConfig, ForgeConfigSpec> 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();
}
}

View file

@ -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<CreateConfig, ForgeConfigSpec> 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<String> 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<ResourceLocation, DoubleValue> stressCapacityEntries = new HashMap<>();
public Map<ResourceLocation, DoubleValue> 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;
}
}
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create;
import java.util.Arrays; import java.util.Arrays;
import com.simibubi.create.config.AllConfigs;
import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity; import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -64,7 +65,7 @@ public class Events {
return; return;
if (!event.getPlayer().isAllowEdit()) if (!event.getPlayer().isAllowEdit())
return; return;
if (!CreateConfig.parameters.allowGlassPanesInPartialBlocks.get()) if (!AllConfigs.SERVER.curiosities.allowGlassPanesInPartialBlocks.get())
return; return;
ItemStack stack = event.getItemStack(); ItemStack stack = event.getItemStack();

View file

@ -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<Pair<ConfigBase, ModConfig.Type>> 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 extends ConfigBase> T register(Supplier<T> factory, ModConfig.Type side) {
Pair<T, ForgeConfigSpec> 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<ConfigBase, Type> pair : configs)
ctx.registerConfig(pair.getValue(), pair.getKey().specification);
}
public static void onLoad(ModConfig.Loading event) {
for (Pair<ConfigBase, Type> pair : configs)
if (pair.getKey().specification == event.getConfig().getSpec())
pair.getKey().onLoad();
}
public static void onReload(ModConfig.ConfigReloading event) {
for (Pair<ConfigBase, Type> pair : configs)
if (pair.getKey().specification == event.getConfig().getSpec())
pair.getKey().onReload();
}
}

View file

@ -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";
}
}

View file

@ -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";
}
}

View file

@ -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.";
}
}

View file

@ -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.";
}
}

View file

@ -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";
}
}

View file

@ -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.";
}
}

View file

@ -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.";
}
}

View file

@ -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.";
}
}

View file

@ -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<ResourceLocation, ConfigValue<Double>> impacts = new HashMap<>();
public Map<ResourceLocation, ConfigValue<Double>> 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.";
}
}

View file

@ -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";
}
}

View file

@ -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<CValue<?, ?>> allValues;
protected List<ConfigBase> 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<V, T extends ConfigValue<V>>
extends Function<ForgeConfigSpec.Builder, T> {
}
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 extends ConfigBase> T nested(int depth, Supplier<T> constructor, String... comment) {
T config = constructor.get();
new ConfigGroup(config.getName(), depth, comment);
new CValue<Boolean, ForgeConfigSpec.BooleanValue>(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<V, T extends ConfigValue<V>> {
protected ConfigValue<V> value;
protected String name;
private IValueProvider<V, T> provider;
public CValue(String name, IValueProvider<V, T> 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<Boolean, BooleanValue> {
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<Boolean, BooleanValue> {
public ConfigBool(String name, boolean def, String... comment) {
super(name, builder -> builder.define(name, def), comment);
}
}
public class ConfigFloat extends CValue<Double, DoubleValue> {
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<Integer, IntValue> {
public ConfigInt(String name, int current, int min, int max, String... comment) {
super(name, builder -> builder.defineInRange(name, current, min, max), comment);
}
}
}

View file

@ -1,4 +1,6 @@
package com.simibubi.create; package com.simibubi.create.config;
import com.simibubi.create.AllBlocks;
public class StressConfigDefaults { public class StressConfigDefaults {

View file

@ -8,6 +8,7 @@ import java.util.function.Supplier;
import org.apache.commons.lang3.tuple.Pair; 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.IBehaviourType;
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour;
@ -56,6 +57,8 @@ public class ExtractingBehaviour extends InventoryManagementBehaviour {
public boolean extract(int exactAmount) { public boolean extract(int exactAmount) {
if (getWorld().isRemote) if (getWorld().isRemote)
return false; return false;
if (AllConfigs.SERVER.control.freezeExtractors.get())
return false;
Predicate<ItemStack> test = customFilter; Predicate<ItemStack> test = customFilter;
FilteringBehaviour filter = get(tileEntity, FilteringBehaviour.TYPE); FilteringBehaviour filter = get(tileEntity, FilteringBehaviour.TYPE);

View file

@ -1,14 +1,15 @@
package com.simibubi.create.foundation.command; 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 com.simibubi.create.foundation.packet.SimplePacketBase;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
import java.util.function.Supplier;
public class ConfigureConfigPacket extends SimplePacketBase { public class ConfigureConfigPacket extends SimplePacketBase {
private String option; private String option;
@ -20,8 +21,8 @@ public class ConfigureConfigPacket extends SimplePacketBase {
} }
public ConfigureConfigPacket(PacketBuffer buffer) { public ConfigureConfigPacket(PacketBuffer buffer) {
this.option = buffer.readString(); this.option = buffer.readString(32767);
this.value = buffer.readString(); this.value = buffer.readString(32767);
} }
@Override @Override
@ -33,8 +34,8 @@ public class ConfigureConfigPacket extends SimplePacketBase {
@Override @Override
public void handle(Supplier<NetworkEvent.Context> ctx) { public void handle(Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { ctx.get().enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
if (option.equals("rainbowDebug")){ if (option.equals("rainbowDebug")) {
CreateClientConfig.instance.enableRainbowDebug.set(Boolean.parseBoolean(value)); AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value));
} }
})); }));

View file

@ -3,7 +3,8 @@ package com.simibubi.create.foundation.command;
import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.ArgumentBuilder;
import com.simibubi.create.AllPackets; 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.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
@ -15,21 +16,21 @@ import net.minecraftforge.fml.network.PacketDistributor;
public class ToggleDebugCommand { public class ToggleDebugCommand {
static ArgumentBuilder<CommandSource, ?> register() { static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("toggleDebug") return Commands.literal("toggleDebug").requires(cs -> cs.hasPermissionLevel(0))
.requires(cs -> cs.hasPermissionLevel(0)) .then(Commands.argument("value", BoolArgumentType.bool()).executes(ctx -> {
.then(Commands.argument("value", BoolArgumentType.bool())
.executes(ctx -> {
boolean value = BoolArgumentType.getBool(ctx, "value"); boolean value = BoolArgumentType.getBool(ctx, "value");
System.out.println("Command toggleDebug " + 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, () -> () -> DistExecutor.runWhenOn(Dist.DEDICATED_SERVER,
AllPackets.channel.send( () -> () -> AllPackets.channel.send(
PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()), PacketDistributor.PLAYER
.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()),
new ConfigureConfigPacket("rainbowDebug", String.valueOf(value)))); 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;
})); }));

View file

@ -1,6 +1,5 @@
package com.simibubi.create.foundation.item; package com.simibubi.create.foundation.item;
import static com.simibubi.create.CreateConfig.parameters;
import static com.simibubi.create.foundation.item.TooltipHelper.cutString; import static com.simibubi.create.foundation.item.TooltipHelper.cutString;
import static net.minecraft.util.text.TextFormatting.AQUA; import static net.minecraft.util.text.TextFormatting.AQUA;
import static net.minecraft.util.text.TextFormatting.BLUE; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import com.simibubi.create.AllItems; 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.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate;
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; 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.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
public class ItemDescription { public class ItemDescription {
public static final ItemDescription MISSING = new ItemDescription(null); public static final ItemDescription MISSING = new ItemDescription(null);
public static ITextComponent trim = new StringTextComponent( public static ITextComponent trim =
WHITE + "" + STRIKETHROUGH + " "); new StringTextComponent(WHITE + "" + STRIKETHROUGH + " ");
public enum Palette { public enum Palette {
@ -80,21 +83,23 @@ public class ItemDescription {
} }
public ItemDescription withKineticStats(IRotate block) { public ItemDescription withKineticStats(IRotate block) {
CKinetics config = AllConfigs.SERVER.kinetics;
SpeedLevel minimumRequiredSpeedLevel = block.getMinimumRequiredSpeedLevel(); SpeedLevel minimumRequiredSpeedLevel = block.getMinimumRequiredSpeedLevel();
boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE; boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE;
ResourceLocation id = ((Block) block).getRegistryName(); ResourceLocation id = ((Block) block).getRegistryName();
boolean hasStressImpact = parameters.stressEntries.containsKey(id) Map<ResourceLocation, ConfigValue<Double>> impacts = config.stressValues.capacities;
&& parameters.stressEntries.get(id).get() > 0; Map<ResourceLocation, ConfigValue<Double>> capacities = config.stressValues.impacts;
boolean hasStressCapacity = parameters.stressCapacityEntries.containsKey(id); boolean hasStressImpact = impacts.containsKey(id) && impacts.get(id).get() > 0;
boolean hasGlasses = AllItems.GOGGLES boolean hasStressCapacity = capacities.containsKey(id);
.typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD)); boolean hasGlasses =
AllItems.GOGGLES.typeOf(Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD));
String rpmUnit = Lang.translate("generic.unit.rpm"); String rpmUnit = Lang.translate("generic.unit.rpm");
if (hasSpeedRequirement) { if (hasSpeedRequirement) {
List<String> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); List<String> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high");
int index = minimumRequiredSpeedLevel.ordinal(); int index = minimumRequiredSpeedLevel.ordinal();
String level = minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) String level =
+ speedLevels.get(index); minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) + speedLevels.get(index);
if (hasGlasses) if (hasGlasses)
level += " (" + minimumRequiredSpeedLevel.getSpeedValue() + rpmUnit + "+)"; level += " (" + minimumRequiredSpeedLevel.getSpeedValue() + rpmUnit + "+)";
@ -105,33 +110,33 @@ public class ItemDescription {
String stressUnit = Lang.translate("generic.unit.stress"); String stressUnit = Lang.translate("generic.unit.stress");
if (hasStressImpact && !block.hideStressImpact()) { if (hasStressImpact && !block.hideStressImpact()) {
List<String> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); List<String> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high");
double impact = parameters.stressEntries.get(id).get(); double impact = impacts.get(id).get();
StressImpact impactId = impact >= parameters.highStressImpact.get() ? StressImpact.HIGH StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
: (impact >= parameters.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
int index = impactId.ordinal(); int index = impactId.ordinal();
String level = impactId.getColor() + makeProgressBar(3, index) + stressLevels.get(index); String level = impactId.getColor() + makeProgressBar(3, index) + stressLevels.get(index);
if (hasGlasses) if (hasGlasses)
level += " (" + parameters.stressEntries.get(id).get() + stressUnit + ")"; level += " (" + impacts.get(id).get() + stressUnit + ")";
add(linesOnShift, GRAY + Lang.translate("tooltip.stressImpact")); add(linesOnShift, GRAY + Lang.translate("tooltip.stressImpact"));
add(linesOnShift, level); add(linesOnShift, level);
} }
if (hasStressCapacity) { if (hasStressCapacity) {
List<String> stressCapacityLevels = Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", List<String> stressCapacityLevels =
"high"); Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high");
double capacity = parameters.stressCapacityEntries.get(id).get(); double capacity = capacities.get(id).get();
StressImpact impactId = capacity >= parameters.highCapacity.get() ? StressImpact.LOW StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW
: (capacity >= parameters.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
int index = StressImpact.values().length - 1 - impactId.ordinal(); int index = StressImpact.values().length - 1 - impactId.ordinal();
String level = impactId.getColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index); String level = impactId.getColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index);
if (hasGlasses) if (hasGlasses)
level += " (" + capacity + stressUnit + ")"; level += " (" + capacity + stressUnit + ")";
if (block.showCapacityWithAnnotation()) if (block.showCapacityWithAnnotation())
level += " " + DARK_GRAY + TextFormatting.ITALIC level +=
+ Lang.translate("tooltip.capacityProvided.asGenerator"); " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator");
add(linesOnShift, GRAY + Lang.translate("tooltip.capacityProvided")); add(linesOnShift, GRAY + Lang.translate("tooltip.capacityProvided"));
add(linesOnShift, level); add(linesOnShift, level);

View file

@ -8,7 +8,7 @@ import java.util.function.Predicate;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.tuple.Pair; 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.ItemStack;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
@ -98,7 +98,7 @@ public class ItemHelper {
boolean amountRequired = exactAmount != -1; boolean amountRequired = exactAmount != -1;
boolean checkHasEnoughItems = amountRequired; boolean checkHasEnoughItems = amountRequired;
boolean hasEnoughItems = !checkHasEnoughItems; boolean hasEnoughItems = !checkHasEnoughItems;
int maxExtractionCount = hasEnoughItems ? CreateConfig.parameters.extractorAmount.get() : exactAmount; int maxExtractionCount = hasEnoughItems ? AllConfigs.SERVER.logistics.extractorAmount.get() : exactAmount;
boolean potentialOtherMatch = false; boolean potentialOtherMatch = false;
Extraction: do { Extraction: do {
@ -157,7 +157,7 @@ public class ItemHelper {
public static ItemStack extract(IItemHandler inv, Predicate<ItemStack> test, public static ItemStack extract(IItemHandler inv, Predicate<ItemStack> test,
Function<ItemStack, Integer> amountFunction, boolean simulate) { Function<ItemStack, Integer> amountFunction, boolean simulate) {
ItemStack extracting = ItemStack.EMPTY; 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++) { for (int slot = 0; slot < inv.getSlots(); slot++) {
if (extracting.isEmpty()) { if (extracting.isEmpty()) {

View file

@ -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<Biome, ConfiguredFeature<?>> 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<ConfiguredFeature<?>> 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();
});
}
}

View file

@ -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<ChanceRangeConfig> {
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<Placement<ChanceRangeConfig>, ChanceRangeConfig> getPlacement() {
return Pair.of(Placement.CHANCE_RANGE,
new ChanceRangeConfig(clusterChance.getF(), minHeight.get(), 0, maxHeight.get() - minHeight.get()));
}
}

View file

@ -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<CountRangeConfig> {
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<Placement<CountRangeConfig>, CountRangeConfig> getPlacement() {
return Pair.of(Placement.COUNT_RANGE,
new CountRangeConfig(clusterCount.get(), minHeight.get(), 0, maxHeight.get() - minHeight.get()));
}
}

View file

@ -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<ConfiguredFeature<?>> createFeature(Biome biome);
public Decoration getGenerationStage();
}

View file

@ -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<T extends IPlacementConfig> extends ConfigBase implements IFeature {
public String id;
protected ConfigBool enable;
protected ConfigInt clusterSize;
protected ConfigInt minHeight;
protected ConfigInt maxHeight;
private Block block;
private List<Biome> 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<T> 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<T> inBiomes(Biome... biomes) {
biomeWhitelist = Arrays.asList(biomes);
return this;
}
public OreFeature<T> 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<ConfiguredFeature<?>> createFeature(Biome biome) {
if (biomeWhitelist != null && !biomeWhitelist.contains(biome))
return Optional.empty();
if (!canGenerate())
return Optional.empty();
Pair<Placement<T>, 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<Placement<T>, 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;
}
}

View file

@ -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<Biome> 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);
}
}

View file

@ -2,7 +2,8 @@ package com.simibubi.create.modules;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; 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 com.simibubi.create.foundation.item.ItemDescription.Palette;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -16,10 +17,10 @@ public interface IModule {
if (module.equals("materials")) if (module.equals("materials"))
return true; return true;
CreateConfig conf = CreateConfig.parameters; CServer conf = AllConfigs.SERVER;
switch (module) { switch (module) {
case "contraptions": case "contraptions":
return conf.enableContraptions.get(); return true;
case "palettes": case "palettes":
return conf.enablePalettes.get(); return conf.enablePalettes.get();
case "curiosities": case "curiosities":

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.contraptions; package com.simibubi.create.modules.contraptions;
import com.mojang.blaze3d.platform.GlStateManager; 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.foundation.utility.TessellatorHelper;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -45,8 +45,7 @@ public class KineticDebugger {
} }
public static boolean isActive() { public static boolean isActive() {
return Minecraft.getInstance().gameSettings.showDebugInfo return Minecraft.getInstance().gameSettings.showDebugInfo && AllConfigs.CLIENT.rainbowDebug.get();
&& CreateClientConfig.instance.enableRainbowDebug.get();
} }
public static KineticTileEntity getSelectedTE() { public static KineticTileEntity getSelectedTE() {

View file

@ -3,13 +3,12 @@ package com.simibubi.create.modules.contraptions;
import static com.simibubi.create.AllBlocks.BELT; import static com.simibubi.create.AllBlocks.BELT;
import static com.simibubi.create.AllBlocks.COGWHEEL; import static com.simibubi.create.AllBlocks.COGWHEEL;
import static com.simibubi.create.AllBlocks.LARGE_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 static net.minecraft.state.properties.BlockStateProperties.AXIS;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; 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.IRotate;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity;
@ -51,8 +50,8 @@ public class RotationPropagator {
if (axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0) if (axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0)
alignedAxes = false; alignedAxes = false;
boolean connectedByAxis = alignedAxes boolean connectedByAxis =
&& definitionFrom.hasShaftTowards(world, from.getPos(), stateFrom, direction) alignedAxes && definitionFrom.hasShaftTowards(world, from.getPos(), stateFrom, direction)
&& definitionTo.hasShaftTowards(world, to.getPos(), stateTo, direction.getOpposite()); && definitionTo.hasShaftTowards(world, to.getPos(), stateTo, direction.getOpposite());
boolean connectedByGears = definitionFrom.hasCogsTowards(world, from.getPos(), stateFrom, direction) boolean connectedByGears = definitionFrom.hasCogsTowards(world, from.getPos(), stateFrom, direction)
@ -206,10 +205,10 @@ public class RotationPropagator {
final float newSpeed = updateTE.speed * modFromTo; final float newSpeed = updateTE.speed * modFromTo;
float oppositeSpeed = neighbourTE.speed * modToFrom; float oppositeSpeed = neighbourTE.speed * modToFrom;
boolean incompatible = Math.signum(newSpeed) != Math.signum(neighbourTE.speed) boolean incompatible =
&& (newSpeed != 0 && neighbourTE.speed != 0); 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; boolean speedChangedTooOften = updateTE.speedChangeCounter > MAX_FLICKER_SCORE;
if (tooFast || speedChangedTooOften) { if (tooFast || speedChangedTooOften) {
world.destroyBlock(pos, true); world.destroyBlock(pos, true);
@ -397,7 +396,7 @@ public class RotationPropagator {
} }
public static boolean isFrozen() { public static boolean isFrozen() {
return CreateConfig.parameters.freezeRotationPropagator.get(); return AllConfigs.SERVER.control.freezeRotationPropagator.get();
} }
} }

View file

@ -1,6 +1,6 @@
package com.simibubi.create.modules.contraptions.base; 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 com.simibubi.create.modules.contraptions.IWrenchable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -13,7 +13,9 @@ import net.minecraft.world.IWorldReader;
public interface IRotate extends IWrenchable { public interface IRotate extends IWrenchable {
public enum SpeedLevel { public enum SpeedLevel {
NONE, MEDIUM, FAST; NONE,
MEDIUM,
FAST;
public TextFormatting getTextColor() { public TextFormatting getTextColor() {
return this == NONE ? TextFormatting.GREEN return this == NONE ? TextFormatting.GREEN
@ -31,9 +33,9 @@ public interface IRotate extends IWrenchable {
public static SpeedLevel of(float speed) { public static SpeedLevel of(float speed) {
speed = Math.abs(speed); speed = Math.abs(speed);
if (speed >= CreateConfig.parameters.fastSpeed.get()) { if (speed >= AllConfigs.SERVER.kinetics.fastSpeed.get()) {
return FAST; return FAST;
} else if (speed >= CreateConfig.parameters.mediumSpeed.get()) { } else if (speed >= AllConfigs.SERVER.kinetics.mediumSpeed.get()) {
return MEDIUM; return MEDIUM;
} }
return NONE; return NONE;
@ -42,9 +44,9 @@ public interface IRotate extends IWrenchable {
public float getSpeedValue() { public float getSpeedValue() {
switch (this) { switch (this) {
case FAST: case FAST:
return CreateConfig.parameters.fastSpeed.get().floatValue(); return AllConfigs.SERVER.kinetics.fastSpeed.get().floatValue();
case MEDIUM: case MEDIUM:
return CreateConfig.parameters.mediumSpeed.get().floatValue(); return AllConfigs.SERVER.kinetics.mediumSpeed.get().floatValue();
case NONE: case NONE:
default: default:
return 0; return 0;
@ -54,7 +56,9 @@ public interface IRotate extends IWrenchable {
} }
public enum StressImpact { public enum StressImpact {
LOW, MEDIUM, HIGH; LOW,
MEDIUM,
HIGH;
public TextFormatting getColor() { public TextFormatting getColor() {
return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED; return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED;

View file

@ -10,7 +10,7 @@ import java.util.Random;
import java.util.UUID; import java.util.UUID;
import com.simibubi.create.Create; 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.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.VecHelper; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.server.ServerWorld; 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 { public abstract class KineticTileEntity extends SmartTileEntity implements ITickableTileEntity {
@ -81,7 +81,7 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick
} }
public float getAddedStressCapacity() { public float getAddedStressCapacity() {
Map<ResourceLocation, DoubleValue> capacityMap = CreateConfig.parameters.stressCapacityEntries; Map<ResourceLocation, ConfigValue<Double>> capacityMap = AllConfigs.SERVER.kinetics.stressValues.impacts;
ResourceLocation path = getBlockState().getBlock().getRegistryName(); ResourceLocation path = getBlockState().getBlock().getRegistryName();
if (!capacityMap.containsKey(path)) if (!capacityMap.containsKey(path))
return 0; return 0;
@ -89,7 +89,7 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick
} }
public float getStressApplied() { public float getStressApplied() {
Map<ResourceLocation, DoubleValue> stressEntries = CreateConfig.parameters.stressEntries; Map<ResourceLocation, ConfigValue<Double>> stressEntries = AllConfigs.SERVER.kinetics.stressValues.capacities;
ResourceLocation path = getBlockState().getBlock().getRegistryName(); ResourceLocation path = getBlockState().getBlock().getRegistryName();
if (!stressEntries.containsKey(path)) if (!stressEntries.containsKey(path))
return 1; return 1;
@ -347,9 +347,9 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick
if (minimumRequiredSpeedLevel == null) if (minimumRequiredSpeedLevel == null)
return true; return true;
if (minimumRequiredSpeedLevel == SpeedLevel.MEDIUM) 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) if (minimumRequiredSpeedLevel == SpeedLevel.FAST)
return Math.abs(getSpeed()) >= CreateConfig.parameters.fastSpeed.get(); return Math.abs(getSpeed()) >= AllConfigs.SERVER.kinetics.fastSpeed.get();
return true; return true;
} }
@ -402,8 +402,8 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick
particleSpeed *= Math.signum(getSpeed()); particleSpeed *= Math.signum(getSpeed());
if (getWorld() instanceof ServerWorld) { if (getWorld() instanceof ServerWorld) {
RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, RotationIndicatorParticleData particleData =
radius1, radius2, 10, axisChar); new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar);
((ServerWorld) getWorld()).spawnParticle(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1); ((ServerWorld) getWorld()).spawnParticle(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1);
} }
} }

View file

@ -1,6 +1,5 @@
package com.simibubi.create.modules.contraptions.components.contraptions; 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.AXIS;
import static net.minecraft.state.properties.BlockStateProperties.FACING; 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 org.apache.commons.lang3.tuple.MutablePair;
import com.simibubi.create.AllBlocks; 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.IHaveMovementBehavior.MovementContext;
import com.simibubi.create.modules.contraptions.components.contraptions.bearing.BearingContraption; import com.simibubi.create.modules.contraptions.components.contraptions.bearing.BearingContraption;
import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock; import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock;
@ -72,7 +71,7 @@ public class Contraption {
search.add(pos); search.add(pos);
while (!search.isEmpty()) { while (!search.isEmpty()) {
if (chassis.size() > parameters.maxChassisForTranslation.get()) if (chassis.size() > AllConfigs.SERVER.kinetics.maxChassisForTranslation.get())
return null; return null;
BlockPos current = search.remove(0); BlockPos current = search.remove(0);
@ -202,11 +201,11 @@ public class Contraption {
BlockInfo anchorChassis = cluster.get(0); BlockInfo anchorChassis = cluster.get(0);
Axis chassisAxis = anchorChassis.state.get(AXIS); Axis chassisAxis = anchorChassis.state.get(AXIS);
int chassisCoord = chassisAxis.getCoordinate(anchorChassis.pos.getX(), anchorChassis.pos.getY(), int chassisCoord =
anchorChassis.pos.getZ()); chassisAxis.getCoordinate(anchorChassis.pos.getX(), anchorChassis.pos.getY(), anchorChassis.pos.getZ());
Function<BlockPos, BlockPos> getChassisPos = position -> new BlockPos( Function<BlockPos, BlockPos> getChassisPos =
chassisAxis == Axis.X ? chassisCoord : position.getX(), position -> new BlockPos(chassisAxis == Axis.X ? chassisCoord : position.getX(),
chassisAxis == Axis.Y ? chassisCoord : position.getY(), chassisAxis == Axis.Y ? chassisCoord : position.getY(),
chassisAxis == Axis.Z ? chassisCoord : position.getZ()); chassisAxis == Axis.Z ? chassisCoord : position.getZ());
@ -268,8 +267,8 @@ public class Contraption {
continue; continue;
// Skip if pushed column ended already // Skip if pushed column ended already
for (BlockPos posInbetween = currentPos; !posInbetween.equals( for (BlockPos posInbetween = currentPos; !posInbetween.equals(currentChassisPos); posInbetween =
currentChassisPos); posInbetween = posInbetween.offset(chassisDirection.getOpposite())) { posInbetween.offset(chassisDirection.getOpposite())) {
BlockState blockState = world.getBlockState(posInbetween); BlockState blockState = world.getBlockState(posInbetween);
if (!chassisSticky && (blockState.getMaterial().isReplaceable())) if (!chassisSticky && (blockState.getMaterial().isReplaceable()))
@ -322,7 +321,7 @@ public class Contraption {
// Collect chain of chassis // Collect chain of chassis
for (int offset : new int[] { -1, 1 }) { 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); Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
BlockPos currentPos = pos.offset(direction, distance * offset); BlockPos currentPos = pos.offset(direction, distance * offset);
if (!world.isBlockPresent(currentPos)) if (!world.isBlockPresent(currentPos))
@ -547,7 +546,7 @@ public class Contraption {
} }
public static boolean isFrozen() { 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) { public void disassemble(IWorld world, BlockPos offset, float yaw, float pitch) {

View file

@ -1,10 +1,8 @@
package com.simibubi.create.modules.contraptions.components.contraptions.chassis; 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.AllPackets;
import com.simibubi.create.AllTileEntities; 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.block.SyncedTileEntity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -19,7 +17,7 @@ public class ChassisTileEntity extends SyncedTileEntity implements ITickableTile
public ChassisTileEntity() { public ChassisTileEntity() {
super(AllTileEntities.CHASSIS.type); super(AllTileEntities.CHASSIS.type);
newRange = range = CreateConfig.parameters.maxChassisRange.get() / 2; newRange = range = AllConfigs.SERVER.kinetics.maxChassisRange.get() / 2;
} }
@Override @Override
@ -46,7 +44,7 @@ public class ChassisTileEntity extends SyncedTileEntity implements ITickableTile
} }
public void setRangeLazily(int range) { 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) if (newRange == this.range)
return; return;
this.lastModified = 0; this.lastModified = 0;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.contraptions.components.contraptions.piston; package com.simibubi.create.modules.contraptions.components.contraptions.piston;
import com.simibubi.create.AllBlocks; 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.AllShapes;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
@ -99,7 +99,9 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
} }
public enum PistonState implements IStringSerializable { public enum PistonState implements IStringSerializable {
RETRACTED, MOVING, EXTENDED; RETRACTED,
MOVING,
EXTENDED;
@Override @Override
public String getName() { public String getName() {
@ -114,7 +116,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
BlockPos pistonBase = pos; BlockPos pistonBase = pos;
boolean dropBlocks = player == null || !player.isCreative(); boolean dropBlocks = player == null || !player.isCreative();
Integer maxPoles = CreateConfig.parameters.maxPistonPoles.get(); Integer maxPoles = maxAllowedPistonPoles();
for (int offset = 1; offset < maxPoles; offset++) { for (int offset = 1; offset < maxPoles; offset++) {
BlockPos currentPos = pos.offset(direction, offset); BlockPos currentPos = pos.offset(direction, offset);
BlockState block = worldIn.getBlockState(currentPos); BlockState block = worldIn.getBlockState(currentPos);
@ -151,6 +153,10 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
super.onBlockHarvested(worldIn, pos, state, player); super.onBlockHarvested(worldIn, pos, state, player);
} }
public static int maxAllowedPistonPoles() {
return AllConfigs.SERVER.kinetics.maxPistonPoles.get();
}
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {

View file

@ -1,7 +1,6 @@
package com.simibubi.create.modules.contraptions.components.contraptions.piston; package com.simibubi.create.modules.contraptions.components.contraptions.piston;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.IHaveNoBlockItem; import com.simibubi.create.foundation.block.IHaveNoBlockItem;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.foundation.utility.AllShapes;
@ -50,7 +49,7 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements
BlockPos pistonHead = pos; BlockPos pistonHead = pos;
BlockPos pistonBase = null; 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); BlockPos currentPos = pos.offset(direction.getOpposite(), offset);
BlockState block = worldIn.getBlockState(currentPos); BlockState block = worldIn.getBlockState(currentPos);

View file

@ -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.MECHANICAL_PISTON_HEAD;
import static com.simibubi.create.AllBlocks.PISTON_POLE; import static com.simibubi.create.AllBlocks.PISTON_POLE;
import static com.simibubi.create.AllBlocks.STICKY_MECHANICAL_PISTON; 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 static net.minecraft.state.properties.BlockStateProperties.FACING;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.AllBlocks; 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.Contraption;
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState; import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
@ -63,7 +63,7 @@ public class PistonContraption extends Contraption {
extensionsInFront++; extensionsInFront++;
nextBlock = world.getBlockState(actualStart.offset(direction)); nextBlock = world.getBlockState(actualStart.offset(direction));
if (extensionsInFront > parameters.maxPistonPoles.get()) if (extensionsInFront > MechanicalPistonBlock.maxAllowedPistonPoles())
return false; return false;
} }
} }
@ -87,7 +87,7 @@ public class PistonContraption extends Contraption {
extensionsInBack++; extensionsInBack++;
nextBlock = world.getBlockState(end.offset(direction.getOpposite())); nextBlock = world.getBlockState(end.offset(direction.getOpposite()));
if (extensionsInFront + extensionsInBack > parameters.maxPistonPoles.get()) if (extensionsInFront + extensionsInBack > MechanicalPistonBlock.maxAllowedPistonPoles())
return false; return false;
} }
@ -112,7 +112,7 @@ public class PistonContraption extends Contraption {
@Override @Override
protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, List<BlockPos> frontier) { protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, List<BlockPos> 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); BlockPos currentPos = pos.offset(direction, offset);
if (!world.isAreaLoaded(currentPos, 1)) if (!world.isAreaLoaded(currentPos, 1))
return false; return false;

View file

@ -1,7 +1,6 @@
package com.simibubi.create.modules.contraptions.components.contraptions.piston; package com.simibubi.create.modules.contraptions.components.contraptions.piston;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState; import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
@ -35,8 +34,8 @@ public class PistonPoleBlock extends ProperDirectionalBlock {
BlockPos pistonBase = null; BlockPos pistonBase = null;
for (int modifier : new int[] { 1, -1 }) { for (int modifier : new int[] { 1, -1 }) {
for (int offset = modifier; modifier * offset < CreateConfig.parameters.maxPistonPoles for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
.get(); offset += modifier) { modifier) {
BlockPos currentPos = pos.offset(direction, offset); BlockPos currentPos = pos.offset(direction, offset);
BlockState block = worldIn.getBlockState(currentPos); BlockState block = worldIn.getBlockState(currentPos);

View file

@ -7,7 +7,7 @@ import java.util.UUID;
import com.simibubi.create.AllRecipes; import com.simibubi.create.AllRecipes;
import com.simibubi.create.AllTileEntities; 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.block.SyncedTileEntity;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.processing.ProcessingInventory; import com.simibubi.create.modules.contraptions.processing.ProcessingInventory;
@ -117,7 +117,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
if (!(processingEntity instanceof ItemEntity)) { if (!(processingEntity instanceof ItemEntity)) {
processingEntity.attackEntityFrom(CrushingWheelTileEntity.damageSource, processingEntity.attackEntityFrom(CrushingWheelTileEntity.damageSource,
CreateConfig.parameters.crushingDamage.get()); AllConfigs.SERVER.kinetics.crushingDamage.get());
if (!processingEntity.isAlive()) { if (!processingEntity.isAlive()) {
processingEntity.setPosition(outPos.x, outPos.y - .75f, outPos.z); processingEntity.setPosition(outPos.x, outPos.y - .75f, outPos.z);
} }
@ -232,7 +232,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
} }
public static boolean isFrozen() { public static boolean isFrozen() {
return CreateConfig.parameters.freezeCrushing.get(); return AllConfigs.SERVER.control.freezeCrushing.get();
} }
} }

View file

@ -6,7 +6,7 @@ import java.util.List;
import org.apache.commons.lang3.tuple.Pair; 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.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.particle.AirFlowParticleData; import com.simibubi.create.modules.contraptions.particle.AirFlowParticleData;
import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity;
@ -60,7 +60,7 @@ public class AirCurrent {
if (world.isRemote) { if (world.isRemote) {
float offset = pushing ? 0.5f : maxDistance + .5f; float offset = pushing ? 0.5f : maxDistance + .5f;
Vec3d pos = VecHelper.getCenterOf(source.getPos()).add(new Vec3d(facing.getDirectionVec()).scale(offset)); 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); world.addParticle(new AirFlowParticleData(source.getPos()), pos.x, pos.y, pos.z, 0, 0, 0);
} }

View file

@ -1,10 +1,9 @@
package com.simibubi.create.modules.contraptions.components.fan; package com.simibubi.create.modules.contraptions.components.fan;
import static com.simibubi.create.CreateConfig.parameters;
import com.simibubi.create.AllBlockTags; import com.simibubi.create.AllBlockTags;
import com.simibubi.create.AllTileEntities; 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 com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -57,7 +56,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
@Override @Override
public float getGeneratedSpeed() { public float getGeneratedSpeed() {
return isGenerator ? CreateConfig.parameters.generatingFanSpeed.get() : 0; return isGenerator ? AllConfigs.SERVER.kinetics.generatingFanSpeed.get() : 0;
} }
public void updateGenerator() { public void updateGenerator() {
@ -75,9 +74,10 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
public float getMaxDistance() { public float getMaxDistance() {
float speed = Math.abs(this.getSpeed()); float speed = Math.abs(this.getSpeed());
float distanceFactor = Math.min(speed / parameters.fanRotationArgmax.get(), 1); CKinetics config = AllConfigs.SERVER.kinetics;
float pushDistance = MathHelper.lerp(distanceFactor, 3, parameters.fanPushDistance.get()); float distanceFactor = Math.min(speed / config.fanRotationArgmax.get(), 1);
float pullDistance = MathHelper.lerp(distanceFactor, 3f, parameters.fanPullDistance.get()); float pushDistance = MathHelper.lerp(distanceFactor, 3, config.fanPushDistance.get());
float pullDistance = MathHelper.lerp(distanceFactor, 3f, config.fanPullDistance.get());
return this.getSpeed() > 0 ? pushDistance : pullDistance; return this.getSpeed() > 0 ? pushDistance : pullDistance;
} }
@ -103,7 +103,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
super.tick(); super.tick();
if (!world.isRemote && airCurrentUpdateCooldown-- <= 0) { if (!world.isRemote && airCurrentUpdateCooldown-- <= 0) {
airCurrentUpdateCooldown = parameters.fanBlockCheckRate.get(); airCurrentUpdateCooldown = AllConfigs.SERVER.kinetics.fanBlockCheckRate.get();
updateAirFlow = true; updateAirFlow = true;
} }

View file

@ -5,7 +5,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import com.simibubi.create.AllTileEntities; 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.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -72,9 +72,11 @@ public class NozzleTileEntity extends SmartTileEntity {
Vec3d center = VecHelper.getCenterOf(pos); Vec3d center = VecHelper.getCenterOf(pos);
if (world.isRemote && range != 0) { 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 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); world.addParticle(ParticleTypes.POOF, start.x, start.y, start.z, motion.x, motion.y, motion.z);
} }
} }

View file

@ -4,7 +4,7 @@ import java.util.UUID;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.AllTileEntities; 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 com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -52,7 +52,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity {
public void setSpeedValueLazily(int speed) { public void setSpeedValueLazily(int speed) {
if (newGeneratedSpeed == speed) if (newGeneratedSpeed == speed)
return; return;
Integer max = CreateConfig.parameters.maxMotorSpeed.get(); Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get();
newGeneratedSpeed = MathHelper.clamp(speed, -max, max); newGeneratedSpeed = MathHelper.clamp(speed, -max, max);
this.lastModified = 0; this.lastModified = 0;
} }

View file

@ -4,7 +4,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import com.simibubi.create.AllBlocks; 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.foundation.item.IAddedByOther;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
@ -175,7 +175,7 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther {
return false; return false;
if (!world.isAreaLoaded(second, 1)) if (!world.isAreaLoaded(second, 1))
return false; return false;
if (!second.withinDistance(first, CreateConfig.parameters.maxBeltLength.get())) if (!second.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get()))
return false; return false;
BlockPos diff = second.subtract(first); 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())); BlockPos step = new BlockPos(Math.signum(diff.getX()), Math.signum(diff.getY()), Math.signum(diff.getZ()));
int limit = 1000; int limit = 1000;
for (BlockPos currentPos = first.add(step); !currentPos.equals(second) for (BlockPos currentPos = first.add(step); !currentPos.equals(second) && limit-- > 0; currentPos =
&& limit-- > 0; currentPos = currentPos.add(step)) { currentPos.add(step)) {
BlockState blockState = world.getBlockState(currentPos); BlockState blockState = world.getBlockState(currentPos);
if (AllBlocks.SHAFT.typeOf(blockState) && blockState.get(ShaftBlock.AXIS) == axis) if (AllBlocks.SHAFT.typeOf(blockState) && blockState.get(ShaftBlock.AXIS) == axis)
continue; continue;
@ -224,5 +224,4 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther {
return true; return true;
} }
} }

View file

@ -6,7 +6,7 @@ import java.util.Random;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.CreateConfig; import com.simibubi.create.config.AllConfigs;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -70,10 +70,11 @@ public class BeltConnectorItemHandler {
return; return;
if (!AllBlocks.SHAFT.typeOf(world.getBlockState(selected))) if (!AllBlocks.SHAFT.typeOf(world.getBlockState(selected)))
selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace()); selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace());
if (!selected.withinDistance(first, CreateConfig.parameters.maxBeltLength.get())) if (!selected.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get()))
return; 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 start = new Vec3d(first);
Vec3d end = new Vec3d(selected); Vec3d end = new Vec3d(selected);

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.contraptions.relays.gauge; package com.simibubi.create.modules.contraptions.relays.gauge;
import com.simibubi.create.AllTileEntities; 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.foundation.utility.ColorHelper;
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
@ -17,9 +17,9 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
public void onSpeedChanged(float prevSpeed) { public void onSpeedChanged(float prevSpeed) {
super.onSpeedChanged(prevSpeed); super.onSpeedChanged(prevSpeed);
float speed = Math.abs(getSpeed()); float speed = Math.abs(getSpeed());
float medium = CreateConfig.parameters.mediumSpeed.get().floatValue(); float medium = AllConfigs.SERVER.kinetics.mediumSpeed.get().floatValue();
float fast = CreateConfig.parameters.fastSpeed.get().floatValue(); float fast = AllConfigs.SERVER.kinetics.fastSpeed.get().floatValue();
float max = CreateConfig.parameters.maxRotationSpeed.get().floatValue(); float max = AllConfigs.SERVER.kinetics.maxRotationSpeed.get().floatValue();
color = ColorHelper.mixColors(SpeedLevel.of(speed).getColor(), 0xffffff, .25f); color = ColorHelper.mixColors(SpeedLevel.of(speed).getColor(), 0xffffff, .25f);
if (speed == 0) { if (speed == 0) {

View file

@ -3,7 +3,8 @@ package com.simibubi.create.modules.curiosities;
import java.util.Random; import java.util.Random;
import com.simibubi.create.AllItems; 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.item.IItemWithColorHandler;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper; 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) { public int getColor(ItemStack stack, int layer) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
float pt = mc.getRenderPartialTicks(); float pt = mc.getRenderPartialTicks();
float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) float progress =
+ (AnimationTickHolder.getRenderTick() / 10f); (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTick() / 10f);
if (layer == 0) if (layer == 0)
return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2);
if (layer == 1) if (layer == 1)
@ -66,7 +67,7 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan
@Override @Override
public double getDurabilityForDisplay(ItemStack stack) { public double getDurabilityForDisplay(ItemStack stack) {
int light = stack.getOrCreateTag().getInt("CollectingLight"); int light = stack.getOrCreateTag().getInt("CollectingLight");
return 1 - light / (float) CreateConfig.parameters.lightSourceCountForRefinedRadiance.get(); return 1 - light / (float) AllConfigs.SERVER.curiosities.lightSourceCountForRefinedRadiance.get();
} }
@Override @Override
@ -94,9 +95,10 @@ public class ChromaticCompoundCubeItem extends Item implements IItemWithColorHan
CompoundNBT itemData = entity.getItem().getOrCreateTag(); CompoundNBT itemData = entity.getItem().getOrCreateTag();
Vec3d positionVec = entity.getPositionVec(); Vec3d positionVec = entity.getPositionVec();
CCuriosities config = AllConfigs.SERVER.curiosities;
if (world.isRemote) { if (world.isRemote) {
int light = itemData.getInt("CollectingLight"); 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 start = VecHelper.offsetRandomly(positionVec, random, 3);
Vec3d motion = positionVec.subtract(start).normalize().scale(.2f); 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); 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 // 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(); ItemStack newStack = AllItems.SHADOW_STEEL.asStack();
newStack.setCount(stack.getCount()); newStack.setCount(stack.getCount());
data.putBoolean("FromVoid", true); data.putBoolean("FromVoid", true);
entity.setItem(newStack); entity.setItem(newStack);
} }
if (!CreateConfig.parameters.enableRefinedRadianceRecipe.get()) if (!config.enableRefinedRadianceRecipe.get())
return false; return false;
// Convert to Refined Radiance if eaten enough light sources // 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(); ItemStack newStack = AllItems.REFINED_RADIANCE.asStack();
ItemEntity newEntity = new ItemEntity(world, entity.posX, entity.posY, entity.posZ, newStack); ItemEntity newEntity = new ItemEntity(world, entity.posX, entity.posY, entity.posZ, newStack);
newEntity.setMotion(entity.getMotion()); newEntity.setMotion(entity.getMotion());

View file

@ -1,13 +1,12 @@
package com.simibubi.create.modules.curiosities.symmetry; package com.simibubi.create.modules.curiosities.symmetry;
import static com.simibubi.create.CreateConfig.parameters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.config.AllConfigs;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.IHaveCustomItemModel; 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)); SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound(SYMMETRY));
Vec3d mirrorPos = symmetry.getPosition(); 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; return;
if (!player.isCreative() && isHoldingBlock(player, block) if (!player.isCreative() && isHoldingBlock(player, block)
&& BlockHelper.findAndRemoveInInventory(block, player, 1) == 0) && 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)); SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound(SYMMETRY));
Vec3d mirrorPos = symmetry.getPosition(); 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; return;
symmetry.process(blockSet); symmetry.process(blockSet);

View file

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.simibubi.create.AllRecipes; 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.ProcessingIngredient;
import com.simibubi.create.modules.contraptions.processing.ProcessingOutput; import com.simibubi.create.modules.contraptions.processing.ProcessingOutput;
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe;
@ -34,15 +34,18 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe<SandPaperInv> {
} }
public static boolean canPolish(World world, ItemStack stack) { public static boolean canPolish(World world, ItemStack stack) {
return (stack.isDamageable() && CreateConfig.parameters.enableSandPaperToolPolishing.get()) return (stack.isDamageable() && isPolishingEnabled()) || !getMatchingRecipes(world, stack).isEmpty();
|| !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) { public static ItemStack applyPolish(World world, Vec3d position, ItemStack stack, ItemStack sandPaperStack) {
List<IRecipe<SandPaperInv>> matchingRecipes = getMatchingRecipes(world, stack); List<IRecipe<SandPaperInv>> matchingRecipes = getMatchingRecipes(world, stack);
if (!matchingRecipes.isEmpty()) if (!matchingRecipes.isEmpty())
return matchingRecipes.get(0).getCraftingResult(new SandPaperInv(stack)).copy(); 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); stack.setDamage(stack.getDamage() - (stack.getMaxDamage() - stack.getDamage()) / 2);

View file

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.simibubi.create.CreateConfig; import com.simibubi.create.config.AllConfigs;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -53,7 +53,7 @@ public class CocoaLogBlock extends RotatedPillarBlock implements IGrowable {
@Override @Override
public void grow(World world, Random random, BlockPos pos, BlockState state) { 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; return;
int age = state.get(AGE); int age = state.get(AGE);

View file

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import com.simibubi.create.AllRecipes; 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.item.ItemHelper;
import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe; import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe;
@ -51,7 +51,9 @@ public class InWorldProcessing {
public static SplashingInv splashingInv = new SplashingInv(); public static SplashingInv splashingInv = new SplashingInv();
public enum Type { public enum Type {
SMOKING, BLASTING, SPLASHING SMOKING,
BLASTING,
SPLASHING
; ;
@ -105,8 +107,8 @@ public class InWorldProcessing {
if (type == Type.SPLASHING) { if (type == Type.SPLASHING) {
splashingInv.setInventorySlotContents(0, stack); splashingInv.setInventorySlotContents(0, stack);
Optional<SplashingRecipe> recipe = world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), Optional<SplashingRecipe> recipe =
splashingInv, world); world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), splashingInv, world);
return recipe.isPresent(); return recipe.isPresent();
} }
@ -135,7 +137,7 @@ public class InWorldProcessing {
Type type) { Type type) {
if (transported.processedBy != type) { if (transported.processedBy != type) {
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())) if (!canProcess(transported.stack, type, belt.getWorld()))
transported.processingTime = -1; transported.processingTime = -1;
return null; return null;
@ -158,8 +160,8 @@ public class InWorldProcessing {
private static List<ItemStack> process(ItemStack stack, Type type, World world) { private static List<ItemStack> process(ItemStack stack, Type type, World world) {
if (type == Type.SPLASHING) { if (type == Type.SPLASHING) {
splashingInv.setInventorySlotContents(0, stack); splashingInv.setInventorySlotContents(0, stack);
Optional<SplashingRecipe> recipe = world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), Optional<SplashingRecipe> recipe =
splashingInv, world); world.getRecipeManager().getRecipe(AllRecipes.SPLASHING.getType(), splashingInv, world);
if (recipe.isPresent()) if (recipe.isPresent())
return applyRecipeOn(stack, recipe.get()); return applyRecipeOn(stack, recipe.get());
return null; return null;
@ -174,8 +176,8 @@ public class InWorldProcessing {
FurnaceTileEntity furnace = new FurnaceTileEntity(); FurnaceTileEntity furnace = new FurnaceTileEntity();
furnace.setWorld(world); furnace.setWorld(world);
furnace.setInventorySlotContents(0, stack); furnace.setInventorySlotContents(0, stack);
Optional<FurnaceRecipe> smeltingRecipe = world.getRecipeManager().getRecipe(IRecipeType.SMELTING, furnace, Optional<FurnaceRecipe> smeltingRecipe =
world); world.getRecipeManager().getRecipe(IRecipeType.SMELTING, furnace, world);
if (!smokingRecipe.isPresent()) { if (!smokingRecipe.isPresent()) {
if (smeltingRecipe.isPresent()) if (smeltingRecipe.isPresent())
@ -184,8 +186,8 @@ public class InWorldProcessing {
BlastFurnaceTileEntity blastFurnace = new BlastFurnaceTileEntity(); BlastFurnaceTileEntity blastFurnace = new BlastFurnaceTileEntity();
blastFurnace.setWorld(world); blastFurnace.setWorld(world);
blastFurnace.setInventorySlotContents(0, stack); blastFurnace.setInventorySlotContents(0, stack);
Optional<BlastingRecipe> blastingRecipe = world.getRecipeManager().getRecipe(IRecipeType.BLASTING, Optional<BlastingRecipe> blastingRecipe =
blastFurnace, world); world.getRecipeManager().getRecipe(IRecipeType.BLASTING, blastFurnace, world);
if (blastingRecipe.isPresent()) if (blastingRecipe.isPresent())
return applyRecipeOn(stack, blastingRecipe.get()); return applyRecipeOn(stack, blastingRecipe.get());
@ -213,7 +215,7 @@ public class InWorldProcessing {
if (!processing.contains("Type") || Type.valueOf(processing.getString("Type")) != type) { if (!processing.contains("Type") || Type.valueOf(processing.getString("Type")) != type) {
processing.putString("Type", type.name()); 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; int value = processing.getInt("Time") - 1;
@ -288,7 +290,7 @@ public class InWorldProcessing {
} }
public static boolean isFrozen() { public static boolean isFrozen() {
return CreateConfig.parameters.freezeInWorldProcessing.get(); return AllConfigs.SERVER.control.freezeInWorldProcessing.get();
} }
} }

View file

@ -9,7 +9,7 @@ import java.util.Set;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.Create; 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 com.simibubi.create.foundation.behaviour.linked.LinkBehaviour;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -115,7 +115,7 @@ public class RedstoneLinkNetworkHandler {
} }
public static boolean withinRange(LinkBehaviour from, LinkBehaviour to) { 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<Pair<Frequency, Frequency>, Set<LinkBehaviour>> networksIn(IWorld world) { public Map<Pair<Frequency, Frequency>, Set<LinkBehaviour>> networksIn(IWorld world) {

View file

@ -4,7 +4,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTileEntities; 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.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour;
@ -47,17 +47,17 @@ public class ExtractorTileEntity extends SmartTileEntity {
@Override @Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) { public void addBehaviours(List<TileEntityBehaviour> behaviours) {
int delay = CreateConfig.parameters.extractorDelay.get(); int delay = AllConfigs.SERVER.logistics.extractorDelay.get();
extracting = new SingleTargetAutoExtractingBehaviour(this, extracting =
() -> AttachedLogisticalBlock.getBlockFacing(getBlockState()), this::onExtract, delay) new SingleTargetAutoExtractingBehaviour(this, () -> AttachedLogisticalBlock.getBlockFacing(getBlockState()),
.pauseWhen(this::isPowered).waitUntil(this::canExtract); this::onExtract, delay).pauseWhen(this::isPowered).waitUntil(this::canExtract);
behaviours.add(extracting); behaviours.add(extracting);
if (slots == null) if (slots == null)
slots = new SlotPositioning(ExtractorBlock::getFilterSlotPosition, ExtractorBlock::getFilterSlotOrientation) slots = new SlotPositioning(ExtractorBlock::getFilterSlotPosition, ExtractorBlock::getFilterSlotOrientation)
.scale(.4f); .scale(.4f);
filtering = new FilteringBehaviour(this).withCallback(this::filterChanged).withSlotPositioning(slots) filtering =
.showCount(); new FilteringBehaviour(this).withCallback(this::filterChanged).withSlotPositioning(slots).showCount();
behaviours.add(filtering); behaviours.add(filtering);
} }
@ -127,7 +127,8 @@ public class ExtractorTileEntity extends SmartTileEntity {
boolean onBelt = isTargetingBelt(); boolean onBelt = isTargetingBelt();
if (extractingToBelt != onBelt) { if (extractingToBelt != onBelt) {
extractingToBelt = onBelt; extractingToBelt = onBelt;
((AutoExtractingBehaviour) extracting).setDelay(onBelt ? 0 : CreateConfig.parameters.extractorDelay.get()); ((AutoExtractingBehaviour) extracting)
.setDelay(onBelt ? 0 : AllConfigs.SERVER.logistics.extractorDelay.get());
} }
} }

View file

@ -10,9 +10,9 @@ import net.minecraft.block.material.MaterialColor;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; 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)); super(Properties.from(Blocks.ANDESITE));
} }

View file

@ -1,7 +1,5 @@
package com.simibubi.create.modules.schematics; package com.simibubi.create.modules.schematics;
import static com.simibubi.create.CreateConfig.parameters;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
@ -18,6 +16,7 @@ import java.util.Map;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.config.AllConfigs;
import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.FilesHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket; import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket;
@ -67,7 +66,7 @@ public class ClientSchematicLoader {
long size = Files.size(path); long size = Files.size(path);
// Too big // Too big
Integer maxSize = parameters.maxTotalSchematicSize.get(); Integer maxSize = AllConfigs.SERVER.schematics.maxTotalSchematicSize.get();
if (size > maxSize * 1000) { if (size > maxSize * 1000) {
Minecraft.getInstance().player.sendMessage(new StringTextComponent( Minecraft.getInstance().player.sendMessage(new StringTextComponent(
Lang.translate("schematics.uploadTooLarge") + " (" + size / 1000 + " KB).")); Lang.translate("schematics.uploadTooLarge") + " (" + size / 1000 + " KB)."));
@ -86,7 +85,7 @@ public class ClientSchematicLoader {
private void continueUpload(String schematic) { private void continueUpload(String schematic) {
if (activeUploads.containsKey(schematic)) { if (activeUploads.containsKey(schematic)) {
Integer maxPacketSize = parameters.maxSchematicPacketSize.get(); Integer maxPacketSize = AllConfigs.SERVER.schematics.maxSchematicPacketSize.get();
byte[] data = new byte[maxPacketSize]; byte[] data = new byte[maxPacketSize];
try { try {
int status = activeUploads.get(schematic).read(data); int status = activeUploads.get(schematic).read(data);

View file

@ -1,7 +1,5 @@
package com.simibubi.create.modules.schematics; package com.simibubi.create.modules.schematics;
import static com.simibubi.create.CreateConfig.parameters;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
@ -18,6 +16,8 @@ import java.util.stream.Stream;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create; 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.type.DimensionPos;
import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.FilesHelper;
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity; import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
@ -54,7 +54,7 @@ public class ServerSchematicLoader {
} }
public String getSchematicPath() { public String getSchematicPath() {
return parameters.schematicPath.get(); return "schematics/uploaded";
} }
public void tick() { public void tick() {
@ -63,7 +63,7 @@ public class ServerSchematicLoader {
for (String upload : activeUploads.keySet()) { for (String upload : activeUploads.keySet()) {
SchematicUploadEntry entry = activeUploads.get(upload); 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); Create.logger.warn("Schematic Upload timed out: " + upload);
deadEntries.add(upload); deadEntries.add(upload);
} }
@ -90,7 +90,7 @@ public class ServerSchematicLoader {
} }
// Too big // Too big
Integer maxFileSize = parameters.maxTotalSchematicSize.get(); Integer maxFileSize = getConfig().maxTotalSchematicSize.get();
if (size > maxFileSize * 1000) { if (size > maxFileSize * 1000) {
player.sendMessage(new TranslationTextComponent("create.schematics.uploadTooLarge") player.sendMessage(new TranslationTextComponent("create.schematics.uploadTooLarge")
.appendSibling(new StringTextComponent(" (" + size / 1000 + " KB)."))); .appendSibling(new StringTextComponent(" (" + size / 1000 + " KB).")));
@ -114,7 +114,7 @@ public class ServerSchematicLoader {
// Too many Schematics // Too many Schematics
Stream<Path> list = Files.list(Paths.get(playerPath)); Stream<Path> list = Files.list(Paths.get(playerPath));
if (list.count() >= parameters.maxSchematics.get()) { if (list.count() >= getConfig().maxSchematics.get()) {
Stream<Path> list2 = Files.list(Paths.get(playerPath)); Stream<Path> list2 = Files.list(Paths.get(playerPath));
Optional<Path> lastFilePath = list2.filter(f -> !Files.isDirectory(f)) Optional<Path> lastFilePath = list2.filter(f -> !Files.isDirectory(f))
.min(Comparator.comparingLong(f -> f.toFile().lastModified())); .min(Comparator.comparingLong(f -> f.toFile().lastModified()));
@ -126,8 +126,8 @@ public class ServerSchematicLoader {
list.close(); list.close();
// Open Stream // Open Stream
OutputStream writer = Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), OutputStream writer =
StandardOpenOption.CREATE_NEW); Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW);
activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, dimPos)); activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, dimPos));
// Notify Tile Entity // 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) { public void handleWriteRequest(ServerPlayerEntity player, String schematic, byte[] data) {
String playerSchematicId = player.getName().getFormattedText() + "/" + schematic; String playerSchematicId = player.getName().getFormattedText() + "/" + schematic;
@ -148,7 +152,7 @@ public class ServerSchematicLoader {
entry.bytesUploaded += data.length; entry.bytesUploaded += data.length;
// Size Validations // Size Validations
if (data.length > parameters.maxSchematicPacketSize.get()) { if (data.length > getConfig().maxSchematicPacketSize.get()) {
Create.logger.warn("Oversized Upload Packet received: " + playerSchematicId); Create.logger.warn("Oversized Upload Packet received: " + playerSchematicId);
cancelUpload(playerSchematicId); cancelUpload(playerSchematicId);
return; return;
@ -167,8 +171,8 @@ public class ServerSchematicLoader {
if (!AllBlocks.SCHEMATIC_TABLE.typeOf(blockState)) if (!AllBlocks.SCHEMATIC_TABLE.typeOf(blockState))
return; return;
SchematicTableTileEntity tileEntity = (SchematicTableTileEntity) entry.tablePos.world SchematicTableTileEntity tileEntity =
.getTileEntity(entry.tablePos.pos); (SchematicTableTileEntity) entry.tablePos.world.getTileEntity(entry.tablePos.pos);
tileEntity.uploadingProgress = (float) ((double) entry.bytesUploaded / entry.totalBytes); tileEntity.uploadingProgress = (float) ((double) entry.bytesUploaded / entry.totalBytes);
tileEntity.sendUpdate = true; tileEntity.sendUpdate = true;

View file

@ -1,7 +1,5 @@
package com.simibubi.create.modules.schematics.block; package com.simibubi.create.modules.schematics.block;
import static com.simibubi.create.CreateConfig.parameters;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -9,6 +7,8 @@ import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities; 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.block.SyncedTileEntity;
import com.simibubi.create.foundation.type.Cuboid; import com.simibubi.create.foundation.type.Cuboid;
import com.simibubi.create.modules.schematics.MaterialChecklist; import com.simibubi.create.modules.schematics.MaterialChecklist;
@ -363,7 +363,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
refillFuelIfPossible(); refillFuelIfPossible();
// Update Printer // Update Printer
skipsLeft = parameters.schematicannonSkips.get(); skipsLeft = config().schematicannonSkips.get();
blockSkipped = true; blockSkipped = true;
while (blockSkipped && skipsLeft-- > 0) 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() { protected void tickPrinter() {
ItemStack blueprint = inventory.getStackInSlot(0); ItemStack blueprint = inventory.getStackInSlot(0);
blockSkipped = false; blockSkipped = false;
@ -492,14 +496,14 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
else else
statusMsg = "clearing"; statusMsg = "clearing";
launchBlock(target, blockState); launchBlock(target, blockState);
printerCooldown = parameters.schematicannonDelay.get(); printerCooldown = config().schematicannonDelay.get();
fuelLevel -= getFuelUsageRate(); fuelLevel -= getFuelUsageRate();
sendUpdate = true; sendUpdate = true;
missingBlock = null; missingBlock = null;
} }
public double getFuelUsageRate() { public double getFuelUsageRate() {
return parameters.schematicannonFuelUsage.get() / 100f; return config().schematicannonFuelUsage.get() / 100f;
} }
protected void initializePrinter(ItemStack blueprint) { protected void initializePrinter(ItemStack blueprint) {
@ -706,7 +710,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
} }
public double getFuelAddedByGunPowder() { public double getFuelAddedByGunPowder() {
return parameters.schematicannonGunpowderWorth.get() / 100f; return config().schematicannonGunpowderWorth.get() / 100f;
} }
protected void tickPaperPrinter() { protected void tickPaperPrinter() {

View file

@ -10,7 +10,6 @@ import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.schematics.client.SchematicEditScreen; import com.simibubi.create.modules.schematics.client.SchematicEditScreen;
@ -99,7 +98,7 @@ public class SchematicItem extends Item {
String filepath = ""; String filepath = "";
if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER) if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER)
filepath = CreateConfig.parameters.schematicPath.get() + "/" + owner + "/" + schematic; filepath = "schematics/uploaded/" + owner + "/" + schematic;
else else
filepath = "schematics/" + schematic; filepath = "schematics/" + schematic;

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "create:block/palettes/scoria" }
}
}

View file

@ -1,5 +0,0 @@
{
"variants": {
"": { "model": "create:block/palettes/volcanic_rock" }
}
}

View file

@ -1,6 +1,6 @@
{ {
"parent": "block/cube_all", "parent": "block/cube_all",
"textures": { "textures": {
"all": "create:block/volcanic_rock" "all": "create:block/scoria"
} }
} }

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/palettes/scoria"
}

View file

@ -1,3 +0,0 @@
{
"parent": "create:block/palettes/volcanic_rock"
}

View file

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 682 B