Whittling away at configs... part 1.

This commit is contained in:
Flanks255 2021-11-14 12:18:07 -06:00
parent d3780c5011
commit 789570e25d
13 changed files with 121 additions and 105 deletions

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.Lang;
@ -72,7 +72,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
player.inventory.removeItem(player.inventory.selected, 1);
}
//Shush, don't tell anyone!
else if (ConfigIntValues.ELEVEN.getValue() == 11 && item == Items.MUSIC_DISC_11) {
else if (CommonConfig.OTHER.ELEVEN.get() == 11 && item == Items.MUSIC_DISC_11) {
reconstructor.counter++;
reconstructor.setChanged();
}

View file

@ -0,0 +1,96 @@
package de.ellpeck.actuallyadditions.mod.config;
import net.minecraftforge.common.ForgeConfigSpec;
public class CommonConfig {
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static ForgeConfigSpec COMMON_CONFIG;
static {
OTHER.build();
COMMON_CONFIG = BUILDER.build();
}
public static class OTHER {
public static ForgeConfigSpec.BooleanValue SOLID_XP_ALWAYS_ORBS;
public static ForgeConfigSpec.BooleanValue DO_UPDATE_CHECK;
public static ForgeConfigSpec.BooleanValue UPDATE_CHECK_VERSION_SPECIFIC;
public static ForgeConfigSpec.BooleanValue DO_CAT_DROPS;
public static ForgeConfigSpec.IntValue FUR_CHANCE;
public static ForgeConfigSpec.BooleanValue WORMS;
public static ForgeConfigSpec.IntValue WORMS_DIE_TIME;
public static ForgeConfigSpec.BooleanValue CTRL_EXTRA_INFO;
public static ForgeConfigSpec.BooleanValue CTRL_INFO_FOR_EXTRA_INFO;
public static ForgeConfigSpec.BooleanValue GIVE_BOOKLET_ON_FIRST_CRAFT;
public static ForgeConfigSpec.BooleanValue DUNGEON_LOOT;
public static ForgeConfigSpec.BooleanValue WATER_BOWL;
public static ForgeConfigSpec.BooleanValue WATER_BOWL_LOSS;
public static ForgeConfigSpec.BooleanValue TINY_COAL_STUFF;
public static ForgeConfigSpec.BooleanValue SUPER_DUPER_HARD_MODE;
public static ForgeConfigSpec.BooleanValue MOST_BLAND_PERSON_EVER;
public static ForgeConfigSpec.IntValue ELEVEN;
public static void build() {
BUILDER.comment("Everything else").push("other");
SOLID_XP_ALWAYS_ORBS = BUILDER.comment("If true, Solidified Experience will always spawn orbs, even for regular players.")
.define("solidXPOrbs", false);
DO_UPDATE_CHECK = BUILDER.comment("If true, Actually Additions Checks for updates on World Load.")
.define("doUpdateCheck", true);
UPDATE_CHECK_VERSION_SPECIFIC = BUILDER.comment("If true, Actually Additions' Update Checker searches for updates for the Minecraft Version you currently play on.")
.define("versionSpecificUpdateChecker", true);
DO_CAT_DROPS = BUILDER.comment("If true, Cats drop Hairy Balls Occasionally.")
.define("doCatDrops", true);
FUR_CHANCE = BUILDER.comment("The 1/n drop chance, per tick, for a fur ball to be dropped.")
.defineInRange("furDropChance", 5000, 1, Integer.MAX_VALUE);
WORMS = BUILDER.comment("If true, worms will drop from tilling the soil.")
.define("tillingWorms", true);
WORMS_DIE_TIME = BUILDER.comment("The amount of ticks it takes for a worm to die. When at 0 ticks, it will not die.")
.defineInRange("wormDeathTime", 0, 0, 10000000);
CTRL_EXTRA_INFO = BUILDER.comment("Show Advanced Item Info when holding Control on every Item.")
.define("advancedInfo", true);
CTRL_INFO_FOR_EXTRA_INFO = BUILDER.comment("Show the 'Press Control for more Info'-Text on Item Tooltips")
.define("advancedInfoTooltips", true);
GIVE_BOOKLET_ON_FIRST_CRAFT = BUILDER.comment("If true, the booklet should be given to the player when he first crafts something from the Mod")
.define("giveBookletOnFirstCraft", true);
DUNGEON_LOOT = BUILDER.comment("Should Actually Additions Loot generate in dungeons?")
.define("villageAndDungeonLoot", true);
WATER_BOWL = BUILDER.comment("Should right-clicking a bowl on water blocks create a water bowl?")
.define("waterBowl", true);
WATER_BOWL_LOSS = BUILDER.comment("Should the water bowl spill if you don't sneak while using it?")
.define("waterBowlSpilling", true);
TINY_COAL_STUFF = BUILDER.comment("Should Tiny Coal and Tiny Charcoal be craftable").define("tinyCoal", true); //TODO conditionalRecipe
SUPER_DUPER_HARD_MODE = BUILDER.comment("Turn this on to make recipes for items from the mod really hard. (This is a joke feature poking fun at the whole FTB Infinity Expert Mode style of playing. You shouldn't really turn this on as it makes the mod completely unplayable.)")
.define("superDuperHardRecipes", false); //TODO what did this do?
MOST_BLAND_PERSON_EVER = BUILDER.comment("If you want to be really boring and lame, you can turn on this setting to disable colored names on Actually Additions items. Because why would you want things to look pretty anyways, right?")
.define("noColoredItemNames", false); //TODO is this still needed?
ELEVEN = BUILDER.comment("11?").defineInRange("whatIs11", 11, 0, 12);
BUILDER.pop();
}
}
}

View file

@ -28,19 +28,6 @@ public enum ConfigBoolValues {
GENERATE_QUARTZ("Black Quartz", ConfigCategories.WORLD_GEN, true, "Shold Black Quartz generate in the world?"),
DO_UPDATE_CHECK(
"Do Update Check",
ConfigCategories.OTHER,
true,
"If true, Actually Additions Checks for updates on World Load."),
UPDATE_CHECK_VERSION_SPECIFIC(
"Version Specific Update Checker",
ConfigCategories.OTHER,
true,
"If true, Actually Additions' Update Checker searches for updates for the Minecraft Version you currently play on."),
DO_CAT_DROPS("Do Cat Drops", ConfigCategories.OTHER, true, "If true, Cats drop Hairy Balls Occasionally."),
WORMS("Worms", ConfigCategories.OTHER, true, "If true, worms will drop from tilling the soil."),
DO_RICE_GEN("Rice Gen", ConfigCategories.WORLD_GEN, true, "Should Rice generate in the World?"),
DO_CANOLA_GEN("Canola Gen", ConfigCategories.WORLD_GEN, true, "Should Canola generate in the World?"),
@ -66,50 +53,18 @@ public enum ConfigBoolValues {
true,
"If true, Mobs will randomly drop solidified XP occasionally."),
CTRL_EXTRA_INFO(
"Advanced Info",
ConfigCategories.OTHER,
true,
"Show Advanced Item Info when holding Control on every Item."),
CTRL_INFO_FOR_EXTRA_INFO(
"Advanced Info Tooltips",
ConfigCategories.OTHER,
true,
"Show the 'Press Control for more Info'-Text on Item Tooltips"),
SHOW_BOOKLET_INFO(
"Booklet Quick Opening Info",
ConfigCategories.TOOL_VALUES,
true,
"If true,'Press key for more information' text should show when the item has a page in the booklet"),
GIVE_BOOKLET_ON_FIRST_CRAFT(
"Give Booklet on First Craft",
ConfigCategories.OTHER,
true,
"If true, the booklet should be given to the player when he first crafts something from the Mod"),
DUNGEON_LOOT(
"Village and Dungeon Loot",
ConfigCategories.OTHER,
true,
"Should Actually Additions Loot generate in dungeons?"),
GEN_LUSH_CAVES(
"Generate Lush Caves",
ConfigCategories.WORLD_GEN,
true,
"Should caves with trees and grass randomly generate underground?"),
WATER_BOWL(
"Water Bowl",
ConfigCategories.OTHER,
true,
"Should right-clicking a bowl on water blocks create a water bowl?"),
WATER_BOWL_LOSS(
"Water Bowl Spilling",
ConfigCategories.OTHER,
true,
"Should the water bowl spill if you don't sneak while using it?"),
TINY_COAL_STUFF("Tiny Coal", ConfigCategories.OTHER, true, "Should Tiny Coal and Tiny Charcoal be craftable"),
LASER_RELAY_LOSS(
"Laser Relay Energy Loss",
@ -117,27 +72,6 @@ public enum ConfigBoolValues {
true,
"If Energy Laser Relays should have energy loss"),
SUPER_DUPER_HARD_MODE(
"Super Duper Hard Recipes",
ConfigCategories.OTHER,
false,
"Turn this on to make recipes for items from the mod really hard. (This is a joke feature poking fun at the whole FTB Infinity Expert Mode style of playing. You shouldn't really turn this on as it makes the mod completely unplayable.)"),
MOST_BLAND_PERSON_EVER(
"No Colored Item Names",
ConfigCategories.OTHER,
false,
"If you want to be really boring and lame, you can turn on this setting to disable colored names on Actually Additions items. Because why would you want things to look pretty anyways, right?"),
COLOR_LENS_USES_OREDICT(
"Color Lens Oredict",
ConfigCategories.OTHER,
false,
"If true, the Lens of Color will attempt to pull from the oredict instead of only using vanilla dyes."),
SOLID_XP_ALWAYS_ORBS(
"Solid XP Orbs",
ConfigCategories.OTHER,
false,
"If true, Solidified Experience will always spawn orbs, even for regular players."),
ORE_GEN_DIM_WHITELIST(
"Ore Gen Whitelist",

View file

@ -32,13 +32,6 @@ public enum ConfigIntValues {
1,
100,
"The chances for lush caves to generate. The lower the number, the higher the chances."),
WORMS_DIE_TIME(
"Worm Death Time",
ConfigCategories.OTHER,
0,
0,
10000000,
"The amount of ticks it takes for a worm to die. When at 0 ticks, it will not die."),
TILE_ENTITY_UPDATE_INTERVAL(
"Tile Entities: Update Interval",
@ -77,14 +70,6 @@ public enum ConfigIntValues {
500,
"The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."),
ELEVEN("What is 11", ConfigCategories.OTHER, 11, 0, 12, "11?"),
FUR_CHANCE(
"Fur Drop Chance",
ConfigCategories.OTHER,
5000,
1,
Integer.MAX_VALUE,
"The 1/n drop chance, per tick, for a fur ball to be dropped."),
RECONSTRUCTOR_POWER(
"Atomic Reconstructor Power",
ConfigCategories.MACHINE_VALUES,

View file

@ -10,7 +10,7 @@
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
import net.minecraft.block.*;
import net.minecraft.entity.Entity;
@ -104,7 +104,7 @@ public class EntityWorm extends Entity {
}
}
int dieTime = ConfigIntValues.WORMS_DIE_TIME.getValue();
int dieTime = CommonConfig.OTHER.WORMS_DIE_TIME.get();
if (dieTime > 0 && this.timer >= dieTime) {
this.removeAfterChangingDimensions();
}

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.event;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.WorldData;
@ -162,7 +163,7 @@ public class CommonEvents {
public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event) {
//checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
if (ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()) {
if (CommonConfig.OTHER.GIVE_BOOKLET_ON_FIRST_CRAFT.get()) {
if (!event.getPlayer().level.isClientSide && StackUtil.isValid(event.getCrafting()) && event.getCrafting().getItem() != ActuallyItems.ITEM_BOOKLET.get()) {
String name = event.getCrafting().getItem().getRegistryName().toString();

View file

@ -11,8 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.passive.OcelotEntity;
@ -43,9 +42,9 @@ public class ItemHairBall extends ItemBase {
@SubscribeEvent
public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) {
//Ocelots dropping Hair Balls
if (ConfigBoolValues.DO_CAT_DROPS.isEnabled() && event.getEntityLiving() != null && event.getEntityLiving().level != null && !event.getEntityLiving().level.isClientSide) {
if (CommonConfig.OTHER.DO_CAT_DROPS.get() && event.getEntityLiving() != null && event.getEntityLiving().level != null && !event.getEntityLiving().level.isClientSide) {
if (event.getEntityLiving() instanceof OcelotEntity && catIsTamedReflection((OcelotEntity) event.getEntityLiving()) || event.getEntityLiving() instanceof PlayerEntity && event.getEntityLiving().getUUID().equals(this.KittyVanCatUUID)) {
if (event.getEntityLiving().level.random.nextInt(ConfigIntValues.FUR_CHANCE.getValue()) == 0) {
if (event.getEntityLiving().level.random.nextInt(CommonConfig.OTHER.FUR_CHANCE.get()) == 0) {
ItemEntity item = new ItemEntity(event.getEntityLiving().level, event.getEntityLiving().getX() + 0.5, event.getEntityLiving().getY() + 0.5, event.getEntityLiving().getZ() + 0.5, new ItemStack(ActuallyItems.HAIRY_BALL.get()));
event.getEntityLiving().level.addFreshEntity(item);
}

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.entity.CreatureEntity;
@ -69,7 +70,7 @@ public class ItemSolidifiedExperience extends ItemBase {
}
}
if (ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) {
if (CommonConfig.OTHER.SOLID_XP_ALWAYS_ORBS.get() || player instanceof FakePlayer) {
ExperienceOrbEntity orb = new ExperienceOrbEntity(world, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, amount);
orb.getPersistentData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true);
world.addFreshEntity(orb);

View file

@ -10,7 +10,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -46,7 +46,7 @@ public class ItemWaterBowl extends ItemBase {
@SubscribeEvent
public void onPlayerInteractEvent(PlayerInteractEvent.RightClickItem event) {
if (event.getWorld() != null) {
if (ConfigBoolValues.WATER_BOWL.isEnabled()) {
if (CommonConfig.OTHER.WATER_BOWL.get()) {
if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) {
RayTraceResult rayTrace = WorldUtil.getNearestBlockWithDefaultReachDistance(event.getWorld(), event.getPlayer(), true, false, false);
if (rayTrace.getType() != RayTraceResult.Type.BLOCK) {
@ -126,7 +126,7 @@ public class ItemWaterBowl extends ItemBase {
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (!world.isClientSide) {
if (ConfigBoolValues.WATER_BOWL_LOSS.isEnabled()) {
if (CommonConfig.OTHER.WATER_BOWL_LOSS.get()) {
if (world.getGameTime() % 10 == 0 && world.random.nextFloat() >= 0.5F) {
int lastX = 0;
int lastY = 0;

View file

@ -11,7 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.block.BlockState;
@ -68,7 +68,7 @@ public class ItemWorm extends ItemBase {
@SubscribeEvent(priority = EventPriority.LOW)
public void onHoe(UseHoeEvent event) {
if (ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Event.Result.DENY) {
if (CommonConfig.OTHER.WORMS.get() && event.getResult() != Event.Result.DENY) {
World world = event.getEntity().level;
if (!world.isClientSide) {
BlockPos pos = event.getContext().getClickedPos();

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -35,7 +35,7 @@ public class LensDisruption extends Lens {
@Override
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
if (ConfigIntValues.ELEVEN.getValue() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)) {
if (CommonConfig.OTHER.ELEVEN.get() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)) {
int range = 2;
ArrayList<ItemEntity> items = (ArrayList<ItemEntity>) tile.getWorldObject().getEntitiesOfClass(ItemEntity.class, new AxisAlignedBB(hitBlock.getX() - range, hitBlock.getY() - range, hitBlock.getZ() - range, hitBlock.getX() + range, hitBlock.getY() + range, hitBlock.getZ() + range));
for (ItemEntity item : items) {

View file

@ -10,14 +10,14 @@
package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.util.Util;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Properties;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.util.Util;
public class ThreadUpdateChecker extends Thread {
public ThreadUpdateChecker() {
@ -35,7 +35,7 @@ public class ThreadUpdateChecker extends Thread {
updateProperties.load(new InputStreamReader(newestURL.openStream()));
String currentMcVersion = Util.getMcVersion();
if (ConfigBoolValues.UPDATE_CHECK_VERSION_SPECIFIC.isEnabled()) {
if (CommonConfig.OTHER.UPDATE_CHECK_VERSION_SPECIFIC.get()) {
String newestVersionProp = updateProperties.getProperty(currentMcVersion);
UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp);

View file

@ -11,7 +11,7 @@
package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.Minecraft;
@ -34,7 +34,7 @@ public class UpdateChecker {
public static boolean threadFinished = false;
public UpdateChecker() {
if (ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()) {
if (CommonConfig.OTHER.DO_UPDATE_CHECK.get() && !Util.isDevVersion()) {
ActuallyAdditions.LOGGER.info("Initializing Update Checker...");
new ThreadUpdateChecker();
MinecraftForge.EVENT_BUS.register(this);