Skip to content

Commit

Permalink
add item save cooldown again
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Dec 11, 2023
1 parent 5ce0307 commit f3c42d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.fabricmc.api.Environment;
import net.frozenblock.lib.config.api.instance.Config;
import net.frozenblock.lib.config.clothconfig.FrozenClothConfig;
import net.frozenblock.lib.config.frozenlib_config.FrozenLibConfig;
import net.frozenblock.wilderwild.config.ItemConfig;
import net.frozenblock.wilderwild.misc.WilderSharedConstants;
import static net.frozenblock.wilderwild.misc.WilderSharedConstants.text;
Expand All @@ -37,24 +38,49 @@ private ItemConfigGui() {
}

public static void setupEntries(@NotNull ConfigCategory category, @NotNull ConfigEntryBuilder entryBuilder) {
// WW CONFIG
var config = ItemConfig.get(true);
Class<? extends ItemConfig> clazz = config.getClass();
Config<? extends ItemConfig> configInstance = ItemConfig.INSTANCE;
var modifiedConfig = ItemConfig.getWithSync();
var defaultConfig = ItemConfig.INSTANCE.defaultInstance();
var ancientHorn = config.ancientHorn;
var modifiedAncientHorn = modifiedConfig.ancientHorn;
var ancientHornClass = config.ancientHorn.getClass();
var projectileLandingSounds = config.projectileLandingSounds;
var modifiedProjectileLandingSounds = modifiedConfig.projectileLandingSounds;
// FROZENLIB CONFIG
var frozenLibConfig = FrozenLibConfig.get(true);
Class<? extends FrozenLibConfig> frozenConfigClass = frozenLibConfig.getClass();
Config<? extends FrozenLibConfig> frozenConfigInstance = FrozenLibConfig.INSTANCE;
var modifiedFrozenConfig = FrozenLibConfig.getWithSync();
var defaultFrozenConfig = FrozenLibConfig.INSTANCE.defaultInstance();

category.setBackground(WilderSharedConstants.id("textures/config/item.png"));

var itemCooldownsSave = category.addEntry(
FrozenClothConfig.syncedEntry(
entryBuilder.startBooleanToggle(text("save_item_cooldowns"), modifiedFrozenConfig.saveItemCooldowns)
.setDefaultValue(defaultFrozenConfig.saveItemCooldowns)
.setSaveConsumer(newValue -> {
frozenLibConfig.saveItemCooldowns = newValue;
frozenConfigInstance.save();
})
.setTooltip(tooltip("save_item_cooldowns"))
.build(),
frozenConfigClass,
"saveItemCooldowns",
frozenConfigInstance
)
);

var summonsWarden = FrozenClothConfig.syncedEntry(
entryBuilder.startBooleanToggle(text("ancient_horn_can_summon_warden"), modifiedAncientHorn.ancientHornCanSummonWarden)
.setDefaultValue(defaultConfig.ancientHorn.ancientHornCanSummonWarden)
.setSaveConsumer(newValue -> ancientHorn.ancientHornCanSummonWarden = newValue)
.setTooltip(tooltip("ancient_horn_can_summon_warden"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornCanSummonWarden",
configInstance
);
Expand All @@ -65,7 +91,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setSaveConsumer(newValue -> ancientHorn.ancientHornLifespan = newValue)
.setTooltip(tooltip("ancient_horn_lifespan"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornLifespan",
configInstance
);
Expand All @@ -76,7 +102,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setSaveConsumer(newValue -> ancientHorn.ancientHornMobDamage = newValue)
.setTooltip(tooltip("ancient_horn_mob_damage"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornMobDamage",
configInstance
);
Expand All @@ -87,7 +113,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setSaveConsumer(newValue -> ancientHorn.ancientHornPlayerDamage = newValue)
.setTooltip(tooltip("ancient_horn_player_damage"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornPlayerDamage",
configInstance
);
Expand All @@ -98,7 +124,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setSaveConsumer(newValue -> ancientHorn.ancientHornShattersGlass = newValue)
.setTooltip(tooltip("ancient_horn_shatters_glass"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornShattersGlass",
configInstance
);
Expand All @@ -109,7 +135,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setSaveConsumer(newValue -> ancientHorn.ancientHornSizeMultiplier = newValue)
.setTooltip(tooltip("ancient_horn_size_multiplier"))
.build(),
config.ancientHorn.getClass(),
ancientHornClass,
"ancientHornSizeMultiplier",
configInstance
);
Expand Down Expand Up @@ -189,7 +215,7 @@ public static void setupEntries(@NotNull ConfigCategory category, @NotNull Confi
.setDefaultValue(defaultConfig.restrictInstrumentSound)
.setSaveConsumer(newValue -> config.restrictInstrumentSound = newValue)
.setTooltip(tooltip("restrict_instrument_sound"))
.build() ,
.build(),
clazz,
"restrictInstrumentSound",
configInstance
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/wilderwild/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@
"tooltip.wilderwild.podzol_sounds": "Whether or not Podzol sounds should be overridden.",
"tooltip.wilderwild.projectile_landing_sounds": "Contains toggles for thrown projectile landing sounds.",
"tooltip.wilderwild.projectile_break_particles": "Whether or not projectiles like Arrows or Tridents\nshould emit block breaking particles when colliding.",
"tooltip.wilderwild.item_cooldowns_save": "Whether or not item cooldowns will save instead of being\ncleared upon switching dimensions or rejoining a world.",
"tooltip.wilderwild.item_cooldowns_save": "Whether or not item cooldowns will save instead of being\ncleared upon switching dimensions or rejoining a world.\nAncient Horns will save their cooldowns regardless of this config.",
"tooltip.wilderwild.reinforced_deepslate_sounds": "Whether or not Reinforced Deepslate sounds should be overridden.",
"tooltip.wilderwild.restrict_instrument_sound": "Whether or not instruments, such as the Goat Horn, should stop their sound when the user releases the mouse button",
"tooltip.wilderwild.sapling_sounds": "Whether or not Sapling sounds should be overridden.",
Expand Down

0 comments on commit f3c42d6

Please sign in to comment.