diff --git a/.gitignore b/.gitignore index 09cd281..fa1a19b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,120 @@ -# gradle +# User-specific stuff +.idea/ -.gradle/ -build/ +*.iml +*.ipr +*.iws + +# IntelliJ out/ -classes/ +# mpeltonen/sbt-idea plugin +.idea_modules/ -# eclipse +# JIRA plugin +atlassian-ide-plugin.xml -*.launch +# Compiled class file +*.class -# idea +# Log file +*.log -.idea/ -*.iml -*.ipr -*.iws +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory -# vscode +# Linux trash folder which might appear on any partition or disk +.Trash-* -.settings/ -.vscode/ -bin/ -.classpath -.project +# .nfs files are created when an open file is removed but is still being accessed +.nfs* -# macos +# General +.DS_Store +.AppleDouble +.LSOverride -*.DS_Store +# Icon must end with two \r +Icon -# fabric +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ + +# Common working directory run/ +fabric/run/ +forge/run/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/README.md b/README.md index b5a7890..fdb37f9 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ Now I am trying to continue developing it. ### Special thanks - LlamaLad7 from the Fabric Discord server: Thanks for helping CyborgCabbage with some mixin stuff! - - CyborgCabbage: Huge shoutout to you for creating this awesome mod in the first place! - - All the contributors: A big thank you to everyone who has contributed to the development of this mod! You rock! + - [CyborgCabbage](https://github.com/CyborgCabbage/): Huge shoutout to you for creating this awesome mod in the first place! + - [Juzz](https://github.com/Juuxel) from the Architectury Discord server: Thanks for helping with architectury! + - [All the contributors](https://github.com/Norbiros/emojitype/graphs/contributors): A big thank you to everyone who has contributed to the development of this mod! You rock! ### Links - [Mod on CurseForge](https://legacy.curseforge.com/minecraft/mc-mods/emoji-type) diff --git a/build.gradle b/build.gradle index 14eb721..049843b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,96 +1,51 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' - id 'maven-publish' + id "architectury-plugin" version "3.4-SNAPSHOT" + id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group - -repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. - maven { url "https://maven.shedaniel.me/" } - maven { url "https://maven.terraformersmc.com/"} +architectury { + minecraft = rootProject.minecraft_version } -dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. - // You may need to force-disable transitiveness on them. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { - exclude(group: "net.fabricmc.fabric-api") - } - modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" -} +subprojects { + apply plugin: "dev.architectury.loom" -processResources { - inputs.property "version", project.version + loom { + silentMojangMappingsLicense() + } - filesMatching("fabric.mod.json") { - expand "version": project.version - } + dependencies { + minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" + // The following line declares the yarn mappings you may select this one as well. + mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2" + } } -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" +allprojects { + apply plugin: "java" + apply plugin: "architectury-plugin" + apply plugin: "maven-publish" - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } -} - -java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} + archivesBaseName = rootProject.archives_base_name + version = rootProject.mod_version + group = rootProject.maven_group -jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } -} + repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/"} + } -// configure the maven publication -publishing { - publications { - mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } - } - } + tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.release = 17 + } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } + java { + withSourcesJar() + } } diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..4585381 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,24 @@ +architectury { + common(project.enabled_platforms.split(",")) +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "me.shedaniel.cloth:cloth-config:${project.cloth_config_version}" +} + +publishing { + publications { + mavenCommon(MavenPublication) { + artifactId = rootProject.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/ConfigDirPlatform.java b/common/src/main/java/dev/norbiros/emojitype/ConfigDirPlatform.java new file mode 100644 index 0000000..3af5eb9 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/ConfigDirPlatform.java @@ -0,0 +1,14 @@ +package dev.norbiros.emojitype; + +import dev.architectury.injectables.annotations.ExpectPlatform; + +import java.nio.file.Path; + +public class ConfigDirPlatform { + + @ExpectPlatform + public static Path getConfigDirectory() { + // Just throw an error, the content should get replaced at runtime. + throw new AssertionError(); + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/EmojiType.java b/common/src/main/java/dev/norbiros/emojitype/EmojiType.java new file mode 100644 index 0000000..a28803e --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/EmojiType.java @@ -0,0 +1,270 @@ +package dev.norbiros.emojitype; + +import dev.norbiros.emojitype.emoji.EmojiCode; +import dev.norbiros.emojitype.config.ConfigUtil; + +import java.util.ArrayList; +import java.util.List; + +public class EmojiType { + public static final String MOD_ID = "emojitype"; + + public static final ArrayList DEFAULT_EMOJI_CODES = new ArrayList() { + { + add(new EmojiCode(":bucket:", "\uD83E\uDEA3")); + add(new EmojiCode(":shears:", "✂")); + add(new EmojiCode(":whiteflag:", "⚑")); + add(new EmojiCode(":bell:", "\uD83D\uDD14")); + add(new EmojiCode(":hunger:", "\uD83C\uDF56")); + add(new EmojiCode(":hourglass2:", "⏳")); + + //Face + add(new EmojiCode(":happy1:", "☺")); + add(new EmojiCode(":happy2:", "☻")); + add(new EmojiCode(":sad:", "☹")); + add(new EmojiCode(":skull:", "☠")); + //Tool + add(new EmojiCode(":pickaxe:", "⛏")); + add(new EmojiCode(":axe:", "\uD83E\uDE93")); + add(new EmojiCode(":fishing:", "\uD83C\uDFA3")); + add(new EmojiCode(":umbrella:", "☂")); + //Combat + add(new EmojiCode(":trident:", "\uD83D\uDD31")); + add(new EmojiCode(":sword:", "\uD83D\uDDE1")); + add(new EmojiCode(":shield:", "\uD83D\uDEE1")); + add(new EmojiCode(":duel:", "⚔")); + add(new EmojiCode(":bow:", "\uD83C\uDFF9")); + //Potion + add(new EmojiCode(":potion:", "\uD83E\uDDEA")); + add(new EmojiCode(":splash:", "⚗")); + //Mark + add(new EmojiCode(":copyright:", "©")); + add(new EmojiCode(":registered:", "®")); + add(new EmojiCode(":protected:", "℗")); + add(new EmojiCode(":trademark:", "™")); + //Water + add(new EmojiCode(":anchor:", "⚓")); + add(new EmojiCode(":wave:", "\uD83C\uDF0A")); + add(new EmojiCode(":trademark:", "™")); + //Sex + add(new EmojiCode(":male:", "♂")); + add(new EmojiCode(":female:", "♀")); + add(new EmojiCode(":intersex:", "⚥")); + //Direction + add(new EmojiCode(":left:", "⏴")); + add(new EmojiCode(":right:", "⏵")); + add(new EmojiCode(":up:", "⏶")); + add(new EmojiCode(":down:", "⏷")); + add(new EmojiCode(":handleft:", "☜")); + add(new EmojiCode(":handright:", "☞")); + add(new EmojiCode(":swap:", "⇄")); + //Culture + add(new EmojiCode(":yingyang:", "☯")); + add(new EmojiCode(":peace:", "☮")); + //Weather + add(new EmojiCode(":sun:", "☀")); + add(new EmojiCode(":cloud:", "☁")); + add(new EmojiCode(":comet:", "☄")); + add(new EmojiCode(":moon:", "☽")); + add(new EmojiCode(":snowman:", "⛄")); + add(new EmojiCode(":storm:", "⛈")); + add(new EmojiCode(":snow:", "❄")); + //Control + add(new EmojiCode(":eject:", "⏏")); + add(new EmojiCode(":fastforward:", "⏩")); + add(new EmojiCode(":fastbackward:", "⏪")); + add(new EmojiCode(":toend:", "⏭")); + add(new EmojiCode(":tostart:", "⏮")); + add(new EmojiCode(":playpause:", "⏯")); + add(new EmojiCode(":pause:", "⏸")); + add(new EmojiCode(":poweron:", "⏻")); + add(new EmojiCode(":poweroff:", "⏼")); + //Flag + add(new EmojiCode(":blackflag:", "⚐")); + //Boolean + add(new EmojiCode(":box:", "☐")); + add(new EmojiCode(":boxyes:", "☑")); + add(new EmojiCode(":boxno:", "☒")); + add(new EmojiCode(":yes:", "✔")); + add(new EmojiCode(":no:", "✘")); + //Shape + add(new EmojiCode(":square1:", "⏹")); + add(new EmojiCode(":square2:", "□")); + add(new EmojiCode(":circle1:", "⏺")); + add(new EmojiCode(":circle2:", "○")); + add(new EmojiCode(":cross:", "❌")); + add(new EmojiCode(":heart1:", "❤")); + add(new EmojiCode(":heart2:", "❣")); + add(new EmojiCode(":triangle1:", "▲")); + add(new EmojiCode(":triangle2:", "△")); + add(new EmojiCode(":diamond1:", "◆")); + add(new EmojiCode(":diamond2:", "◇")); + add(new EmojiCode(":loopedsquare:", "⌘")); + add(new EmojiCode(":target:", "◎")); + add(new EmojiCode(":star1:", "★")); + add(new EmojiCode(":star2:", "☆")); + add(new EmojiCode(":star3:", "⭐")); + + //Misc + add(new EmojiCode(":fire:", "\uD83D\uDD25")); + add(new EmojiCode(":unknown:", "�")); + add(new EmojiCode(":house:", "⌂")); + add(new EmojiCode(":clock:", "⌚")); + add(new EmojiCode(":warning:", "⚠")); + add(new EmojiCode(":electric:", "⚡")); + add(new EmojiCode(":mail:", "✉")); + add(new EmojiCode(":pencil:", "✎")); + add(new EmojiCode(":degree:", "°")); + add(new EmojiCode(":hourglass:", "⌛")); + + //Cards + add(new EmojiCode(":suitspade1:", "♠")); + add(new EmojiCode(":suitspade2:", "♤")); + add(new EmojiCode(":suitheart1:", "♥")); + add(new EmojiCode(":suitheart2:", "♡")); + add(new EmojiCode(":suitclub1:", "♣")); + add(new EmojiCode(":suitclub2:", "♧")); + add(new EmojiCode(":suitdiamond1:", "♦")); + add(new EmojiCode(":suitdiamond2:", "♢")); + //Music + add(new EmojiCode(":note1:", "♩")); + add(new EmojiCode(":note2:", "♪")); + add(new EmojiCode(":note3:", "♫")); + add(new EmojiCode(":note4:", "♬")); + add(new EmojiCode(":flat:", "♭")); + add(new EmojiCode(":sharp:", "♮")); + //Dice + add(new EmojiCode(":dice1:", "⚀")); + add(new EmojiCode(":dice2:", "⚁")); + add(new EmojiCode(":dice3:", "⚂")); + add(new EmojiCode(":dice4:", "⚃")); + add(new EmojiCode(":dice5:", "⚄")); + add(new EmojiCode(":dice6:", "⚅")); + //Additional symbols + //Shading + add(new EmojiCode(":z0:", "▀")); + add(new EmojiCode(":z1:", "▄")); + add(new EmojiCode(":z2:", "█")); + add(new EmojiCode(":z3:", "▌")); + add(new EmojiCode(":z4:", "▐")); + add(new EmojiCode(":z5:", "░")); + add(new EmojiCode(":z6:", "▒")); + add(new EmojiCode(":z7:", "▓")); + //Lowercase Letters + add(new EmojiCode(":za:", "ⓐ")); + add(new EmojiCode(":zb:", "ⓑ")); + add(new EmojiCode(":zc:", "ⓒ")); + add(new EmojiCode(":zd:", "ⓓ")); + add(new EmojiCode(":ze:", "ⓔ")); + add(new EmojiCode(":zf:", "ⓕ")); + add(new EmojiCode(":zg:", "ⓖ")); + add(new EmojiCode(":zh:", "ⓗ")); + add(new EmojiCode(":zi:", "ⓘ")); + add(new EmojiCode(":zj:", "ⓙ")); + add(new EmojiCode(":zk:", "ⓚ")); + add(new EmojiCode(":zl:", "ⓛ")); + add(new EmojiCode(":zm:", "ⓜ")); + add(new EmojiCode(":zn:", "ⓝ")); + add(new EmojiCode(":zo:", "ⓞ")); + add(new EmojiCode(":zp:", "ⓟ")); + add(new EmojiCode(":zq:", "ⓠ")); + add(new EmojiCode(":zr:", "ⓡ")); + add(new EmojiCode(":zs:", "ⓢ")); + add(new EmojiCode(":zt:", "ⓣ")); + add(new EmojiCode(":zu:", "ⓤ")); + add(new EmojiCode(":zv:", "ⓥ")); + add(new EmojiCode(":zw:", "ⓦ")); + add(new EmojiCode(":zx:", "ⓧ")); + add(new EmojiCode(":zy:", "ⓨ")); + add(new EmojiCode(":zz:", "ⓩ")); + //Uppercase Letters + add(new EmojiCode(":za_:", "Ⓐ")); + add(new EmojiCode(":zb_:", "Ⓑ")); + add(new EmojiCode(":zc_:", "Ⓒ")); + add(new EmojiCode(":zd_:", "Ⓓ")); + add(new EmojiCode(":ze_:", "Ⓔ")); + add(new EmojiCode(":zf_:", "Ⓕ")); + add(new EmojiCode(":zg_:", "Ⓖ")); + add(new EmojiCode(":zh_:", "Ⓗ")); + add(new EmojiCode(":zi_:", "Ⓘ")); + add(new EmojiCode(":zj_:", "Ⓙ")); + add(new EmojiCode(":zk_:", "Ⓚ")); + add(new EmojiCode(":zl_:", "Ⓛ")); + add(new EmojiCode(":zm_:", "Ⓜ")); + add(new EmojiCode(":zn_:", "Ⓝ")); + add(new EmojiCode(":zo_:", "Ⓞ")); + add(new EmojiCode(":zp_:", "Ⓟ")); + add(new EmojiCode(":zq_:", "Ⓠ")); + add(new EmojiCode(":zr_:", "Ⓡ")); + add(new EmojiCode(":zs_:", "Ⓢ")); + add(new EmojiCode(":zt_:", "Ⓣ")); + add(new EmojiCode(":zu_:", "Ⓤ")); + add(new EmojiCode(":zv_:", "Ⓥ")); + add(new EmojiCode(":zw_:", "Ⓦ")); + add(new EmojiCode(":zx_:", "Ⓧ")); + add(new EmojiCode(":zy_:", "Ⓨ")); + add(new EmojiCode(":zz_:", "Ⓩ")); + //Face + add(new EmojiCode(":face1:", "(°_°)")); + add(new EmojiCode(":face2:", "(ㆆ_ㆆ)")); + add(new EmojiCode(":face3:", "(O_O)")); + add(new EmojiCode(":face4:", "(ಠ_ಠ)")); + add(new EmojiCode(":face5:", "(。◕‿‿◕。)")); + add(new EmojiCode(":face6:", "(-‿-)")); + add(new EmojiCode(":face7:", "(◠‿◠)")); + add(new EmojiCode(":face8:", "(✿◠‿◠)")); + add(new EmojiCode(":face9:", "(°o•)")); + //Animals + add(new EmojiCode(":bear1:", "ʕ·ᴥ·ʔ")); + add(new EmojiCode(":bear2:", "ʕっ·ᴥ·ʔっ")); + add(new EmojiCode(":bear3:", "ʕ♥ᴥ♥ʔ")); + add(new EmojiCode(":bird:", "(°v°)")); + add(new EmojiCode(":cat:", "(°ᴥ°)")); + add(new EmojiCode(":dog:", "(◕ᴥ◕ʋ)")); + //Action + add(new EmojiCode(":cheer1:", "※\\(^o^)/※")); + add(new EmojiCode(":cheer2:", "*(^_^)*")); + add(new EmojiCode(":cool1:", "(⌐■_■)")); + add(new EmojiCode(":cool2:", "(•_•) ( •_•)>⌐■-■ (⌐■_■)")); + add(new EmojiCode(":creep:", "ԅ(≖‿≖ԅ)")); + add(new EmojiCode(":cry:", "(╥﹏╥)")); + add(new EmojiCode(":dance1:", "ᕕ(⌐■_■)ᕗ")); + add(new EmojiCode(":dance2:", "ᕕ( ᐛ ) ᕗ")); + add(new EmojiCode(":table1:", "(╯°□°)╯︵ ┻━┻")); + add(new EmojiCode(":table2:", "(╯°□°)╯︵ ʇɟɐɹɔǝuᴉɯ")); + add(new EmojiCode(":table3:", "(╯°□°)╯︵ ƃuɐɾoɯ")); + add(new EmojiCode(":table4:", "┳━┳ノ(°_°ノ)")); + add(new EmojiCode(":shrug1:", "¯\\_(ツ)_/¯")); + add(new EmojiCode(":shrug2:", "¯\\(°_o)/¯")); + add(new EmojiCode(":gimme:", "༼ つ◕_◕༽つ")); + add(new EmojiCode(":lol:", "L(°O°L)")); + add(new EmojiCode(":zoidberg:", "(V)(°,,,°)(V)")); + add(new EmojiCode(":fly:", "─=≡Σ((つ•ω•)つ")); + } + }; + + public static ArrayList allCodes = new ArrayList<>(); + public static ArrayList allEmoji = new ArrayList<>(); + public static ArrayList emojiCodesCombined = new ArrayList<>(); + public static ArrayList emojiCodes = new ArrayList<>(); + + public static void update(List emojiCodeStrings) { + emojiCodes.clear(); + allCodes.clear(); + allEmoji.clear(); + emojiCodesCombined.clear(); + for (String str : emojiCodeStrings) { + EmojiCode.fromString(str).ifPresent(emojiCodes::add); + } + for (EmojiCode ec : emojiCodes) { + allCodes.add(ec.getCode()); + allEmoji.add(ec.getEmoji()); + emojiCodesCombined.add(ec.getCode() + " " + ec.getEmoji()); + } + } + + public static void init() { + System.out.println("EmojiType initialized!"); + ConfigUtil.deserialise(); + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/config/ConfigUtil.java b/common/src/main/java/dev/norbiros/emojitype/config/ConfigUtil.java new file mode 100644 index 0000000..f65822a --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/config/ConfigUtil.java @@ -0,0 +1,54 @@ +package dev.norbiros.emojitype.config; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import dev.norbiros.emojitype.ConfigDirPlatform; +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.emoji.EmojiCode; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +public class ConfigUtil { + public static Path CONFIG_PATH = ConfigDirPlatform.getConfigDirectory().resolve(EmojiType.MOD_ID + ".json"); + public static List emojiCodeStrings = new ArrayList<>(); + + public static void serialise() { + try { + Files.createDirectories(CONFIG_PATH.getParent()); + BufferedWriter writer = Files.newBufferedWriter(CONFIG_PATH); + writer.write(new GsonBuilder().setPrettyPrinting().create().toJson(emojiCodeStrings)); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + EmojiType.update(emojiCodeStrings); + } + + public static void deserialise() { + if (Files.exists(CONFIG_PATH)) { + try { + BufferedReader reader = Files.newBufferedReader(CONFIG_PATH); + emojiCodeStrings = new Gson().fromJson(reader, new TypeToken>() { + }.getType()); + reader.close(); + } catch (IOException e) { + e.printStackTrace(); //dirty consume + } + EmojiType.update(emojiCodeStrings); + } else { + // From defaults + emojiCodeStrings.clear(); + for (EmojiCode ec : EmojiType.DEFAULT_EMOJI_CODES) { + emojiCodeStrings.add(ec.toString()); + } + serialise(); + } + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/config/EmojiTypeConfig.java b/common/src/main/java/dev/norbiros/emojitype/config/EmojiTypeConfig.java new file mode 100644 index 0000000..669a276 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/config/EmojiTypeConfig.java @@ -0,0 +1,36 @@ +package dev.norbiros.emojitype.config; + +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.emoji.EmojiCode; +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.Text; + +import java.util.ArrayList; +import java.util.List; + + public class EmojiTypeConfig { + public static Screen createConfigScreen(Screen parent) { + ConfigUtil.deserialise(); + ConfigBuilder builder = ConfigBuilder.create(); + builder.setTitle(Text.translatable("config.emojitype.title")); + builder.setSavingRunnable(ConfigUtil::serialise); + ConfigEntryBuilder entryBuilder = builder.entryBuilder(); + builder.getOrCreateCategory(Text.translatable("config.emojitype.category")) + .addEntry(entryBuilder.startStrList(Text.translatable("config.emojitype.codes"), ConfigUtil.emojiCodeStrings) + .setDefaultValue(() -> { + ArrayList l = new ArrayList<>(); + for (EmojiCode ec : EmojiType.DEFAULT_EMOJI_CODES) { + l.add(ec.toString()); + } + return l; + }) + .setSaveConsumer((List lstr) -> { + ConfigUtil.emojiCodeStrings.clear(); + ConfigUtil.emojiCodeStrings.addAll(lstr); + }) + .build()); + return builder.setParentScreen(parent).build(); + } + } diff --git a/common/src/main/java/dev/norbiros/emojitype/emoji/EmojiCode.java b/common/src/main/java/dev/norbiros/emojitype/emoji/EmojiCode.java new file mode 100644 index 0000000..450cea9 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/emoji/EmojiCode.java @@ -0,0 +1,52 @@ +package dev.norbiros.emojitype.emoji; + +import java.util.Optional; + +public class EmojiCode { + public static String DELIMITER = ";"; + private final String code; + private final String emoji; + + public EmojiCode(String code, String emoji) { + this.code = code; + this.emoji = emoji; + } + + public static Optional fromString(String str) { + int index = str.indexOf(DELIMITER); + if (index != -1) { + String code = ":" + str.substring(0, index) + ":"; + String emoji = str.substring(index + DELIMITER.length()); + return Optional.of(new EmojiCode(code, emoji)); + } else { + return Optional.empty(); + } + } + + public String getCode() { + return code; + } + + public String getEmoji() { + return emoji; + } + + public boolean match(String string, int charIndex) { + for (int i = 0; i < code.length(); i++) { + int stringIndex = charIndex - i; + int codeIndex = code.length() - 1 - i; + if (stringIndex < 0 || codeIndex < 0) return false; + if (stringIndex >= string.length()) return false; + if (string.charAt(stringIndex) != code.charAt(codeIndex)) return false; + } + return true; + } + + public String toString() { + if (code.length() >= 3) { + return code.substring(1, code.length() - 1) + DELIMITER + emoji; + } else { + return code + DELIMITER + emoji; + } + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorAccessor.java b/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorAccessor.java new file mode 100644 index 0000000..8016a80 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorAccessor.java @@ -0,0 +1,13 @@ +package dev.norbiros.emojitype.mixin; + + +import net.minecraft.client.gui.screen.ChatInputSuggestor; +import net.minecraft.client.gui.widget.TextFieldWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ChatInputSuggestor.class) +public interface ChatInputSuggestorAccessor { + @Accessor + TextFieldWidget getTextField(); +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorMixin.java b/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorMixin.java new file mode 100644 index 0000000..7fb582b --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/mixin/ChatInputSuggestorMixin.java @@ -0,0 +1,82 @@ +package dev.norbiros.emojitype.mixin; + +import com.google.common.base.Strings; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import dev.norbiros.emojitype.EmojiType; +import net.minecraft.client.gui.screen.ChatInputSuggestor; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.command.CommandSource; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.concurrent.CompletableFuture; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Mixin(ChatInputSuggestor.class) +public abstract class ChatInputSuggestorMixin { + private static final Pattern COLON_PATTERN = Pattern.compile("(:)"); + private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(\\s+)"); + + @Shadow + @Final + TextFieldWidget textField; + + @Shadow + @Nullable + private CompletableFuture pendingSuggestions; + @Shadow + @Final + private boolean slashOptional; + + @Shadow + public abstract void show(boolean narrateFirstSuggestion); + + @Inject(method = "refresh", at = @At("TAIL"), cancellable = true) + private void inject(CallbackInfo ci) { + String text = this.textField.getText(); + StringReader stringReader = new StringReader(text); + boolean hasSlash = stringReader.canRead() && stringReader.peek() == '/'; + if (hasSlash) { + stringReader.skip(); + } + boolean isCommand = this.slashOptional || hasSlash; + int cursor = this.textField.getCursor(); + if (!isCommand) { + String textUptoCursor = text.substring(0, cursor); + int start = Math.max(getLastPattern(textUptoCursor, COLON_PATTERN) - 1, 0); + int whitespace = getLastPattern(textUptoCursor, WHITESPACE_PATTERN); + if (start < textUptoCursor.length() && start >= whitespace) { + if (textUptoCursor.charAt(start) == ':') { + this.pendingSuggestions = CommandSource.suggestMatching(EmojiType.emojiCodesCombined, new SuggestionsBuilder(textUptoCursor, start)); + this.pendingSuggestions.thenRun(() -> { + if (!this.pendingSuggestions.isDone()) { + return; + } + this.show(false); + }); + ci.cancel(); + } + } + } + } + + private int getLastPattern(String input, Pattern pattern) { + if (Strings.isNullOrEmpty(input)) { + return 0; + } + int i = 0; + Matcher matcher = pattern.matcher(input); + while (matcher.find()) { + i = matcher.end(); + } + return i; + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/mixin/SelectionManagerMixin.java b/common/src/main/java/dev/norbiros/emojitype/mixin/SelectionManagerMixin.java new file mode 100644 index 0000000..915f696 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/mixin/SelectionManagerMixin.java @@ -0,0 +1,42 @@ +package dev.norbiros.emojitype.mixin; + +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.emoji.EmojiCode; +import net.minecraft.client.util.SelectionManager; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.function.Supplier; + +@Mixin(SelectionManager.class) +public abstract class SelectionManagerMixin { + + @Shadow + private int selectionStart; + + @Shadow + @Final + private Supplier stringGetter; + + @Shadow + public abstract void delete(int cursorOffset); + + @Shadow + public abstract void insert(String string); + + @Inject(method = "insert(Ljava/lang/String;Ljava/lang/String;)V", at = @At("TAIL")) + private void inject(String _unused, String insertion, CallbackInfo ci) { + String text = stringGetter.get(); + for (EmojiCode ec : EmojiType.emojiCodes) { + if (ec.match(text, selectionStart - 1)) { + delete(-ec.getCode().length()); + insert(ec.getEmoji()); + break; + } + } + } +} diff --git a/common/src/main/java/dev/norbiros/emojitype/mixin/SuggestionWindowMixin.java b/common/src/main/java/dev/norbiros/emojitype/mixin/SuggestionWindowMixin.java new file mode 100644 index 0000000..ef53957 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/mixin/SuggestionWindowMixin.java @@ -0,0 +1,46 @@ +package dev.norbiros.emojitype.mixin; + +import com.mojang.brigadier.suggestion.Suggestion; +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.emoji.EmojiCode; +import net.minecraft.client.gui.screen.ChatInputSuggestor; +import net.minecraft.client.gui.widget.TextFieldWidget; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; + +@Mixin(ChatInputSuggestor.SuggestionWindow.class) +public abstract class SuggestionWindowMixin { + + @Shadow + @Final + ChatInputSuggestor field_21615; + @Shadow + private int selection; + @Shadow + @Final + private List suggestions; + + @Inject(method = "complete", at = @At("TAIL")) + private void overwriteComplete(CallbackInfo ci) { + ChatInputSuggestorAccessor inputSuggestor = (ChatInputSuggestorAccessor) this.field_21615; + if (inputSuggestor == null) return; + TextFieldWidget textFieldWidget = inputSuggestor.getTextField(); + Suggestion suggestion = this.suggestions.get(this.selection); + int just = suggestion.getRange().getStart() + suggestion.getText().length() - 2; + for (EmojiCode ec : EmojiType.emojiCodes) { + int justTyped = just - ec.getEmoji().length(); + if (ec.match(textFieldWidget.getText(), justTyped)) { + textFieldWidget.eraseCharacters(-ec.getCode().length() - (1 + ec.getEmoji().length())); + textFieldWidget.setSelectionEnd(textFieldWidget.getCursor()); + textFieldWidget.write(ec.getEmoji()); + break; + } + } + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/norbiros/emojitype/mixin/TextFieldWidgetMixin.java b/common/src/main/java/dev/norbiros/emojitype/mixin/TextFieldWidgetMixin.java new file mode 100644 index 0000000..d854d94 --- /dev/null +++ b/common/src/main/java/dev/norbiros/emojitype/mixin/TextFieldWidgetMixin.java @@ -0,0 +1,46 @@ +package dev.norbiros.emojitype.mixin; + +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.emoji.EmojiCode; +import net.minecraft.client.gui.widget.TextFieldWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(TextFieldWidget.class) +public abstract class TextFieldWidgetMixin { + @Shadow + private int selectionEnd; + @Shadow + private int selectionStart; + + @Shadow + public abstract void eraseCharacters(int characterOffset); + + @Shadow + public abstract String getText(); + + @Shadow + protected abstract int getCursorPosWithOffset(int offset); + + @Shadow + public abstract void write(String text); + + @Inject(method = "charTyped", at = @At("RETURN")) + private void inject(char chr, int modifiers, CallbackInfoReturnable cir) { + if (cir.getReturnValue()) { + int justTyped = getCursorPosWithOffset(-1); + for (EmojiCode ec : EmojiType.emojiCodes) { + if (ec.match(getText(), justTyped)) { + eraseCharacters(-ec.getCode().length()); + //When you hold shift (which you do to type ':') it messes up when eraseCharacters trys to move the cursor back, instead extending the selection + selectionEnd = selectionStart; + write(ec.getEmoji()); + break; + } + } + } + } +} diff --git a/common/src/main/resources/assets/emojitype/lang/en_us.json b/common/src/main/resources/assets/emojitype/lang/en_us.json new file mode 100644 index 0000000..211c6ec --- /dev/null +++ b/common/src/main/resources/assets/emojitype/lang/en_us.json @@ -0,0 +1,6 @@ +{ + "config.emojitype.title": "Emoji Type Config", + "config.emojitype.category": "Emoji Type Category", + "config.emojitype.codes": "Emoji Codes", + "modmenu.descriptionTranslation.emojitype": "A mod that lets you type minecraft emojis easier!" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/emojitype/lang/pl_pl.json b/common/src/main/resources/assets/emojitype/lang/pl_pl.json new file mode 100644 index 0000000..a650128 --- /dev/null +++ b/common/src/main/resources/assets/emojitype/lang/pl_pl.json @@ -0,0 +1,6 @@ +{ + "config.emojitype.title": "Konfiguracja Emoji Type", + "config.emojitype.category": "Kategoria Emoji Type", + "config.emojitype.codes": "Kody Emotikonów", + "modmenu.descriptionTranslation.emojitype": "Mod ułatwiający wpisywanie emotek w Minecraft!" +} \ No newline at end of file diff --git a/common/src/main/resources/emojitype-common.mixins.json b/common/src/main/resources/emojitype-common.mixins.json new file mode 100644 index 0000000..39154ec --- /dev/null +++ b/common/src/main/resources/emojitype-common.mixins.json @@ -0,0 +1,18 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.norbiros.emojitype.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + "ChatInputSuggestorMixin", + "ChatInputSuggestorAccessor", + "SelectionManagerMixin", + "SuggestionWindowMixin", + "TextFieldWidgetMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/common/src/main/resources/logo.png b/common/src/main/resources/logo.png new file mode 100644 index 0000000..0792942 Binary files /dev/null and b/common/src/main/resources/logo.png differ diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..165981a --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,78 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + fabric() +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + modApi "com.terraformersmc:modmenu:${project.modmenu_version}" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +shadowJar { + configurations = [project.configurations.shadowCommon] + archiveClassifier.set("dev-shadow") +} + +remapJar { + inputFile.set shadowJar.archiveFile + dependsOn shadowJar + archiveClassifier.set(null) +} + +jar { + archiveClassifier.set("dev") +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenFabric(MavenPublication) { + artifactId = rootProject.archives_base_name + "-fabric" + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} \ No newline at end of file diff --git a/fabric/src/main/java/dev/norbiros/emojitype/fabric/ConfigDirPlatformImpl.java b/fabric/src/main/java/dev/norbiros/emojitype/fabric/ConfigDirPlatformImpl.java new file mode 100644 index 0000000..0d3ddc8 --- /dev/null +++ b/fabric/src/main/java/dev/norbiros/emojitype/fabric/ConfigDirPlatformImpl.java @@ -0,0 +1,15 @@ +package dev.norbiros.emojitype.fabric; + +import dev.norbiros.emojitype.ConfigDirPlatform; +import net.fabricmc.loader.api.FabricLoader; + +import java.nio.file.Path; + +public class ConfigDirPlatformImpl { + /** + * This is our actual method to {@link ConfigDirPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return FabricLoader.getInstance().getConfigDir(); + } +} \ No newline at end of file diff --git a/fabric/src/main/java/dev/norbiros/emojitype/fabric/EmojiTypeFabric.java b/fabric/src/main/java/dev/norbiros/emojitype/fabric/EmojiTypeFabric.java new file mode 100644 index 0000000..634fc8e --- /dev/null +++ b/fabric/src/main/java/dev/norbiros/emojitype/fabric/EmojiTypeFabric.java @@ -0,0 +1,11 @@ +package dev.norbiros.emojitype.fabric; + +import dev.norbiros.emojitype.EmojiType; +import net.fabricmc.api.ModInitializer; + +public class EmojiTypeFabric implements ModInitializer { + @Override + public void onInitialize() { + EmojiType.init(); + } +} \ No newline at end of file diff --git a/fabric/src/main/java/dev/norbiros/emojitype/fabric/ModMenuIntegration.java b/fabric/src/main/java/dev/norbiros/emojitype/fabric/ModMenuIntegration.java new file mode 100644 index 0000000..703cb70 --- /dev/null +++ b/fabric/src/main/java/dev/norbiros/emojitype/fabric/ModMenuIntegration.java @@ -0,0 +1,12 @@ +package dev.norbiros.emojitype.fabric; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import dev.norbiros.emojitype.config.EmojiTypeConfig; + +public class ModMenuIntegration implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return EmojiTypeConfig::createConfigScreen; + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/emojitype.mixins.json b/fabric/src/main/resources/emojitype.mixins.json new file mode 100644 index 0000000..77daf23 --- /dev/null +++ b/fabric/src/main/resources/emojitype.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.norbiros.emojitype.mixin.fabric", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..2867261 --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,42 @@ +{ + "schemaVersion": 1, + "id": "emojitype", + "version": "${version}", + "name": "Emoji Type", + "description": "A mod that lets you type minecraft emojis easier!", + "license": "GPL-3.0", + "icon": "logo.png", + "authors": [ + "CyborgCabbage", + "Norbiros" + ], + + "contact": { + "homepage": "https://modrinth.com/mod/emoji-type", + "sources": "https://github.com/Norbiros/emojitype", + "issues": "https://github.com/Norbiros/emojitype/issues" + }, + + "environment": "*", + "entrypoints": { + "main": [ + "dev.norbiros.emojitype.fabric.EmojiTypeFabric" + ], + "modmenu": [ + "dev.norbiros.emojitype.fabric.ModMenuIntegration" + ] + }, + + "mixins": [ + "emojitype.mixins.json", + "emojitype-common.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14.21", + "minecraft": ">=1.20" + }, + "suggests": { + "cloth-config2" : "*" + } +} diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..a8427f6 --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,78 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +architectury { + platformSetupLoomIde() + forge() +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + +dependencies { + forge "net.minecraftforge:forge:${project.forge_version}" + + modApi "me.shedaniel.cloth:cloth-config-forge:${project.cloth_config_version}" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } +} + +processResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version, + "minecraft_version_range": minecraft_version_range + } +} + +shadowJar { + exclude "fabric.mod.json" + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + archiveClassifier.set("dev-shadow") +} + +remapJar { + inputFile.set shadowJar.archiveFile + dependsOn shadowJar + archiveClassifier.set(null) +} + +jar { + archiveClassifier.set("dev") +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenForge(MavenPublication) { + artifactId = rootProject.archives_base_name + "-forge" + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} \ No newline at end of file diff --git a/forge/gradle.properties b/forge/gradle.properties new file mode 100644 index 0000000..32f842a --- /dev/null +++ b/forge/gradle.properties @@ -0,0 +1 @@ +loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/dev/norbiros/emojitype/forge/ConfigDirPlatformImpl.java b/forge/src/main/java/dev/norbiros/emojitype/forge/ConfigDirPlatformImpl.java new file mode 100644 index 0000000..47daa25 --- /dev/null +++ b/forge/src/main/java/dev/norbiros/emojitype/forge/ConfigDirPlatformImpl.java @@ -0,0 +1,15 @@ +package dev.norbiros.emojitype.forge; + +import dev.norbiros.emojitype.ConfigDirPlatform; +import net.minecraftforge.fml.loading.FMLPaths; + +import java.nio.file.Path; + +public class ConfigDirPlatformImpl { + /** + * This is our actual method to {@link ConfigDirPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return FMLPaths.CONFIGDIR.get(); + } +} \ No newline at end of file diff --git a/forge/src/main/java/dev/norbiros/emojitype/forge/EmojitypeForge.java b/forge/src/main/java/dev/norbiros/emojitype/forge/EmojitypeForge.java new file mode 100644 index 0000000..a2e1c7d --- /dev/null +++ b/forge/src/main/java/dev/norbiros/emojitype/forge/EmojitypeForge.java @@ -0,0 +1,16 @@ +package dev.norbiros.emojitype.forge; + +import dev.norbiros.emojitype.EmojiType; +import dev.norbiros.emojitype.config.EmojiTypeConfig; +import net.minecraftforge.client.ConfigScreenHandler; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod; + +@Mod(EmojiType.MOD_ID) +public class EmojitypeForge { + public EmojitypeForge() { + EmojiType.init(); + + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> EmojiTypeConfig.createConfigScreen(parent))); + } +} \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..0cca8d2 --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,30 @@ +modLoader = "javafml" +loaderVersion = "[38,)" +license = "GPL-3.0" +issueTrackerURL = "https://github.com/Norbiros/emojitype/issues" +displayURL = "https://modrinth.com/mod/emoji-type" +#updateJSONURL="https://api.modrinth.com/updates/emoji-type/forge_updates.json" +logoFile = "logo.png" +authors = "Cyborgcabbage,Norbiros" + +[[mods]] +modId = "emojitype" +version = "${version}" +displayName = "Emoji Type" +description=''' +A mod that lets you type minecraft emojis easier! +''' +#credits="Thanks to cyborgcabbage for original mod!" + +[[dependencies.emojitype]] + modId="forge" + mandatory=true + versionRange="[38,)" + ordering="NONE" + side="BOTH" +[[dependencies.emojitype]] + modId="minecraft" + mandatory=true + versionRange="${minecraft_version_range}" + ordering="NONE" + side="BOTH" diff --git a/forge/src/main/resources/emojitype.mixins.json b/forge/src/main/resources/emojitype.mixins.json new file mode 100644 index 0000000..904efda --- /dev/null +++ b/forge/src/main/resources/emojitype.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.norbiros.emojitype.mixin.forge", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..5161b45 --- /dev/null +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "emojitype resources", + "pack_format": 15, + "forge:server_data_pack_format": 12 + } +} diff --git a/gradle.properties b/gradle.properties index 24d8711..786eb82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,20 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx2G -# Fabric Properties -# check these on https://fabricmc.net/develop +archives_base_name=emoji-type +mod_version=2.2.0+1.20 +maven_group=dev.norbiros minecraft_version=1.20 +minecraft_version_range=[1.20,1.21) + +enabled_platforms=fabric,forge +architectury_version=9.1.10 + yarn_mappings=1.20+build.1 -loader_version=0.14.21 +fabric_loader_version=0.14.21 +fabric_api_version=0.83.0+1.20 -# Mod Properties -mod_version = 2.1.0+1.20 -maven_group = cyborgcabbage.emojitype -archives_base_name = emoji-type -fabric_version=0.83.0+1.20 +forge_version=1.20-46.0.14 -#Dependencies -cloth_config_version=11.0.99 -mod_menu_version=7.0.1 \ No newline at end of file +# https://linkie.shedaniel.me/dependencies +cloth_config_version=11.1.106 +modmenu_version=7.0.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..59bc51a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index c53aefa..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions $var, ${var}, ${var:-default}, ${var+SET}, -# ${var#prefix}, ${var%suffix}, and $( cmd ); -# * compound commands having a testable exit status, especially case; -# * various built-in commands including command, set, and ulimit. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # diff --git a/settings.gradle b/settings.gradle index b02216b..4ab8e79 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,14 @@ pluginManagement { repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://maven.minecraftforge.net/" } gradlePluginPortal() } } + +include("common") +include("fabric") +include("forge") + +rootProject.name = "emojitype" \ No newline at end of file