2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("ConfigValues.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.config;
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-12-18 17:50:31 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
2021-04-19 21:20:23 +02:00
|
|
|
import net.minecraft.block.Blocks;
|
2017-03-04 22:25:40 +01:00
|
|
|
import net.minecraft.item.Item;
|
2021-04-19 21:20:23 +02:00
|
|
|
import net.minecraft.item.Items;
|
2017-03-04 22:25:40 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-02-09 17:25:05 +01:00
|
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public final class ConfigValues {
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2017-03-04 22:25:40 +01:00
|
|
|
public static Item itemRedstoneTorchConfigurator;
|
|
|
|
public static Item itemCompassConfigurator;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public static void defineConfigValues(Configuration config) {
|
|
|
|
for (ConfigIntValues currConf : ConfigIntValues.values()) {
|
2015-10-01 12:52:03 +02:00
|
|
|
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
|
2015-04-24 19:22:03 +02:00
|
|
|
}
|
2016-06-05 12:15:02 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
|
2015-10-01 12:52:03 +02:00
|
|
|
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
|
2015-04-24 19:22:03 +02:00
|
|
|
}
|
2015-07-02 11:44:41 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
|
2016-06-05 12:15:02 +02:00
|
|
|
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
|
2016-06-05 12:15:02 +02:00
|
|
|
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
|
|
|
}
|
2016-01-23 11:02:35 +01:00
|
|
|
|
2017-03-04 22:25:40 +01:00
|
|
|
parseConfiguratorConfig();
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private static void parseConfiguratorConfig() {
|
2017-03-04 22:25:40 +01:00
|
|
|
itemRedstoneTorchConfigurator = null;
|
|
|
|
itemCompassConfigurator = null;
|
|
|
|
|
|
|
|
String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (conf.length == 2) {
|
2017-03-04 22:25:40 +01:00
|
|
|
itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
|
|
|
|
itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
|
2018-05-10 11:38:58 +02:00
|
|
|
ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
|
2017-03-04 22:25:40 +01:00
|
|
|
|
2021-08-22 17:09:06 +02:00
|
|
|
itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
|
2017-03-04 22:25:40 +01:00
|
|
|
itemCompassConfigurator = Items.COMPASS;
|
|
|
|
}
|
2015-02-09 17:25:05 +01:00
|
|
|
}
|
|
|
|
}
|