diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore index d9b406d..34d600a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,45 +1,42 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ +# gradle -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ *.iml *.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ -.idea/ +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + run/ -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ +# java -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store +hs_err_*.log +replay_*.log +*.hprof +*.jfr +remappedSrc/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 746677e..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Environment-dependent path to Maven home directory -/mavenHomeManager.xml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1625c17 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 06a0052..0000000 --- a/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Fabric-Kotlin MDK - -This is an example of using Cobblemon with Fabric and Kotlin. This mirrors the logic in the Java version of the MDK. - -## Notice when writing mixins - -When writing mixins, you should write these in Java and not in Kotlin due to a lack of support for Kotlin. -More information about this can be read on this [Sponge Issue](https://github.com/SpongePowered/Mixin/issues/245) \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..c960c2b --- /dev/null +++ b/build.gradle @@ -0,0 +1,113 @@ +plugins { + id 'fabric-loom' version "${loom_version}" + id 'maven-publish' + id "org.jetbrains.kotlin.jvm" version "2.1.20" +} + +version = project.mod_version +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + mavenCentral() + + maven { + url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' + } + maven { + url 'https://maven.impactdev.net/repository/development/' + } + + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots' + } + +} + +loom { + splitEnvironmentSourceSets() + + mods { + "cobblesync" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } + +} + +fabricApi { + configureDataGeneration { + client = true + } +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings loom.officialMojangMappings() + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" + + modImplementation "com.cobblemon:fabric:1.6.0+1.21.1-SNAPSHOT" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": inputs.properties.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + jvmTarget = 21 + } +} + +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() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +jar { + inputs.property "archivesName", project.base.archivesName + + from("LICENSE") { + rename { "${it}_${inputs.properties.archivesName}"} + } +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.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. + // 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. + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 71ca5fb..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,51 +0,0 @@ -plugins { - id("java") - id("dev.architectury.loom") version("1.7-SNAPSHOT") - id("architectury-plugin") version("3.4-SNAPSHOT") - kotlin("jvm") version ("1.9.23") -} - -group = "co.sirblob" -version = "1.0.0" - -architectury { - platformSetupLoomIde() - fabric() -} - -loom { - silentMojangMappingsLicense() -} - -repositories { - mavenCentral() - maven(url = "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/") - maven("https://maven.impactdev.net/repository/development/") -} - -dependencies { - minecraft("net.minecraft:minecraft:1.21.1") - mappings(loom.officialMojangMappings()) - modImplementation("net.fabricmc:fabric-loader:0.16.14") - - modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:0.104.0+1.21.1") - modImplementation(fabricApi.module("fabric-command-api-v2", "0.104.0+1.21.1")) - - modImplementation("net.fabricmc:fabric-language-kotlin:1.12.3+kotlin.2.0.21") - modImplementation("com.cobblemon:fabric:1.6.1+1.21.1-SNAPSHOT") - - testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0") -} - -tasks.getByName("test") { - useJUnitPlatform() -} - -tasks.processResources { - inputs.property("version", project.version) - - filesMatching("fabric.mod.json") { - expand(project.properties) - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ccee563..b551732 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ -org.gradle.jvmargs=-Xmx4G +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 loader_version=0.16.14 loom_version=1.10-SNAPSHOT fabric_kotlin_version=1.13.2+kotlin.2.1.20 @@ -15,5 +15,5 @@ maven_group=co.sirblob archives_base_name=cobblesync # Dependencies -fabric_version=0.115.6+1.21.1 -cobblemon_version=1.6.1+1.21.1 \ No newline at end of file +fabric_version=0.116.0+1.21.1 + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..a4b76b9 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 28f5fcf..e18bc25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index a69d9cb..f3b75f3 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +200,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index f127cfd..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -42,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..75c4d72 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index 5a9bc83..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,10 +0,0 @@ -rootProject.name = "CobbleSync" //By default, this is how your built jar is called - -pluginManagement { - repositories { - maven("https://maven.fabricmc.net/") - maven("https://maven.architectury.dev/") - maven("https://maven.minecraftforge.net/") - gradlePluginPortal() - } -} diff --git a/src/EntryPointConfiguration.json b/src/EntryPointConfiguration.json deleted file mode 100644 index e8eaf87..0000000 --- a/src/EntryPointConfiguration.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "entrypoints": { - "main": [ - { - "adapter": "kotlin", - "value": "co.sirblob.CobbleSync" - } - ], - "client": [ - { - "adapter": "kotlin", - "value": "co.sirblob.CobbleSyncClient" - } - ] - } -} \ No newline at end of file diff --git a/src/client/java/co/sirblob/mixin/client/ExampleClientMixin.java b/src/client/java/co/sirblob/mixin/client/ExampleClientMixin.java index 72f8218..b736285 100644 --- a/src/client/java/co/sirblob/mixin/client/ExampleClientMixin.java +++ b/src/client/java/co/sirblob/mixin/client/ExampleClientMixin.java @@ -1,15 +1,15 @@ package co.sirblob.mixin.client; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(MinecraftClient.class) +@Mixin(Minecraft.class) public class ExampleClientMixin { @Inject(at = @At("HEAD"), method = "run") private void init(CallbackInfo info) { - // This code is injected into the start of MinecraftClient.run()V + // This code is injected into the start of Minecraft.run()V } } \ No newline at end of file diff --git a/src/client/kotlin/co/sirblob/CobbleSyncClient.kt b/src/client/kotlin/co/sirblob/CobbleSyncClient.kt index 095b564..6a9d439 100644 --- a/src/client/kotlin/co/sirblob/CobbleSyncClient.kt +++ b/src/client/kotlin/co/sirblob/CobbleSyncClient.kt @@ -1,9 +1,51 @@ package co.sirblob -import net.fabricmc.api.ClientModInitializer +import org.lwjgl.glfw.GLFW +import org.lwjgl.system.windows.KEYBDINPUT + +import net.minecraft.client.KeyMapping +import net.minecraft.network.chat.Component + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper +import com.mojang.blaze3d.platform.InputConstants + +import com.cobblemon.mod.common.api.* +import com.cobblemon.mod.common.api.storage.PokemonStoreManager object CobbleSyncClient : ClientModInitializer { + override fun onInitializeClient() { - // This entrypoint is suitable for setting up client-specific logic, such as rendering. + + val binding1 = KeyBindingHelper.registerKeyBinding( + KeyMapping( + "key.fabric-key-binding-api-v1-testmod.test_keybinding_1", + InputConstants.Type.KEYSYM, + GLFW.GLFW_KEY_U, + "key.category.first.test" + ) + ) + + ClientTickEvents.END_CLIENT_TICK.register { client -> + while (binding1.consumeClick()) { + + var player = client.player + + // client.player?.sendSystemMessage( + // Component.literal("Key 1 was pressed!") + // .withStyle { style -> + // style.withColor(0x00FF00) + // } + // ) + + if(player != null) { + + + + } + + } + } } } \ No newline at end of file diff --git a/src/client/kotlin/co/sirblob/CobbleSyncPC.kt b/src/client/kotlin/co/sirblob/CobbleSyncPC.kt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/co/sirblob/mixin/ExampleMixin.java b/src/main/java/co/sirblob/mixin/ExampleMixin.java index 9dcd31e..bbab054 100644 --- a/src/main/java/co/sirblob/mixin/ExampleMixin.java +++ b/src/main/java/co/sirblob/mixin/ExampleMixin.java @@ -8,8 +8,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MinecraftServer.class) public class ExampleMixin { - @Inject(at = @At("HEAD"), method = "loadWorld") + @Inject(at = @At("HEAD"), method = "loadLevel") private void init(CallbackInfo info) { - // This code is injected into the start of MinecraftServer.loadWorld()V + // This code is injected into the start of MinecraftServer.loadLevel()V } } \ No newline at end of file diff --git a/src/main/kotlin/co/sirblob/CobbleSync.kt b/src/main/kotlin/co/sirblob/CobbleSync.kt index fde8e8d..4f5d8b8 100644 --- a/src/main/kotlin/co/sirblob/CobbleSync.kt +++ b/src/main/kotlin/co/sirblob/CobbleSync.kt @@ -1,25 +1,43 @@ package co.sirblob -import com.cobblemon.mod.common.Cobblemon import net.fabricmc.api.ModInitializer +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback +import net.minecraft.commands.CommandSourceStack +import net.minecraft.network.chat.Component import org.slf4j.LoggerFactory +import com.mojang.brigadier.builder.LiteralArgumentBuilder +import com.mojang.brigadier.context.CommandContext +import com.mojang.brigadier.Command +import com.cobblemon.mod.common.api.text.Text -import com.cobblemon.mod.common.NetworkManager object CobbleSync : ModInitializer { - - const val ID = "cobblesync" - private val logger = LoggerFactory.getLogger("cobblesync") - val networkManager: NetworkManager = Cobblemon.implementation.networkManager - override fun 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. - logger.info("Hello CobbleSync world!") - } + + CommandRegistrationCallback.EVENT.register(CommandRegistrationCallback { dispatcher, _, _ -> + dispatcher.register( + LiteralArgumentBuilder.literal("cobblesync") + .then( + LiteralArgumentBuilder.literal("sync") + .executes(Command { context: CommandContext -> + var player = context.source.player + + player?.sendSystemMessage( + Component.literal("CobbleSync is not yet implemented. Please check back later.") + .withStyle { style -> + style.withColor(0xFF0000) + } + ) + + 1 + }) + ) + ) + }) + + } } \ No newline at end of file diff --git a/src/main/kotlin/co/sirblob/commands/CommandHandler.kt b/src/main/kotlin/co/sirblob/commands/CommandHandler.kt deleted file mode 100644 index d513725..0000000 --- a/src/main/kotlin/co/sirblob/commands/CommandHandler.kt +++ /dev/null @@ -1,23 +0,0 @@ -package co.sirblob.commands - -import com.mojang.brigadier.CommandDispatcher -import com.mojang.brigadier.builder.LiteralArgumentBuilder -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback - -/** - * Handles the registration of all commands for the mod. - */ -object CommandHandler { - - /** - * Initializes and registers all commands. - * This method is typically called from your mod's main initializer. - */ - fun registerCommands() { - CommandRegistrationCallback.EVENT.register { dispatcher, registryAccess, environment -> - // Register your commands here - // MyCommand.register(dispatcher) - // Example: AnotherCommand.register(dispatcher) - } - } -} diff --git a/src/main/kotlin/co/sirblob/network/CobbleSyncNetwork.kt b/src/main/kotlin/co/sirblob/network/CobbleSyncNetwork.kt deleted file mode 100644 index 20dd466..0000000 --- a/src/main/kotlin/co/sirblob/network/CobbleSyncNetwork.kt +++ /dev/null @@ -1,26 +0,0 @@ -package co.sirblob.network - -import co.sirblob.network.handler.OpenPCHandler -import co.sirblob.network.packet.OpenPCPacket -import com.cobblemon.mod.common.net.PacketRegisterInfo - -object CobbleSyncNetwork { - - val s2cPayloads = generateS2CPacketInfoList() - val c2sPayloads = generateC2SPacketInfoList() - - private fun generateS2CPacketInfoList(): List> { - val list = mutableListOf>() - - return list - } - - private fun generateC2SPacketInfoList(): List> { - val list = mutableListOf>() - - list.add(PacketRegisterInfo(OpenPCPacket.ID, OpenPCPacket::decode, OpenPCHandler)) - - return list - } - -} \ No newline at end of file diff --git a/src/main/kotlin/co/sirblob/network/handler/OpenPCHandler.kt b/src/main/kotlin/co/sirblob/network/handler/OpenPCHandler.kt deleted file mode 100644 index eacd568..0000000 --- a/src/main/kotlin/co/sirblob/network/handler/OpenPCHandler.kt +++ /dev/null @@ -1,18 +0,0 @@ -package co.sirblob.network.handler - -import co.sirblob.network.packet.OpenPCPacket -import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler -import com.cobblemon.mod.common.util.pc -import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.ServerPlayer - -object OpenPCHandler : ServerNetworkPacketHandler { - override fun handle(packet: OpenPCPacket, server: MinecraftServer, player: ServerPlayer) { - server.execute { - val pc = player.pc() - com.cobblemon.mod.common.net.messages.client.storage.pc.OpenPCPacket(pc.uuid, 0).sendToPlayer(player) - } - } - - -} \ No newline at end of file diff --git a/src/main/kotlin/co/sirblob/network/packet/CobbleSyncNetworkPacket.kt b/src/main/kotlin/co/sirblob/network/packet/CobbleSyncNetworkPacket.kt deleted file mode 100644 index deaaade..0000000 --- a/src/main/kotlin/co/sirblob/network/packet/CobbleSyncNetworkPacket.kt +++ /dev/null @@ -1,17 +0,0 @@ -package co.sirblob.network.packet - -import co.sirblob.CobbleSync -import com.cobblemon.mod.common.api.net.NetworkPacket -import net.minecraft.server.level.ServerPlayer - -interface CobbleSyncNetworkPacket> : NetworkPacket { - - override fun sendToServer() { - CobbleSync.networkManager.sendToServer(this) - } - - override fun sendToPlayer(player: ServerPlayer) { - CobbleSync.networkManager.sendPacketToPlayer(player, this) - } - -} \ No newline at end of file diff --git a/src/main/kotlin/co/sirblob/network/packet/OpenPCPacket.kt b/src/main/kotlin/co/sirblob/network/packet/OpenPCPacket.kt deleted file mode 100644 index 39ea5a2..0000000 --- a/src/main/kotlin/co/sirblob/network/packet/OpenPCPacket.kt +++ /dev/null @@ -1,20 +0,0 @@ -package co.sirblob.network.packet - -import co.sirblob.CobbleSync -import net.minecraft.network.RegistryFriendlyByteBuf -import net.minecraft.resources.ResourceLocation - -class OpenPCPacket: CobbleSyncNetworkPacket { - - companion object { - val ID = ResourceLocation.fromNamespaceAndPath("open_pc", CobbleSync.ID) - fun decode(buffer: RegistryFriendlyByteBuf): OpenPCPacket = OpenPCPacket() - } - - override val id = ID - - override fun encode(buffer: RegistryFriendlyByteBuf) { - // TO SOMETHING - } - -} \ No newline at end of file diff --git a/src/main/resources/assets/cobblesync/lang/en_us.json b/src/main/resources/assets/cobblesync/lang/en_us.json deleted file mode 100644 index d423903..0000000 --- a/src/main/resources/assets/cobblesync/lang/en_us.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "key.cobblesync.open_pc.desc": "Open PC Storage" -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bf4bd32..42b1d34 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "CobbleSync", "description": "This is an example description! Tell everyone what your mod is about!", "authors": [ - "Sir_Blob_" + "Me!" ], "contact": { "homepage": "https://fabricmc.net/", @@ -26,6 +26,12 @@ "value": "co.sirblob.CobbleSyncClient", "adapter": "kotlin" } + ], + "fabric-datagen": [ + { + "value": "co.sirblob.CobbleSyncDataGenerator", + "adapter": "kotlin" + } ] }, "mixins": [