From 086b12855176e9d2b146b4697440bba46dbf656f Mon Sep 17 00:00:00 2001 From: Jonas_Jones <91549607+J-onasJones@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:32:05 +0200 Subject: [PATCH] Added Config System, Verbose Logger and Pin-Map Entries MOD REBRAND from "Minecraft Arduino Controls" to "MicrocontrollerMC" (to also include other Boards) Introduction of Config file system Introduction of Verbose Logger (toggle-able in config file) Introduction of Pin-Map Entries and their Display status in config file Enhancement of fabric.json to improve visibility in ModMenu --- README.md | 2 +- .../fabric.mod.json | 18 +- .../arduinoctrls/ArduinoControls.class | Bin 1051 -> 1101 bytes .../config/ModConfigProvider.class | Bin 0 -> 2198 bytes .../arduinoctrls/config/ModConfigs.class | Bin 0 -> 7022 bytes .../config/SimpleConfig$ConfigRequest.class | Bin 0 -> 2194 bytes .../config/SimpleConfig$DefaultConfig.class | Bin 0 -> 478 bytes .../arduinoctrls/config/SimpleConfig.class | Bin 0 -> 5804 bytes .../jonasjones/arduinoctrls/gui/GuiHome.class | Bin 3389 -> 3408 bytes .../mixin/GameMenuScreenMixin.class | Bin 3257 -> 3257 bytes .../arduinoctrls/util/VerboseLogger.class | Bin 0 -> 1220 bytes .../arduinoctrls/ArduinoControls.java | 39 +-- .../config/ModConfigProvider.java | 30 +++ .../arduinoctrls/config/ModConfigs.java | 110 ++++++++ .../arduinoctrls/config/SimpleConfig.java | 250 ++++++++++++++++++ .../jonasjones/arduinoctrls/gui/GuiHome.java | 2 +- .../arduinoctrls/util/VerboseLogger.java | 33 +++ src/main/resources/fabric.mod.json | 18 +- 18 files changed, 471 insertions(+), 31 deletions(-) create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/ModConfigProvider.class create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/ModConfigs.class create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/SimpleConfig$ConfigRequest.class create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/SimpleConfig$DefaultConfig.class create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/SimpleConfig.class create mode 100644 production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/util/VerboseLogger.class create mode 100644 src/main/java/me/jonasjones/arduinoctrls/config/ModConfigProvider.java create mode 100644 src/main/java/me/jonasjones/arduinoctrls/config/ModConfigs.java create mode 100644 src/main/java/me/jonasjones/arduinoctrls/config/SimpleConfig.java create mode 100644 src/main/java/me/jonasjones/arduinoctrls/util/VerboseLogger.java diff --git a/README.md b/README.md index 8297c99..963a5fd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MinecraftArduinoControls +# MicrocontrollerMC A Minecraft mod that allows for Arduino Control ## This is a *very* *very* early state of this mod. Only a very small amount of the planned content for this mod has been implemented yet so basically don't even bother trying it out. \ No newline at end of file diff --git a/production/MinecraftArduinoControls.main/fabric.mod.json b/production/MinecraftArduinoControls.main/fabric.mod.json index 194012f..a608661 100644 --- a/production/MinecraftArduinoControls.main/fabric.mod.json +++ b/production/MinecraftArduinoControls.main/fabric.mod.json @@ -3,14 +3,15 @@ "id": "arduinoctrls", "version": "v0.0.1alpha01", - "name": "Minecraft Arduino Controls", - "description": "A mod that allows for communication between the Minecraft client and an Arduino.", + "name": "MicrocontrollerMC", + "description": "A mod that allows for communication between the Minecraft client and multiple microcontrollers, allowing for ingame triggers of actions.", "authors": [ "Jonas_Jones" ], "contact": { - "homepage": "https://jonasjones.me/MinecraftArduinoControls", - "sources": "https://github.com/J-onasJones/MinecraftArduinoControls" + "homepage": "https://jonasjones.me/MicrocontrollerMC", + "sources": "https://github.com/J-onasJones/MicrocontrollerMC", + "issues": "https://github.com/J-onasJones/MicrocontrollerMC/issues" }, "license": "CC0-1.0", @@ -18,7 +19,7 @@ "environment": "client", "entrypoints": { - "main": [ + "client": [ "me.jonasjones.arduinoctrls.ArduinoControls" ] }, @@ -34,5 +35,12 @@ }, "suggests": { "another-mod": "*" + }, + "custom": { + "modmenu": { + "links": { + "modmenu.discord": "https://discord.com/invite/V2EsuUVmWh" + } + } } } diff --git a/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/ArduinoControls.class b/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/ArduinoControls.class index 9314d6b3ac5481fc14217dc1727b5965c9432f74..21bbe19112dab35212a83ff81e0e8dce135da7fe 100644 GIT binary patch literal 1101 zcmaJ>TT|0e5dKbENE(7bxCwFz3J6Gv7rcVbD7Rsz*cp(%I;Y_@o=%$MoTM`Puha+8 z2Y-M+%5l?FV5-B***#}>zuohE&n)DSH&C$AgIOc&A@<-K@2ghT!Hp7gQmbltB|mI%ay&ookIqvtaRYTVST;fl~oW3 zymKdflXLCz#b?5L^b$0<-}F8HUV2-h6j4HB->0>aJd~e=rg0rqw%_h=r{nsEQ39sX#0ig* zDi2$N=-*N&BnHYd60cj$n$T}}Eu(=(c&hcKk zVwEdLR-sZZ7Yj$lom>*j4CZwz)5zhTf%_&N;330oKll=NBc;z6Qoe|~gfcw3iHQG+ zH}IHYITVpy<5ex)hHLYtwD*;_*Tel;XkxdZJi##T$WWBqjjGT`yc&>&X6f?aglie= zJ>y{XUedtVoLhMAdmfvFS%p_M85m`^t_|}hrYUOlFyij%K5zDFC%0T;xAS1rhpMez zQKC68O!XC9k7r24CTRhPE&Ar;H%(hHKxbM8k}IUy^k?)RTKx`oPKN~YBx5%yc$K8t zy?`fJBaPwdW$+o@PLOT!D~!zO4~!>pf$1+8b7I3{$8b&&X^heX&r<0)cb4LTDYDLx zeV#nCn8X|w$P?F_p`4TCUGFqU*?X0rkJ5(d>+vtBAbU! z&-H_r486#11^%AfwzmSO7SFcB;K+4E$S|w7NGydfBL=H}X1pOo*Kb!0oM*TYi+j@b z?E7KJkLzwEv&bQ-+_+%kA}%q^XtYRe5)BO%>nKTO26MP<;EIX2@ebKOgVYL1?l=sW ziUTfa{*}`AS-gvD2CkbZV4mT6E9lsr;6TO5;gavUKZ-E2V_VzYC1&Zikn3)!9JyF5 zjY1l@F%)S{R++hJ;+C?JA%un?N{&ToDw-&v%rMvChl1kO;_|60_h}YM9*52!bi5zC z0lTA;KDjqJGf3bxEw>q}le6A%J6%tCOeL`JQ0(!ZC-sUbHr%$)WiJ#|K-!PfbXDsU zVq96PFr;dML&~|j>x;*|&aMb|_^wA1s~)tt*W{tA)_q}0?z>cE%k{}_j}$8zo286s z*ZU=Aon-dZYdW<&B78F{IV!(RaopryPv{z2DNc;RX!1%;2J>(TXMQ3KgF(^mP!BTX zha-2~J&E4RB$(=`H)WNi&51n5YmUMxa!JYp!>uvZKBh{k#(drpQJ1%`48rdnBzYToIkm>21I>`8uz@0 zD@7%ZI$d>)t+K)mR`{vl=*GNPU|A}kN4_t@n#ZF^LBd`ROgodcn#VA5#eBU+hS6CdLatr$MRGFeclHmwxu zRQWlqUulwn0#Qamuhg0HR9{&;w?g}$;9rQO>EK1 SBKaa7V|zM-Z_vPZxbiPcm`qpz literal 0 HcmV?d00001 diff --git a/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/ModConfigs.class b/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/ModConfigs.class new file mode 100644 index 0000000000000000000000000000000000000000..d1ff69e914e8574ba6e4bef654eb20c7d98802cf GIT binary patch literal 7022 zcmds5dwd*K75;8hx|{8kw(0vlrG+MiWGe`iraU&urfj=;kWEwC@|xYfyP0NoW|^5y z8&DKfR76BnL{tzI-=egd77*}_0*db!zC}^Q_xpvOduL`dn`|om{rJm2lDp^3ch5cd z-0z-y?|J0e`yK>vHaj_n8EA-Lrh?-zi(%eAZB&aJnpuqZW%u!%%P?!JZtCti3=PdK zLlHz7PAl>FKFib``p2EPX6GxqY2{qoaN;@3Ea=5}kCpF~zxr)!RL^reh6oxOF&jz* za}*qpxeTWqgB^z<=GpGibd%xq^f7b}oM;yg%vaDPMxX7OOY4s7#7MtT!6FfYIXRna zF8ADbB3Qz(@hD>@yx9}nwJpPmVj08ya7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1J1?((XkL7s1BGxEhzxB43Kz zaT)H0h6j+vW60wPa6F9yEq0MbG0c`wvFjx4W2aLcsEf)ydtg%5s-_93GIvoX6VyM1 zhbBDnGTZ_*u*Kxj47P*`&!R+%W%Rd(ttDwWQDZGuuoEcjt)uqDS&i%@*333y*?$3Q CX)V?O literal 0 HcmV?d00001 diff --git a/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/SimpleConfig$ConfigRequest.class b/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/config/SimpleConfig$ConfigRequest.class new file mode 100644 index 0000000000000000000000000000000000000000..ce6c351d9ee52d08e1a532142da44061be163983 GIT binary patch literal 2194 zcmcIm>r&G|6#h1phL&(Ea`T2DU|W$WUa^Qk6+sKAD30T=rQJdxO=^-d!yli+$IuxV zN1X8i9G}VYY!alk4r9mhPj=7A+3!1hE;;%3&)Zhf z*wojIQrQ$)Ul<9N=i+TexC9+38m3@q&-tu|tuK(AksR$BI?&0`A}uUlBCAAT<@>hg zIfk{FNzfe<8oF_cyxSCnIGar68uaObDDsNw1+Mwzy&C$^Pvm9C-ZcusVVLl8h>{{b&i^4vfR)2#c>;VR7`2O3!)r8 z<}j>Xdq?OwUfL*dI>C!P@7c~CLu;v8`d(d5;h}(Fky`~*xFb2+-l>!`_5N3BY7V~G zD~oFLzkeA}o_w}CkRfuGo93F~iA*PkDJnCv;qGggm9^h2N@Z`4wDWOf@j%5x*%S-Z z9Cfh@(n2YtK3O=5*8Be-pRgR>RK+tG093+tPX4-U3l0rNP8i` zKpK}xA~c_y`8&z35L+L{L(cmoOCMFq*OUH0TLqFrj$&Yeh#vW{y@A;;Sk=D*BbY0g z2*IuswIqst!N6;}#F=BbsQ==b52Xc0A(R3gS3`h%L?QvY)BEJiKH5Ixyn;hq1b&Bl zSq0S{LPcT3yNvkUUEq1gl$Zcd=8+J|-=*~@PQ@T;r7Ng&T$`DsnV!ZE0E>Nz>Yt)CR3iHj`wU-I?vo zY?}%wAXfzi0R;*oc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!6j4D<4% z>H?H%LV1}qr55-HOK9NxB=1tzB$;7S=b#=3LG^+XqXz^bb0N<#;pUa$=6Y^sBVcYn zDzozI!7CH|n`0b<5PFIE_i_=}`jBe`|5UPH!M}K~Ac`s+#A|$>2Mw=7h)L=iJXfmc lDs`<^*D2~+E9$tTp21RugqTWW9prslMWvW7ju!Qp@ozeM?1caT literal 0 HcmV?d00001 diff --git a/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/gui/GuiHome.class b/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/gui/GuiHome.class index 1d3b53e3b065973c0273cd0cecd0a5ab31e5c190..892dff2e3b381139bc28b2e42042eeb3219728d7 100644 GIT binary patch delta 21 ccmdlhbwO%_7&D{vaZ=O5=iSi65 delta 63 zcmdlfxl?k(A}&r5237_k1`!64$*Z{*iApl?Fi10qF~~3|GRQI51IYvi<;h9hlNc2z Sf8`Ejm1p2*P?+q^lLr8cVhl3? diff --git a/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/util/VerboseLogger.class b/production/MinecraftArduinoControls.main/me/jonasjones/arduinoctrls/util/VerboseLogger.class new file mode 100644 index 0000000000000000000000000000000000000000..be4a21b13d2fa23142df146702a2b7c4d04c4c68 GIT binary patch literal 1220 zcmb7?+iuf95QhIv(;BDSrcK(=Qd-KnO%LW!;39xTtI(UYks1^s?l#WGI5=LkcHmif z40-`77d!wDg_w0Lg%T+dzOZ+H&wTUG?Ed=w<0pU@c$Py3Qx>uu)0kmc=!#Fm2}I~Q z^;TE9F~iJrKlJ053{zX%O&eEWTgY+Df-~&)q|;TQi0CCFN9cCn50xA1AaYz4c6`q{ zQSGB-6){-N>e*qvQDrFBhJ_B53Zw`tIm{z(VS!^21%}0u2nOC7#5P6Hmx-fyHkPn# zp~P_&D-7i^j$RGyk)2qpfc(s*eromO(rFzNnM%6HLO{<&asXS zn$N!h3|T+yD2C;&zglX<+7G?TcGIM9a@;hz({0)6dq%m@JeiM4R0 zQMNhCM#+8_I<&CMus5c)e(VQMQ|gwA0V&j`D}tub zzS*Z@Hh%BZNSxY#RjJUS_GAdEcbd ztaj*5nr8+ywB)@~&&q5PNeRo8bw~I)kTw04WyWbN~PV literal 0 HcmV?d00001 diff --git a/src/main/java/me/jonasjones/arduinoctrls/ArduinoControls.java b/src/main/java/me/jonasjones/arduinoctrls/ArduinoControls.java index fdf7326..1075052 100644 --- a/src/main/java/me/jonasjones/arduinoctrls/ArduinoControls.java +++ b/src/main/java/me/jonasjones/arduinoctrls/ArduinoControls.java @@ -1,36 +1,37 @@ package me.jonasjones.arduinoctrls; +import me.jonasjones.arduinoctrls.config.ModConfigs; import me.jonasjones.arduinoctrls.debug.LedBlink; -import net.fabricmc.api.ModInitializer; +import me.jonasjones.arduinoctrls.util.VerboseLogger; +import net.fabricmc.api.ClientModInitializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ArduinoControls implements ModInitializer { +public class ArduinoControls implements ClientModInitializer { // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. - public static final Logger LOGGER = LoggerFactory.getLogger("arduinoctrls"); + + public static final String MOD_ID = "arduinoctrls"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + public static Logger VERBOSELOGGER = LoggerFactory.getLogger(MOD_ID + " - VERBOSE LOGGER"); @Override - public void onInitialize() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. + public void onInitializeClient() { + // register configs + ModConfigs.registerConfigs(); + //message from mod to confirm that it has been loaded LOGGER.info("UwU from Arduino Controls!"); - try { + + //make verbose logger show that it is active + VerboseLogger.info("Verbose Logger is now logging."); + + //blink LED on startup + /*try { LedBlink.initialisation(); } catch (InterruptedException e) { LOGGER.info("Failed to make Arduino LED blink. ARDUINO NOT CONNECTED!"); - } + }*/ } -} -/* -//TODO: -- Full control over all programmable pins of all known raspberry pi's -- system to flash program onto arduino with ingame editor -- scratch system that allows for multiple event triggering when something happens -- cry because mojang UI system sucks ass -- make own library that allows for easy UI implementation - -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigProvider.java b/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigProvider.java new file mode 100644 index 0000000..a97bd22 --- /dev/null +++ b/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigProvider.java @@ -0,0 +1,30 @@ +package me.jonasjones.arduinoctrls.config; + +import com.mojang.datafixers.util.Pair; + +import me.jonasjones.arduinoctrls.config.SimpleConfig.DefaultConfig; + +import java.util.ArrayList; +import java.util.List; + +public class ModConfigProvider implements DefaultConfig { + + private String configContents = ""; + + public List getConfigsList() { + return configsList; + } + + private final List configsList = new ArrayList<>(); + + public void addKeyValuePair(Pair keyValuePair, String comment) { + configsList.add(keyValuePair); + configContents += keyValuePair.getFirst() + "=" + keyValuePair.getSecond() + " #" + + comment + " | default: " + keyValuePair.getSecond() + "\n"; + } + + @Override + public String get(String namespace) { + return configContents; + } +} diff --git a/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigs.java b/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigs.java new file mode 100644 index 0000000..8157803 --- /dev/null +++ b/src/main/java/me/jonasjones/arduinoctrls/config/ModConfigs.java @@ -0,0 +1,110 @@ +package me.jonasjones.arduinoctrls.config; + +import com.mojang.datafixers.util.Pair; + +import me.jonasjones.arduinoctrls.ArduinoControls; + +public class ModConfigs { + public static SimpleConfig CONFIGMAIN; + public static SimpleConfig CONFIGLISTS; + private static ModConfigProvider configMain; + private static ModConfigProvider configLists; + + //configMain + public static Boolean ISENABLED; + public static String DEFAULTBOARDFALLBACK; + public static int LOOPINTERVAL; + public static Boolean BOARDMELTING; + public static Boolean VERBOSE = false; //needs to be set to false since the verbose logger is called before config file is fully loaded + public static String EDITOR; + + //configList + public static Boolean DISPLAYENTRYALL; + public static Boolean DISPLAYENTRYPLAYERJUMP; + public static Boolean DISPLAYENTRYPLAYERSPRINT; + public static Boolean DISPLAYENTRYPLAYERWALKFORWARDS; + public static Boolean DISPLAYENTRYPLAYERWALKBACKWARDS; + public static Boolean DISPLAYENTRYPLAYERWALKRIGHT; + public static Boolean DISPLAYENTRYPLAYERWALKLEFT; + public static Boolean DISPLAYENTRYPLAYERSNEAK; + public static Boolean DISPLAYENTRYISALL; + public static Boolean DISPLAYENTRYISPLAYERJUMP; + public static Boolean DISPLAYENTRYISPLAYERSPRINT; + public static Boolean DISPLAYENTRYISPLAYERWALKFORWARDS; + public static Boolean DISPLAYENTRYISPLAYERWALKBACKWARDS; + public static Boolean DISPLAYENTRYISPLAYERWALKRIGHT; + public static Boolean DISPLAYENTRYISPLAYERWALKLEFT; + public static Boolean DISPLAYENTRYISPLAYERSNEAK; + + + public static void registerConfigs() { + configMain = new ModConfigProvider(); + configLists = new ModConfigProvider(); + + createConfigs(); + + CONFIGMAIN = SimpleConfig.of(ArduinoControls.MOD_ID + "-main").provider(configMain).request(); + CONFIGLISTS = SimpleConfig.of(ArduinoControls.MOD_ID + "-lists").provider(configLists).request(); + + assignConfigs(); + } + + private static void createConfigs() { + //configMain + configMain.addKeyValuePair(new Pair<>("basic.isEnabled", true), "whether or not the mod is enabled"); + configMain.addKeyValuePair(new Pair<>("basic.defaultBoardFallback", "A-nano"), "The board to automatically be selected if failed to detect automatically. All valid ID's can be found at: https://github.com/J-onasJones/MicrocontrollerMC/wiki/Microcontroller-Boards#supported-boards"); + configMain.addKeyValuePair(new Pair<>("advanced.loopInterval", 50), "The Delay in ms between each check."); + configMain.addKeyValuePair(new Pair<>("fun.boardMelting", false), "Whether or not the board should have a flame overlay instead of being greyed out when not connected."); + configMain.addKeyValuePair(new Pair<>("debug.verbose", false), "Toggle verbose console output."); + configMain.addKeyValuePair(new Pair<>("editor.default", "ingame"), "The default editor for the board program. All valid default Editors can be found at: https://github.com/J-onasJones/MicrocontrollerMC/wiki/Board-Program-Editors#available-editors"); + + //configLists + configLists.addKeyValuePair(new Pair<>("displayEntry.all", false), "Whether or not to display all entries. This overrides all other states except for debug and experimental entries. More infos can be found at: https://github.com/J-onasJones/MicrocontrollerMC/wiki/Pin-Map-Entries#list-of-all-entries"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerJump", true), "Display Player Jump Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerSprint", true), "Display Player Sprint Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerWalkForwards", true), "Display Player Walk Forwards Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerWalkBackwards", true), "Display Player Walk Backwards Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerWalkRight", true), "Display Player Walk Right Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerWalkLeft", true), "Display Player Walk Left Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntry.playerSneak", true), "Display Player Sneak Entry"); + + configLists.addKeyValuePair(new Pair<>("displayEntryIs.all", false), "Whether or not to display all 'Is' entries. This overrides all other states except for debug and experimental entries. More infos can be found at: https://github.com/J-onasJones/MicrocontrollerMC/wiki/Pin-Map-Entries#list-of-all-entries"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerJump", true), "Display Is Player Jumping Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerSprint", true), "Display Is Player Sprinting Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerWalkForwards", true), "Display Is Player Walking Forwards Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerWalkBackwards", true), "Display Is Player Walking Backwards Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerWalkRight", true), "Display Is Player Walking Right Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerWalkLeft", true), "Display Is Player Walking Left Entry"); + configLists.addKeyValuePair(new Pair<>("displayEntryIs.playerSneak", true), "Display Is Player Sneaking Entry"); + + } + + private static void assignConfigs() { + ISENABLED = CONFIGMAIN.getOrDefault("basic.isEnabled", true); + DEFAULTBOARDFALLBACK = CONFIGMAIN.getOrDefault("basic.defaultBoardFallback", "A-nano"); + LOOPINTERVAL = CONFIGMAIN.getOrDefault("advanced.loopInterval", 50); + BOARDMELTING = CONFIGMAIN.getOrDefault("fun.boardMelting", false); + VERBOSE = CONFIGMAIN.getOrDefault("debug.verbose", false); + EDITOR = CONFIGMAIN.getOrDefault("editor.default", "ingame"); + + DISPLAYENTRYALL = CONFIGLISTS.getOrDefault("displayEntry.all", false); + DISPLAYENTRYPLAYERJUMP = CONFIGLISTS.getOrDefault("displayEntry.playerJump", true); + DISPLAYENTRYPLAYERSPRINT = CONFIGLISTS.getOrDefault("displayEntry.playerSprint", true); + DISPLAYENTRYPLAYERWALKFORWARDS = CONFIGLISTS.getOrDefault("displayEntry.playerWalkForwards", true); + DISPLAYENTRYPLAYERWALKBACKWARDS = CONFIGLISTS.getOrDefault("displayEntry.playerWalkBackwards", true); + DISPLAYENTRYPLAYERWALKRIGHT = CONFIGLISTS.getOrDefault("displayEntry.playerWalkRight", true); + DISPLAYENTRYPLAYERWALKLEFT = CONFIGLISTS.getOrDefault("displayEntry.playerWalkRight", true); + DISPLAYENTRYPLAYERSNEAK = CONFIGLISTS.getOrDefault("displayEntry.playerSneak", true); + + DISPLAYENTRYISALL = CONFIGLISTS.getOrDefault("displayEntryIs.all", false); + DISPLAYENTRYISPLAYERJUMP = CONFIGLISTS.getOrDefault("displayEntryIs.playerJump", true); + DISPLAYENTRYISPLAYERSPRINT = CONFIGLISTS.getOrDefault("displayEntryIs.playerSprint", true); + DISPLAYENTRYISPLAYERWALKFORWARDS = CONFIGLISTS.getOrDefault("displayEntryIs.playerWalkForwards", true); + DISPLAYENTRYISPLAYERWALKBACKWARDS = CONFIGLISTS.getOrDefault("displayEntryIs.playerWalkBackwards", true); + DISPLAYENTRYISPLAYERWALKRIGHT = CONFIGLISTS.getOrDefault("displayEntryIs.playerWalkRight", true); + DISPLAYENTRYISPLAYERWALKLEFT = CONFIGLISTS.getOrDefault("displayEntryIs.playerWalkLeft", true); + DISPLAYENTRYISPLAYERSNEAK = CONFIGLISTS.getOrDefault("displayEntryIs.playerSneak", true); + + System.out.println("All " + configMain.getConfigsList().size() + " have been set properly"); + } +} diff --git a/src/main/java/me/jonasjones/arduinoctrls/config/SimpleConfig.java b/src/main/java/me/jonasjones/arduinoctrls/config/SimpleConfig.java new file mode 100644 index 0000000..d41e360 --- /dev/null +++ b/src/main/java/me/jonasjones/arduinoctrls/config/SimpleConfig.java @@ -0,0 +1,250 @@ +package me.jonasjones.arduinoctrls.config; +/* + * Copyright (c) 2021 magistermaks + * Slightly modified by Jonas_Jones 2022 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import me.jonasjones.arduinoctrls.util.VerboseLogger; +import net.fabricmc.loader.api.FabricLoader; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Scanner; + +public class SimpleConfig { + private final HashMap config = new HashMap<>(); + private final ConfigRequest request; + private boolean broken = false; + + public interface DefaultConfig { + String get( String namespace ); + + static String empty( String namespace ) { + return ""; + } + } + + public static class ConfigRequest { + + private final File file; + private final String filename; + private DefaultConfig provider; + + private ConfigRequest(File file, String filename ) { + this.file = file; + this.filename = filename; + this.provider = DefaultConfig::empty; + } + + /** + * Sets the default config provider, used to generate the + * config if it's missing. + * + * @param provider default config provider + * @return current config request object + * @see DefaultConfig + */ + public ConfigRequest provider( DefaultConfig provider ) { + this.provider = provider; + return this; + } + + /** + * Loads the config from the filesystem. + * + * @return config object + * @see SimpleConfig + */ + public SimpleConfig request() { + return new SimpleConfig( this ); + } + + private String getConfig() { + return provider.get( filename ) + "\n"; + } + + } + + /** + * Creates new config request object, ideally `namespace` + * should be the name of the mod id of the requesting mod + * + * @param filename - name of the config file + * @return new config request object + */ + public static ConfigRequest of( String filename ) { + Path path = FabricLoader.getInstance().getConfigDir(); + return new ConfigRequest( path.resolve( filename + ".properties" ).toFile(), filename ); + } + + private void createConfig() throws IOException { + + // try creating missing files + request.file.getParentFile().mkdirs(); + Files.createFile( request.file.toPath() ); + + // write default config data + PrintWriter writer = new PrintWriter(request.file, "UTF-8"); + writer.write( request.getConfig() ); + writer.close(); + + } + + private void loadConfig() throws IOException { + Scanner reader = new Scanner( request.file ); + for( int line = 1; reader.hasNextLine(); line ++ ) { + parseConfigEntry( reader.nextLine(), line ); + } + } + + private void parseConfigEntry( String entry, int line ) { + if( !entry.isEmpty() && !entry.startsWith( "#" ) ) { + String[] parts = entry.split("=", 2); + if( parts.length == 2 ) { + //Recognise comments after a value + String temp = parts[1].split(" #")[0]; + config.put( parts[0], temp); + }else{ + throw new RuntimeException("Syntax error in config file on line " + line + "!"); + } + } + } + + private SimpleConfig( ConfigRequest request ) { + this.request = request; + String identifier = "Config '" + request.filename + "'"; + + if( !request.file.exists() ) { + VerboseLogger.info( identifier + " is missing, generating default one..." ); + + try { + createConfig(); + } catch (IOException e) { + VerboseLogger.error( identifier + " failed to generate!" ); + VerboseLogger.trace(String.valueOf(e)); + broken = true; + } + } + + if( !broken ) { + try { + loadConfig(); + } catch (Exception e) { + VerboseLogger.error( identifier + " failed to load!" ); + VerboseLogger.trace(String.valueOf(e)); + broken = true; + } + } + + } + + /** + * Queries a value from config, returns `null` if the + * key does not exist. + * + * @return value corresponding to the given key + * @see SimpleConfig#getOrDefault + */ + @Deprecated + public String get( String key ) { + return config.get( key ); + } + + /** + * Returns string value from config corresponding to the given + * key, or the default string if the key is missing. + * + * @return value corresponding to the given key, or the default value + */ + public String getOrDefault( String key, String def ) { + String val = get(key); + return val == null ? def : val; + } + + /** + * Returns integer value from config corresponding to the given + * key, or the default integer if the key is missing or invalid. + * + * @return value corresponding to the given key, or the default value + */ + public int getOrDefault( String key, int def ) { + try { + return Integer.parseInt( get(key) ); + } catch (Exception e) { + return def; + } + } + + /** + * Returns boolean value from config corresponding to the given + * key, or the default boolean if the key is missing. + * + * @return value corresponding to the given key, or the default value + */ + public boolean getOrDefault( String key, boolean def ) { + String val = get(key); + if( val != null ) { + return val.equalsIgnoreCase("true"); + } + + return def; + } + + /** + * Returns double value from config corresponding to the given + * key, or the default string if the key is missing or invalid. + * + * @return value corresponding to the given key, or the default value + */ + public double getOrDefault( String key, double def ) { + try { + return Double.parseDouble( get(key) ); + } catch (Exception e) { + return def; + } + } + + /** + * If any error occurred during loading or reading from the config + * a 'broken' flag is set, indicating that the config's state + * is undefined and should be discarded using `delete()` + * + * @return the 'broken' flag of the configuration + */ + public boolean isBroken() { + return broken; + } + + /** + * deletes the config file from the filesystem + * + * @return true if the operation was successful + */ + public boolean delete() { + VerboseLogger.warn( "Config '" + request.filename + "' was removed from existence! Restart the game to regenerate it." ); + return request.file.delete(); + } + +} diff --git a/src/main/java/me/jonasjones/arduinoctrls/gui/GuiHome.java b/src/main/java/me/jonasjones/arduinoctrls/gui/GuiHome.java index 3c31079..20a14a4 100644 --- a/src/main/java/me/jonasjones/arduinoctrls/gui/GuiHome.java +++ b/src/main/java/me/jonasjones/arduinoctrls/gui/GuiHome.java @@ -23,7 +23,7 @@ public class GuiHome extends Screen { this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height / 6 + 12, 150, 20, Text.of("Configure Microcontrollers"), (button) -> { this.client.setScreen(new SelectDevice(this)); })); - this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Settings"), (button) -> { + this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Configure MicrocontrollerMC"), (button) -> { this.client.setScreen(new ModSettings(this)); })); diff --git a/src/main/java/me/jonasjones/arduinoctrls/util/VerboseLogger.java b/src/main/java/me/jonasjones/arduinoctrls/util/VerboseLogger.java new file mode 100644 index 0000000..ed7624a --- /dev/null +++ b/src/main/java/me/jonasjones/arduinoctrls/util/VerboseLogger.java @@ -0,0 +1,33 @@ +package me.jonasjones.arduinoctrls.util; + +import jdk.jfr.StackTrace; +import me.jonasjones.arduinoctrls.ArduinoControls; +import me.jonasjones.arduinoctrls.config.ModConfigs; + +public class VerboseLogger { + public static void info(String message) { + if (ModConfigs.VERBOSE) { + ArduinoControls.VERBOSELOGGER.info(message); + } + } + public void debug(String message) { + if (ModConfigs.VERBOSE) { + ArduinoControls.VERBOSELOGGER.debug(message); + } + } + public static void error(String message) { + if (ModConfigs.VERBOSE) { + ArduinoControls.VERBOSELOGGER.error(message); + } + } + public static void trace( String message) { + if (ModConfigs.VERBOSE) { + ArduinoControls.VERBOSELOGGER.trace(message); + } + } + public static void warn( String message) { + if (ModConfigs.VERBOSE) { + ArduinoControls.VERBOSELOGGER.warn(message); + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 194012f..a608661 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -3,14 +3,15 @@ "id": "arduinoctrls", "version": "v0.0.1alpha01", - "name": "Minecraft Arduino Controls", - "description": "A mod that allows for communication between the Minecraft client and an Arduino.", + "name": "MicrocontrollerMC", + "description": "A mod that allows for communication between the Minecraft client and multiple microcontrollers, allowing for ingame triggers of actions.", "authors": [ "Jonas_Jones" ], "contact": { - "homepage": "https://jonasjones.me/MinecraftArduinoControls", - "sources": "https://github.com/J-onasJones/MinecraftArduinoControls" + "homepage": "https://jonasjones.me/MicrocontrollerMC", + "sources": "https://github.com/J-onasJones/MicrocontrollerMC", + "issues": "https://github.com/J-onasJones/MicrocontrollerMC/issues" }, "license": "CC0-1.0", @@ -18,7 +19,7 @@ "environment": "client", "entrypoints": { - "main": [ + "client": [ "me.jonasjones.arduinoctrls.ArduinoControls" ] }, @@ -34,5 +35,12 @@ }, "suggests": { "another-mod": "*" + }, + "custom": { + "modmenu": { + "links": { + "modmenu.discord": "https://discord.com/invite/V2EsuUVmWh" + } + } } }