Skip to content

Commit

Permalink
Merge branch 'master' into reforgetooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker authored Dec 12, 2024
2 parents 0ee0512 + 562d031 commit 1e774d0
Show file tree
Hide file tree
Showing 40 changed files with 1,141 additions and 29 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
implementation("org.eclipse.jgit:org.eclipse.jgit:7.0.0.202409031743-r")
implementation("org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r")

implementation("com.google.code.gson:gson:2.11.0")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=1.3.4-beta.4
mod_version=1.3.4-beta.5
maven_group=cookiesmod
archives_base_name=cookies-mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ protected void generateLocals(
translationBuilder.add(ITEM_SOURCE_BACKPACK, "Backpack");
translationBuilder.add("cookies.mod.keybinds", "Cookies Mod");
translationBuilder.add("cookies.mod.search", "Item Search");
translationBuilder.add("cookies.mod.garden.keybind_switch", "Garden Keybinds Switcher");
translationBuilder.add("cookies.mod.garden.keybinds.enabled", "Garden Keybinds Enabled");
translationBuilder.add("cookies.mod.garden.keybinds.disabled", "Garden Keybinds Disabled");

this.addItemStats(translationBuilder);
this.addMisc(translationBuilder);
Expand Down Expand Up @@ -323,6 +326,19 @@ private void addFarmingConfig(CookiesTranslationBuilder translationBuilder) {
"Highlight unclaimed",
"Highlight unclaimed jacob contests in his inventory.");

translationBuilder.add(CONFIG_FARMING_RENDER, "Render");
translationBuilder.addConfig(
CONFIG_FARMING_RENDER_HIGHLIGHT_GLOWING_MUSHROOMS,
"Highlight glowing mushrooms",
"Highlights glowing mushrooms by drawing an outline around them.");

translationBuilder.add(CONFIG_FARMING_CATEGORIES_GARDEN_KEYBINDS, "Garden Keybinds");
translationBuilder.addConfig(CONFIG_FARMING_OPEN_KEYBIND_MENU, "Open Keybind Menu", "Opens the garden keybind menu.");

translationBuilder.add(CONFIG_FARMING_OPEN_KEYBIND_TEXT, "Click Here!");
translationBuilder.add(CONFIG_FARMING_KEYBIND_MENU_TITLE, "Garden Keybinds");
translationBuilder.addConfig(CONFIG_FARMING_GARDEN_KEYBIND_PREDICATE, "Predicate: ", "When to enable garden keybinds.");

translationBuilder.addConfig(CONFIG_MISC_NOTIFICATIONS_PEST, "Pest Warnings" ,"Warns you 10s before pests can spawn!");
translationBuilder.addConfig(CONFIG_MISC_NOTIFICATIONS_PEST_ORDER, "Pest timer", """
Changes what pest time to use for the notifications,
Expand Down Expand Up @@ -398,6 +414,7 @@ private void addMiningConfig(CookiesTranslationBuilder translationBuilder) {
CONFIG_MINING_MOD_CRYSTAL_HUD,
"Crystal Hud",
"Enables the crystal hud, shows information about current crystal status, parts available and tools available.\n\n§cRequires the crystal player list widget to be active!");
translationBuilder.addConfig(CONFIG_MINING_GLOSSY_GEMSTONE_MESSAGE, "Glossy gemstone message", "Adds messages when you drop a glossy gemstone");
translationBuilder.addConfig(CONFIG_MINING_PUZZLER_SOLVER,
"Puzzler solver",
"Highlight the correct block for the puzzler.");
Expand Down Expand Up @@ -497,6 +514,10 @@ private void addMiscConfig(CookiesTranslationBuilder translationBuilder) {
translationBuilder.addConfig(CONFIG_MISC_SHOW_PET_RARITY_IN_LEVEL_TEXT,
"Show rarity in level",
"Shows the pet level in the color of the rarity");
translationBuilder.addConfig(
CONFIG_MISC_SHOW_ITEM_UPGRADES,
"Show item stars",
"Shows the amount of stars that are applied to an item in the slot text.");
translationBuilder.addConfig(CONFIG_MISC_SHOW_FORGE_RECIPE_STACK,
"Show forge recipes",
"Shows forge recipes in the recipe book");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.3 2024-12-11T14:15:47.3017455 cookies-mod/Language (en_us)
b38b189b066d12ab0c2d533a84fa00f9718ed60c assets\cookies-mod\lang\en_us.json
b38b189b066d12ab0c2d533a84fa00f9718ed60c assets\cookies-mod\lang\en_us.json
17 changes: 17 additions & 0 deletions src/main/generated/assets/cookies-mod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,27 @@
"cookies.config.dungeon.use_features.name": "Enabled dungeon features",
"cookies.config.dungeon.use_features.tooltip": "Enables or disables all dungeon features. This will not work for ongoing runs.",
"cookies.config.farming.categories.compost": "Composter",
"cookies.config.farming.categories.garden_keybinds": "Garden Keybinds",
"cookies.config.farming.categories.jacobs": "Jacob / Contests",
"cookies.config.farming.categories.ranchers": "Rancher's Boots",
"cookies.config.farming.categories.render": "Render",
"cookies.config.farming.categories.visitor": "Visitors",
"cookies.config.farming.compost_sort_order.name": "Item sort",
"cookies.config.farming.compost_sort_order.tooltip": "How the items should be sorted.",
"cookies.config.farming.compost_sort_order.values.ascending": "Ascending",
"cookies.config.farming.compost_sort_order.values.descending": "Descending",
"cookies.config.farming.compost_sort_order.values.unsorted": "Unsorted",
"cookies.config.farming.garden_keybind_predicate.name": "Predicate: ",
"cookies.config.farming.garden_keybind_predicate.tooltip": "When to enable garden keybinds.",
"cookies.config.farming.highlight_glowing_mushrooms.name": "Highlight glowing mushrooms",
"cookies.config.farming.highlight_glowing_mushrooms.tooltip": "Highlights glowing mushrooms by drawing an outline around them.",
"cookies.config.farming.highlight_unclaimed_jacobs_contents.name": "Highlight unclaimed",
"cookies.config.farming.highlight_unclaimed_jacobs_contents.tooltip": "Highlight unclaimed jacob contests in his inventory.",
"cookies.config.farming.keybind_menu_title": "Garden Keybinds",
"cookies.config.farming.name": "Farming Config",
"cookies.config.farming.open_keybind_menu.name": "Open Keybind Menu",
"cookies.config.farming.open_keybind_menu.text": "Click Here!",
"cookies.config.farming.open_keybind_menu.tooltip": "Opens the garden keybind menu.",
"cookies.config.farming.show_compost_price_breakdown.name": "Compost upgrade price",
"cookies.config.farming.show_compost_price_breakdown.tooltip": "Shows the amount of items required to max an upgrade.",
"cookies.config.farming.show_rancher_optimal_speeds.name": "Show rancher overlay",
Expand Down Expand Up @@ -246,6 +256,8 @@
"cookies.config.mining.categories.hotm": "HOTM",
"cookies.config.mining.crystal_hud.name": "Crystal Hud",
"cookies.config.mining.crystal_hud.tooltip": "Enables the crystal hud, shows information about current crystal status, parts available and tools available.\n\n§cRequires the crystal player list widget to be active!",
"cookies.config.mining.glossy_gemstone_message.name": "Glossy gemstone message",
"cookies.config.mining.glossy_gemstone_message.tooltip": "Adds messages when you drop a glossy gemstone",
"cookies.config.mining.highlight_disabled_hotm_perks.name": "Highlight disabled",
"cookies.config.mining.highlight_disabled_hotm_perks.tooltip": "Change disabled perks to redstone.",
"cookies.config.mining.mod_helper.name": "Mod Helper",
Expand Down Expand Up @@ -341,6 +353,8 @@
"cookies.config.misc.show_item_creation_date.tooltip": "Shows the creation dates of items.",
"cookies.config.misc.show_item_npc_value.name": "NPC Value",
"cookies.config.misc.show_item_npc_value.tooltip": "Show the npc value of items.",
"cookies.config.misc.show_item_upgrades.name": "Show item stars",
"cookies.config.misc.show_item_upgrades.tooltip": "Shows the amount of stars that are applied to an item in the slot text.",
"cookies.config.misc.show_museum_armor_sets.name": "Show museum armor sets",
"cookies.config.misc.show_museum_armor_sets.tooltip": "Shows the components of an armor set in the description.",
"cookies.config.misc.show_pet_level.name": "Show pet level",
Expand Down Expand Up @@ -410,6 +424,9 @@
"cookies.item_stats.value.obtained": "Obtained",
"cookies.keybind": "Cookies Mod",
"cookies.left_click_to_view": "Left-click to view",
"cookies.mod.garden.keybind_switch": "Garden Keybinds Switcher",
"cookies.mod.garden.keybinds.disabled": "Garden Keybinds Disabled",
"cookies.mod.garden.keybinds.enabled": "Garden Keybinds Enabled",
"cookies.mod.keybinds": "Cookies Mod",
"cookies.mod.search": "Item Search",
"cookies.not_found": "Not Found",
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/codes/cookies/mod/CookiesMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import codes.cookies.mod.commands.system.CommandManager;
import codes.cookies.mod.config.ConfigManager;
import codes.cookies.mod.config.screen.ConfigScreen;
import codes.cookies.mod.data.cookiesmoddata.CookieDataManager;
import codes.cookies.mod.data.profile.ProfileStorage;
import codes.cookies.mod.events.EventLoader;
import codes.cookies.mod.features.Features;
import codes.cookies.mod.features.farming.garden.keybinds.GardenKeybindPredicate;
import codes.cookies.mod.render.hud.HudEditScreen;
import codes.cookies.mod.render.hud.HudManager;
import codes.cookies.mod.repository.Repository;
Expand All @@ -23,6 +25,9 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import codes.cookies.mod.utils.cookies.CookiesUtils;
import codes.cookies.mod.utils.dev.DevUtils;
import codes.cookies.mod.utils.skyblock.LocationUtils;
import codes.cookies.mod.utils.skyblock.MayorUtils;
import codes.cookies.mod.utils.skyblock.playerlist.PlayerListUtils;
import lombok.Getter;
Expand All @@ -38,14 +43,16 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;

import org.lwjgl.glfw.GLFW;

/**
* Main class of the mod, mainly initialization and loading of further components/features.
*/
public class CookiesMod implements ClientModInitializer {
public static KeyBinding chestSearch;

private static KeyBinding useGardenKeybinds;
@Getter
private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);

Expand All @@ -68,6 +75,7 @@ public static void openScreen(Screen screen) {
@Override
public void onInitializeClient() {
CommandManager.initialize();
CookieDataManager.load();
ProfileStorage.register();
Repository.loadRepository();
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket.class);
Expand All @@ -82,18 +90,31 @@ public void onInitializeClient() {
HudManager.load();
CrystalStatusService.register();
this.registerKeyBindings();
DevUtils.registerDebugs();
}

private void registerKeyBindings() {
chestSearch = KeyBindingHelper.registerKeyBinding(new KeyBinding("cookies.mod.search",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_O,
"cookies.mod.keybinds"));
useGardenKeybinds = KeyBindingHelper.registerKeyBinding(new KeyBinding("cookies.mod.garden.keybind_switch",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_K,
"cookies.mod.keybinds"));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (chestSearch.isPressed()) {
openScreen(new ItemSearchScreen());
}
while(useGardenKeybinds.wasPressed() && LocationUtils.Island.GARDEN.isActive()) {
GardenKeybindPredicate.keyBindToggle = !GardenKeybindPredicate.keyBindToggle;
for (var keybind : KeyBinding.KEYS_BY_ID.values()) {
keybind.setPressed(false);
keybind.timesPressed = 0;
}
CookiesUtils.sendMessage(Text.translatable("cookies.mod.garden.keybinds." + (GardenKeybindPredicate.keyBindToggle ? "enabled" : "disabled")), false);
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
import codes.cookies.mod.config.system.Parent;
import codes.cookies.mod.config.system.Row;
import codes.cookies.mod.config.system.options.BooleanOption;
import codes.cookies.mod.config.system.options.ButtonOption;
import codes.cookies.mod.config.system.options.EnumCycleOption;
import codes.cookies.mod.config.system.options.TextDisplayOption;

import codes.cookies.mod.features.farming.garden.keybinds.GardenKeybindPredicate;
import codes.cookies.mod.features.farming.garden.keybinds.GardenKeybindsScreen;
import codes.cookies.mod.features.farming.garden.PestTimerHud;
import codes.cookies.mod.features.misc.timer.NotificationManager;

import net.minecraft.client.MinecraftClient;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
Expand All @@ -35,6 +39,15 @@ public class FarmingConfig extends Category {

public PestFoldable pestFoldable = new PestFoldable();

@Parent
public TextDisplayOption keybindsText = new TextDisplayOption(CONFIG_FARMING_CATEGORIES_GARDEN_KEYBINDS);

public ButtonOption openKeybindMenu = new ButtonOption(CONFIG_FARMING_OPEN_KEYBIND_MENU, () -> MinecraftClient.getInstance().setScreen(new GardenKeybindsScreen(MinecraftClient.getInstance().currentScreen)), CONFIG_FARMING_OPEN_KEYBIND_TEXT);

public EnumCycleOption<GardenKeybindPredicate> gardenKeybindPredicate = new EnumCycleOption<>(CONFIG_FARMING_GARDEN_KEYBIND_PREDICATE, GardenKeybindPredicate.ON_GARDEN)
.withSupplier(value -> Text.literal(value.getName()));


@Parent
public TextDisplayOption ranchers = new TextDisplayOption(CONFIG_FARMING_CATEGORIES_RANCHERS);

Expand Down Expand Up @@ -73,6 +86,11 @@ public class FarmingConfig extends Category {
public BooleanOption highlightUnclaimedJacobContests =
new BooleanOption(CONFIG_FARMING_HIGHLIGHT_UNCLAIMED_JACOB_CONTENTS, false);

@Parent
public TextDisplayOption renderText = new TextDisplayOption(CONFIG_FARMING_RENDER);

public BooleanOption highlightGlowingMushrooms = new BooleanOption(CONFIG_FARMING_RENDER_HIGHLIGHT_GLOWING_MUSHROOMS, false);

public FarmingConfig() {
super(new ItemStack(Items.WHEAT), CONFIG_FARMING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public class MiscConfig extends Category {
public BooleanOption showPetRarityInLevelText =
new BooleanOption(CONFIG_MISC_SHOW_PET_RARITY_IN_LEVEL_TEXT, false).onlyIf(this.showPetLevelAsStackSize);

public BooleanOption showItemUpgrades = new BooleanOption(CONFIG_MISC_SHOW_ITEM_UPGRADES, false);

@Expose
public BooleanOption showForgeRecipeStack = new BooleanOption(CONFIG_MISC_SHOW_FORGE_RECIPE_STACK, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MiningConfig extends Category {
public PowderTrackerHudFoldable powderTrackerHud = new PowderTrackerHudFoldable();
@HudSetting(CrystalRunHud.class)
public BooleanOption crystalHud = new BooleanOption(CONFIG_MINING_MOD_CRYSTAL_HUD, true);
public BooleanOption glossyGemstoneMessages = new BooleanOption(CONFIG_MINING_GLOSSY_GEMSTONE_MESSAGE, true);

@Parent
public TextDisplayOption hotmParentDisplay = new TextDisplayOption(CONFIG_MINING_CATEGORIES_HOTM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public boolean keyPressed(final int keyCode, final int scanCode, final int modif
if (hasBeenConsumed.get()) {
return true;
}
if (MinecraftClient.getInstance().options.inventoryKey.matchesKey(keyCode, scanCode)) {
if (!searchField.isFocused() && MinecraftClient.getInstance().options.inventoryKey.matchesKey(keyCode, scanCode)) {
this.close();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package codes.cookies.mod.data.cookiesmoddata;

import codes.cookies.mod.data.farming.GardenKeybindsData;

public final class CookieDataInstances {
public static final GardenKeybindsData gardenKeybindsData = new GardenKeybindsData();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package codes.cookies.mod.data.cookiesmoddata;

import codes.cookies.mod.utils.exceptions.ExceptionHandler;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import lombok.SneakyThrows;

import net.fabricmc.loader.api.FabricLoader;

import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

public class CookieDataManager {
public static final Path MOD_DATA_FOLDER = Path.of(FabricLoader.getInstance().getConfigDir().toString(), "cookiesmod/data");

public static void load() {
if(!Files.exists(MOD_DATA_FOLDER)) {
ExceptionHandler.tryCatch(() -> Files.createDirectories(MOD_DATA_FOLDER));
}

for (Field declaredField : CookieDataInstances.class.getDeclaredFields()) {
ExceptionHandler.tryCatch(() -> loadField(declaredField));
}
}

public static void save(CookiesModData modData) {
final Path dataLocation = MOD_DATA_FOLDER.resolve(modData.getFileLocation());
final JsonElement jsonElement = modData.write();
final byte[] content = jsonElement.toString().getBytes(StandardCharsets.UTF_8);

ExceptionHandler.tryCatch(() -> {
saveFile(dataLocation, content);
});
}

private static void loadField(Field declaredField) {
declaredField.setAccessible(true);

final Object instance;
try {
instance = declaredField.get(null);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}

if (!(instance instanceof CookiesModData data)) {
return;
}

final Path dataLocation = MOD_DATA_FOLDER.resolve(data.getFileLocation());
if (!Files.exists(dataLocation)) {
return;
}

final byte[] bytes;
try {
bytes = readFile(dataLocation);
} catch (IOException e) {
throw new RuntimeException(e);
}

final String fileContent = new String(bytes, StandardCharsets.UTF_8);
final JsonElement fileElement = JsonParser.parseString(fileContent);
if(fileElement.isJsonObject())
data.read(fileElement.getAsJsonObject());
}

private static byte[] readFile(Path filePath) throws IOException {
return Files.readAllBytes(filePath);
}

@SneakyThrows
private static void saveFile(Path filePath, byte[] content) {
Files.write(filePath, content, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package codes.cookies.mod.data.cookiesmoddata;

import codes.cookies.mod.utils.json.JsonSerializable;
import lombok.SneakyThrows;

public interface CookiesModData extends JsonSerializable {
String getFileLocation();

default void save() {
CookieDataManager.save(this);
}
}
Loading

0 comments on commit 1e774d0

Please sign in to comment.