Achievement & Config Button toggles

This commit is contained in:
nelle 2023-09-29 05:10:06 -06:00
parent d7feffc851
commit ef1ce69f29
4 changed files with 16 additions and 5 deletions

View file

@ -31,7 +31,7 @@ public class EMB implements ModInitializer {
ModSemltingRecipes.registerModSmeltingRecipes();
ModCraftingRecipes.registerModRecipes();
ModAchievements.registerModAchievements();
if(ModConfigs.ENABLE_ACHIEVEMENTS){ModAchievements.registerModAchievements();}
ModSounds.registerModSounds();

View file

@ -2,16 +2,18 @@ package xyz.limepot.emb.advancement;
import net.minecraft.advancement.Achievement;
import xyz.limepot.emb.EMB;
import xyz.limepot.emb.config.ModConfigs;
import xyz.limepot.emb.item.ModItems;
import static net.minecraft.advancement.AchievementsAndCriterions.ACQUIRE_IRON;
import static net.minecraft.advancement.AchievementsAndCriterions.BUILD_FURNACE;
public class ModAchievements {
public static Achievement BURY_ME_WITH_MY_MONEY = new Achievement("achievement.getMoney", "getMoney", 1, 6, ModItems.GOLD_COIN, ACQUIRE_IRON).addStat();
public static Achievement BURY_ME_WITH_MY_MONEY = new Achievement("achievement.getMoney", "getMoney", 1, 6, ModItems.GOLD_COIN, ACQUIRE_IRON).addStat();
public static void registerModAchievements() {
EMB.LOGGER.debug("Registering Achievements....");
}
}

View file

@ -7,6 +7,8 @@ public class ModConfigs {
public static SimpleConfig CONFIG;
private static ModConfigProvider configs;
public static boolean TUTORIAL_BUTTON_TOGGLE;
public static boolean CONFIG_BUTTON_TOGGLE;
public static boolean ENABLE_ACHIEVEMENTS;
public static void registerConfigs() {
configs = new ModConfigProvider();
@ -18,11 +20,15 @@ public class ModConfigs {
}
private static void createConfigs() {
configs.addKeyValuePair(new Pair("tutorial.button.toggle", false), "True Or False");
configs.addKeyValuePair(new Pair("tutorial.button.toggle", false), "True Or False - True being enable the feature, False being disable");
configs.addKeyValuePair(new Pair("config.button.toggle", false), "True Or False - True being enable the feature, False being disable");
configs.addKeyValuePair(new Pair("enable.achievements", false), "True Or False - True being enable the feature, False being disable");
}
private static void assignConfigs() {
TUTORIAL_BUTTON_TOGGLE = CONFIG.getOrDefault("tutorial.button.toggle", true);
TUTORIAL_BUTTON_TOGGLE = CONFIG.getOrDefault("tutorial.button.toggle", false);
CONFIG_BUTTON_TOGGLE = CONFIG.getOrDefault("config.button.toggle", false);
ENABLE_ACHIEVEMENTS = CONFIG.getOrDefault("enable.achievements", false);
System.out.println("All " + configs.getConfigsList().size() + " have been set properly");
}

View file

@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xyz.limepot.emb.config.ModConfigs;
import static xyz.limepot.emb.config.ModConfigs.TUTORIAL_BUTTON_TOGGLE;
@ -15,7 +16,9 @@ import static xyz.limepot.emb.config.ModConfigs.TUTORIAL_BUTTON_TOGGLE;
public class SettingScreenMixin extends Screen {
@Inject(at = @At("RETURN"), method = "init")
private void addCustomButton(CallbackInfo ci) {
this.buttons.add(new ButtonWidget(13, this.width / 2 - 155, this.height / 6 + 48 - 6, 150, 20, I18n.translate("menu.embOptions", new Object[0])));
if(ModConfigs.CONFIG_BUTTON_TOGGLE) {
this.buttons.add(new ButtonWidget(13, this.width / 2 - 155, this.height / 6 + 48 - 6, 150, 20, I18n.translate("menu.embOptions", new Object[0])));
}
}
@Inject(at = @At("RETURN"), method = "buttonClicked")