@@ -1,6 +1,7 @@
|
||||
package com.drmangotea.createindustry;
|
||||
|
||||
import com.drmangotea.createindustry.base.TFMGLangPartials;
|
||||
import com.drmangotea.createindustry.config.TFMGConfigs;
|
||||
import com.drmangotea.createindustry.items.gadgets.explosives.thermite_grenades.fire.TFMGColoredFires;
|
||||
import com.drmangotea.createindustry.registry.*;
|
||||
import com.drmangotea.createindustry.worldgen.TFMGConfiguredFeatures;
|
||||
@@ -21,6 +22,7 @@ import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -60,6 +62,8 @@ public class CreateTFMG
|
||||
TFMGFeatures.register(modEventBus);
|
||||
TFMGRecipeTypes.register(modEventBus);
|
||||
|
||||
TFMGConfigs.register(ModLoadingContext.get());
|
||||
|
||||
//
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
modEventBus.addListener(EventPriority.LOWEST, CreateTFMG::gatherData);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.drmangotea.createindustry.config;
|
||||
|
||||
import com.simibubi.create.foundation.config.ConfigBase;
|
||||
|
||||
public class ServerConfig extends ConfigBase {
|
||||
|
||||
public final StressConfig stressValues = nested(0, StressConfig::new, "Fine tune the kinetic stats of individual components");
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "server";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.drmangotea.createindustry.config;
|
||||
|
||||
import com.drmangotea.createindustry.CreateTFMG;
|
||||
import com.simibubi.create.content.kinetics.BlockStressDefaults;
|
||||
import com.simibubi.create.content.kinetics.BlockStressValues.IStressValueProvider;
|
||||
import com.simibubi.create.foundation.config.ConfigBase;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StressConfig extends ConfigBase implements IStressValueProvider {
|
||||
|
||||
private final Map<ResourceLocation, ConfigValue<Double>> capacities = new HashMap<>();
|
||||
private final Map<ResourceLocation, ConfigValue<Double>> impacts = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerAll(Builder builder) {
|
||||
builder.comment(".", Comments.su, Comments.impact)
|
||||
.push("impact");
|
||||
BlockStressDefaults.DEFAULT_IMPACTS.forEach((r, i) -> {
|
||||
if (r.getNamespace()
|
||||
.equals(CreateTFMG.MOD_ID))
|
||||
getImpacts().put(r, builder.define(r.getPath(), i));
|
||||
});
|
||||
builder.pop();
|
||||
|
||||
builder.comment(".", Comments.su, Comments.capacity)
|
||||
.push("capacity");
|
||||
BlockStressDefaults.DEFAULT_CAPACITIES.forEach((r, i) -> {
|
||||
if (r.getNamespace()
|
||||
.equals(CreateTFMG.MOD_ID))
|
||||
getCapacities().put(r, builder.define(r.getPath(), i));
|
||||
});
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stressValues";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getImpact(Block block) {
|
||||
block = redirectValues(block);
|
||||
ResourceLocation key = RegisteredObjects.getKeyOrThrow(block);
|
||||
ConfigValue<Double> value = getImpacts().get(key);
|
||||
if(value != null) return value.get();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCapacity(Block block) {
|
||||
block = redirectValues(block);
|
||||
ResourceLocation key = RegisteredObjects.getKeyOrThrow(block);
|
||||
ConfigValue<Double> value = getCapacities().get(key);
|
||||
if(value != null) return value.get();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasImpact(Block block) {
|
||||
block = redirectValues(block);
|
||||
ResourceLocation key = RegisteredObjects.getKeyOrThrow(block);
|
||||
return getImpacts().containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapacity(Block block) {
|
||||
block = redirectValues(block);
|
||||
ResourceLocation key = RegisteredObjects.getKeyOrThrow(block);
|
||||
return getCapacities().containsKey(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Couple<Integer> getGeneratedRPM(Block block) {
|
||||
block = redirectValues(block);
|
||||
ResourceLocation key = RegisteredObjects.getKeyOrThrow(block);
|
||||
Supplier<Couple<Integer>> supplier = BlockStressDefaults.GENERATOR_SPEEDS.get(key);
|
||||
if(supplier == null) return null;
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
protected Block redirectValues(Block block) {
|
||||
return block;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, ConfigValue<Double>> getImpacts() {
|
||||
return impacts;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, ConfigValue<Double>> getCapacities() {
|
||||
return capacities;
|
||||
}
|
||||
|
||||
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.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.drmangotea.createindustry.config;
|
||||
|
||||
import com.simibubi.create.content.kinetics.BlockStressValues;
|
||||
import com.simibubi.create.foundation.config.ConfigBase;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class TFMGConfigs {
|
||||
|
||||
private static final Map<ModConfig.Type, ConfigBase> CONFIGS = new EnumMap<>(ModConfig.Type.class);
|
||||
|
||||
private static ServerConfig server;
|
||||
|
||||
public static ServerConfig server() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public static ConfigBase byType(ModConfig.Type type) {
|
||||
return CONFIGS.get(type);
|
||||
}
|
||||
|
||||
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.put(side, config);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void register(ModLoadingContext context) {
|
||||
server = register(ServerConfig::new, ModConfig.Type.SERVER);
|
||||
|
||||
for (Map.Entry<ModConfig.Type, ConfigBase> pair : CONFIGS.entrySet())
|
||||
context.registerConfig(pair.getKey(), pair.getValue().specification);
|
||||
|
||||
BlockStressValues.registerProvider(context.getActiveNamespace(), server().stressValues);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onLoad(ModConfigEvent.Loading event) {
|
||||
for (ConfigBase config : CONFIGS.values())
|
||||
if (config.specification == event.getConfig()
|
||||
.getSpec())
|
||||
config.onLoad();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onReload(ModConfigEvent.Reloading event) {
|
||||
for (ConfigBase config : CONFIGS.values())
|
||||
if (config.specification == event.getConfig()
|
||||
.getSpec())
|
||||
config.onReload();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.drmangotea.createindustry.config;
|
||||
|
||||
import com.simibubi.create.foundation.config.ConfigBase;
|
||||
|
||||
public class WorldGenConfig extends ConfigBase {
|
||||
|
||||
/**
|
||||
* Increment this number if all worldgen config entries should be overwritten
|
||||
* in this update. Worlds from the previous version will overwrite potentially
|
||||
* changed values with the new defaults.
|
||||
*/
|
||||
public static final int FORCED_UPDATE_VERSION = 1;
|
||||
|
||||
public final ConfigBool disableOil = b(false, "disableOil", Comments.disableOil);
|
||||
public final ConfigBool disableSimulatedOil = b(false, "disableSimulatedOil", Comments.disableSimulatedOil);
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "worldgen" + FORCED_UPDATE_VERSION;
|
||||
}
|
||||
|
||||
private static class Comments {
|
||||
static String disableOil = "Prevents oil geodes from spawning";
|
||||
static String disableSimulatedOil = "Prevents oil deposit veins from spawning in bedrock";
|
||||
}
|
||||
}
|
||||
@@ -823,8 +823,6 @@ public static final BlockEntry<DistillationOutputBlock> STEEL_DISTILLATION_OUTPU
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new EngineGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setCapacity(66.0))
|
||||
.transform(BlockStressDefaults.setGeneratorSpeed(() -> Couple.create(0, 256)))
|
||||
.item()
|
||||
.properties(p -> p.rarity(Rarity.UNCOMMON))
|
||||
.transform(customItemModel())
|
||||
@@ -854,8 +852,6 @@ public static final BlockEntry<DistillationOutputBlock> STEEL_DISTILLATION_OUTPU
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new EngineGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setCapacity(60.0))
|
||||
.transform(BlockStressDefaults.setGeneratorSpeed(() -> Couple.create(0, 256)))
|
||||
.item()
|
||||
.properties(p -> p.rarity(Rarity.UNCOMMON))
|
||||
.transform(customItemModel())
|
||||
@@ -885,8 +881,6 @@ public static final BlockEntry<DistillationOutputBlock> STEEL_DISTILLATION_OUTPU
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new EngineGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setCapacity(66.0))
|
||||
.transform(BlockStressDefaults.setGeneratorSpeed(() -> Couple.create(0, 256)))
|
||||
.item()
|
||||
.properties(p -> p.rarity(Rarity.UNCOMMON))
|
||||
.transform(customItemModel())
|
||||
|
||||
Reference in New Issue
Block a user