···11+# Mod Properties
22+mod_version=5.0.0
33+maven_group=xyz.sillyjune
44+archives_base_name=notebook
55+16# Done to increase the memory available to gradle.
27org.gradle.jvmargs=-Xmx1G
38org.gradle.parallel=true
···1116loader_version=0.18.2
1217loom_version=1.14-SNAPSHOT
13181414-# Mod Properties
1515-mod_version=5.0.1
1616-maven_group=xyz.sillyjune
1717-archives_base_name=notebook
1818-1919# Dependencies
2020-fabric_version=0.139.4+1.21.11
2020+fabric_version=0.139.4+1.21.11
+99
remappedSrc/xyz/sillyjune/notebook/Notebook.java
···11+package xyz.sillyjune.notebook;
22+33+import com.google.gson.Gson;
44+import com.mojang.blaze3d.platform.InputConstants;
55+import net.fabricmc.api.EnvType;
66+import net.fabricmc.api.Environment;
77+import net.fabricmc.api.ModInitializer;
88+import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
99+import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
1010+import net.minecraft.client.KeyMapping;
1111+import net.minecraft.client.gui.components.WidgetSprites;
1212+import net.minecraft.resources.ResourceLocation;
1313+import org.lwjgl.glfw.GLFW;
1414+import org.slf4j.Logger;
1515+import org.slf4j.LoggerFactory;
1616+1717+import java.io.File;
1818+import java.io.FileWriter;
1919+import java.io.IOException;
2020+import java.nio.file.Files;
2121+import java.nio.file.Paths;
2222+import java.util.Calendar;
2323+import java.util.Date;
2424+2525+@Environment(EnvType.CLIENT)
2626+public class Notebook implements ModInitializer {
2727+ private static KeyMapping openBookKeybind;
2828+ public static WidgetSprites b_id(String id) {
2929+ return new WidgetSprites( // For whatever reason, you can't specify .png at the end of these. I have questions for mojang.
3030+ ResourceLocation.fromNamespaceAndPath("notebook", id + "/unfocused"),
3131+ ResourceLocation.fromNamespaceAndPath("notebook", id + "/focused")
3232+ );
3333+ }
3434+3535+ @Override
3636+ public void onInitialize() {
3737+ String config = NotebookConfig.read_config(); // Read config
3838+ NotebookConfig cfg = NotebookConfig.default_config();
3939+ if (config != null) { // If the config file exists, set it to whatever json was inside
4040+ cfg = new Gson().fromJson(config, NotebookConfig.class);
4141+ } else { // If the config file doesn't exist, get the string version of the defaults we set cfg to
4242+ String json = new Gson().toJson(cfg);
4343+ try { // Write the defaults to config/notebook.json
4444+ FileWriter writer = new FileWriter("config/notebook.json");
4545+ writer.write(json);
4646+ writer.close();
4747+ } catch (IOException e) {
4848+ LOGGER.warn("Failed to create config file!");
4949+ }
5050+ }
5151+ CONFIG = cfg; // Set the config
5252+ openBookKeybindRegister(); // Register keybind for opening the notebook, ";" by default
5353+ if (!new File(BOOK_FOLDER).exists() || !new File(BOOK_FOLDER + "/default.json").exists()) {
5454+ try {
5555+ Files.createDirectories(Paths.get(BOOK_FOLDER));
5656+ NotebookData data = new NotebookData(new String[0], "default.json");
5757+ data.write();
5858+ } catch (IOException e) {
5959+ LOGGER.error("failed to create " + BOOK_FOLDER);
6060+ }
6161+ }
6262+ if (CONFIG.debug()) { LOGGER.error("Juniper is very silly. Continue with extreme caution."); }
6363+ Calendar cal = Calendar.getInstance();
6464+ cal.setTime(new Date());
6565+ if (cal.get(Calendar.MONTH) != Calendar.JUNE) { GAY = false; } // Gay unless proven straight.
6666+ }
6767+6868+ public static void openBookKeybindRegister() { // Register keybind
6969+ openBookKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("key.notebook.open", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_SEMICOLON, KeyMapping.Category.register(ResourceLocation.parse("category.notebook.keys"))));
7070+ ClientTickEvents.END_CLIENT_TICK.register(client -> {
7171+ if (openBookKeybind.wasPressed()) { // Open notebook on key press
7272+ client.setScreen(new NotebookScreen());
7373+ }
7474+ });
7575+7676+ }
7777+ public static WidgetSprites getBookIcon() {
7878+ if (!GAY){
7979+ return MAIN_BUTTON_ICON;
8080+ } else {
8181+ return MAIN_BUTTON_ICON_GAY;
8282+ }
8383+ }
8484+ public static final Logger LOGGER = LoggerFactory.getLogger("notebook");
8585+ public static final WidgetSprites MAIN_BUTTON_ICON_GAY = b_id("book_gay");
8686+ public static final WidgetSprites DEL_BOOK_ICON = b_id("delete_book");
8787+ public static final WidgetSprites MAIN_BUTTON_ICON = b_id("book");
8888+ public static final WidgetSprites NEW_PAGE_ICON = b_id("new_page");
8989+ public static final WidgetSprites DEL_PAGE_ICON = b_id("delete_page");
9090+ public static final WidgetSprites LAST_BOOK_ICON = b_id("last_book");
9191+ public static final WidgetSprites NEW_BOOK_ICON = b_id("new_book");
9292+ public static final WidgetSprites NEXT_BOOK_ICON = b_id("next_book");
9393+ public static final WidgetSprites RENAME_BOOK_ICON = b_id("rename_book");
9494+ public static NotebookConfig CONFIG;
9595+ public static final ResourceLocation BOOK_TEXTURE = ResourceLocation.parse("textures/gui/book.png");
9696+ public static String BOOK_FOLDER = "Notebook";
9797+ public static final String VERSION = "5.0.0";
9898+ public static boolean GAY = true; // I might be straight but gay people are pretty cool
9999+}
···11package xyz.sillyjune.notebook;
2233import com.google.gson.Gson;
44-44+import com.mojang.blaze3d.platform.InputConstants;
55import net.fabricmc.api.EnvType;
66import net.fabricmc.api.Environment;
77import net.fabricmc.api.ModInitializer;
88import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
99import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
1010-import net.minecraft.client.gui.screen.ButtonTextures;
1111-import net.minecraft.client.option.KeyBinding;
1212-import net.minecraft.client.util.InputUtil;
1313-import net.minecraft.util.Identifier;
1010+import net.minecraft.client.KeyMapping;
1111+import net.minecraft.client.gui.components.WidgetSprites;
1212+import net.minecraft.resources.Identifier;
1413import org.lwjgl.glfw.GLFW;
1514import org.slf4j.Logger;
1615import org.slf4j.LoggerFactory;
···25242625@Environment(EnvType.CLIENT)
2726public class Notebook implements ModInitializer {
2828- private static KeyBinding openBookKeybind;
2929- public static ButtonTextures b_id(String id) {
3030- return new ButtonTextures( // For whatever reason, you can't specify .png at the end of these. I have questions for mojang.
3131- Identifier.of("notebook", id + "/unfocused"),
3232- Identifier.of("notebook", id + "/focused")
2727+ private static KeyMapping openBookKeybind;
2828+ public static WidgetSprites b_id(String id) {
2929+ return new WidgetSprites( // For whatever reason, you can't specify .png at the end of these. I have questions for mojang.
3030+ Identifier.fromNamespaceAndPath("notebook", id + "/unfocused"),
3131+ Identifier.fromNamespaceAndPath("notebook", id + "/focused")
3332 );
3433 }
3534···6766 }
68676968 public static void openBookKeybindRegister() { // Register keybind
7070- openBookKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.notebook.open", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_SEMICOLON, KeyBinding.Category.create(Identifier.of("category.notebook.keys"))));
6969+ openBookKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("key.notebook.open", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_SEMICOLON, KeyMapping.Category.register(Identifier.parse("category.notebook.keys"))));
7170 ClientTickEvents.END_CLIENT_TICK.register(client -> {
7272- if (openBookKeybind.wasPressed()) { // Open notebook on key press
7171+ if (openBookKeybind.isDown()) { // Open notebook on key press
7372 client.setScreen(new NotebookScreen());
7473 }
7574 });
76757776 }
7878- public static ButtonTextures getBookIcon() {
7777+ public static WidgetSprites getBookIcon() {
7978 if (!GAY){
8079 return MAIN_BUTTON_ICON;
8180 } else {
···8382 }
8483 }
8584 public static final Logger LOGGER = LoggerFactory.getLogger("notebook");
8686- public static final ButtonTextures MAIN_BUTTON_ICON_GAY = b_id("book_gay");
8787- public static final ButtonTextures DEL_BOOK_ICON = b_id("delete_book");
8888- public static final ButtonTextures MAIN_BUTTON_ICON = b_id("book");
8989- public static final ButtonTextures NEW_PAGE_ICON = b_id("new_page");
9090- public static final ButtonTextures DEL_PAGE_ICON = b_id("delete_page");
9191- public static final ButtonTextures LAST_BOOK_ICON = b_id("last_book");
9292- public static final ButtonTextures NEW_BOOK_ICON = b_id("new_book");
9393- public static final ButtonTextures NEXT_BOOK_ICON = b_id("next_book");
9494- public static final ButtonTextures RENAME_BOOK_ICON = b_id("rename_book");
8585+ public static final WidgetSprites MAIN_BUTTON_ICON_GAY = b_id("book_gay");
8686+ public static final WidgetSprites DEL_BOOK_ICON = b_id("delete_book");
8787+ public static final WidgetSprites MAIN_BUTTON_ICON = b_id("book");
8888+ public static final WidgetSprites NEW_PAGE_ICON = b_id("new_page");
8989+ public static final WidgetSprites DEL_PAGE_ICON = b_id("delete_page");
9090+ public static final WidgetSprites LAST_BOOK_ICON = b_id("last_book");
9191+ public static final WidgetSprites NEW_BOOK_ICON = b_id("new_book");
9292+ public static final WidgetSprites NEXT_BOOK_ICON = b_id("next_book");
9393+ public static final WidgetSprites RENAME_BOOK_ICON = b_id("rename_book");
9594 public static NotebookConfig CONFIG;
9696- public static final Identifier BOOK_TEXTURE = Identifier.of("textures/gui/book.png");
9595+ public static final Identifier BOOK_TEXTURE = Identifier.parse("textures/gui/book.png");
9796 public static String BOOK_FOLDER = "Notebook";
9898- public static final String VERSION = "5.0.1";
9797+ public static final String VERSION = "5.0.0";
9998 public static boolean GAY = true; // I might be straight but gay people are pretty cool
10099}