[READ-ONLY] Mirror of https://github.com/aaronateataco/pets-and-pals. Pets & Pals — client-side companion pets with real presence. Fork/redesign of downloadableduck's Pets Mod.
0

Configure Feed

Select the types of activity you want to include in your feed.

Initial commit

downloadableduck (Jan 25, 2026, 3:24 PM -0800) ce26dcbe

+1539
+9
.gitattributes
··· 1 + # 2 + # https://help.github.com/articles/dealing-with-line-endings/ 3 + # 4 + # Linux start script should use lf 5 + /gradlew text eol=lf 6 + 7 + # These are Windows script files and should use crlf 8 + *.bat text eol=crlf 9 +
+30
.github/workflows/build.yml
··· 1 + # Automatically build the project and run any configured tests for every push 2 + # and submitted pull request. This can help catch issues that only occur on 3 + # certain platforms or Java versions, and provides a first line of defence 4 + # against bad commits. 5 + 6 + name: build 7 + on: [pull_request, push] 8 + 9 + jobs: 10 + build: 11 + runs-on: ubuntu-24.04 12 + steps: 13 + - name: checkout repository 14 + uses: actions/checkout@v4 15 + - name: validate gradle wrapper 16 + uses: gradle/actions/wrapper-validation@v4 17 + - name: setup jdk 18 + uses: actions/setup-java@v4 19 + with: 20 + java-version: '21' 21 + distribution: 'microsoft' 22 + - name: make gradle wrapper executable 23 + run: chmod +x ./gradlew 24 + - name: build 25 + run: ./gradlew build 26 + - name: capture build artifacts 27 + uses: actions/upload-artifact@v4 28 + with: 29 + name: Artifacts 30 + path: build/libs/
+40
.gitignore
··· 1 + # gradle 2 + 3 + .gradle/ 4 + build/ 5 + out/ 6 + classes/ 7 + 8 + # eclipse 9 + 10 + *.launch 11 + 12 + # idea 13 + 14 + .idea/ 15 + *.iml 16 + *.ipr 17 + *.iws 18 + 19 + # vscode 20 + 21 + .settings/ 22 + .vscode/ 23 + bin/ 24 + .classpath 25 + .project 26 + 27 + # macos 28 + 29 + *.DS_Store 30 + 31 + # fabric 32 + 33 + run/ 34 + 35 + # java 36 + 37 + hs_err_*.log 38 + replay_*.log 39 + *.hprof 40 + *.jfr
+121
LICENSE
··· 1 + Creative Commons Legal Code 2 + 3 + CC0 1.0 Universal 4 + 5 + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 + HEREUNDER. 13 + 14 + Statement of Purpose 15 + 16 + The laws of most jurisdictions throughout the world automatically confer 17 + exclusive Copyright and Related Rights (defined below) upon the creator 18 + and subsequent owner(s) (each and all, an "owner") of an original work of 19 + authorship and/or a database (each, a "Work"). 20 + 21 + Certain owners wish to permanently relinquish those rights to a Work for 22 + the purpose of contributing to a commons of creative, cultural and 23 + scientific works ("Commons") that the public can reliably and without fear 24 + of later claims of infringement build upon, modify, incorporate in other 25 + works, reuse and redistribute as freely as possible in any form whatsoever 26 + and for any purposes, including without limitation commercial purposes. 27 + These owners may contribute to the Commons to promote the ideal of a free 28 + culture and the further production of creative, cultural and scientific 29 + works, or to gain reputation or greater distribution for their Work in 30 + part through the use and efforts of others. 31 + 32 + For these and/or other purposes and motivations, and without any 33 + expectation of additional consideration or compensation, the person 34 + associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 + is an owner of Copyright and Related Rights in the Work, voluntarily 36 + elects to apply CC0 to the Work and publicly distribute the Work under its 37 + terms, with knowledge of his or her Copyright and Related Rights in the 38 + Work and the meaning and intended legal effect of CC0 on those rights. 39 + 40 + 1. Copyright and Related Rights. A Work made available under CC0 may be 41 + protected by copyright and related or neighboring rights ("Copyright and 42 + Related Rights"). Copyright and Related Rights include, but are not 43 + limited to, the following: 44 + 45 + i. the right to reproduce, adapt, distribute, perform, display, 46 + communicate, and translate a Work; 47 + ii. moral rights retained by the original author(s) and/or performer(s); 48 + iii. publicity and privacy rights pertaining to a person's image or 49 + likeness depicted in a Work; 50 + iv. rights protecting against unfair competition in regards to a Work, 51 + subject to the limitations in paragraph 4(a), below; 52 + v. rights protecting the extraction, dissemination, use and reuse of data 53 + in a Work; 54 + vi. database rights (such as those arising under Directive 96/9/EC of the 55 + European Parliament and of the Council of 11 March 1996 on the legal 56 + protection of databases, and under any national implementation 57 + thereof, including any amended or successor version of such 58 + directive); and 59 + vii. other similar, equivalent or corresponding rights throughout the 60 + world based on applicable law or treaty, and any national 61 + implementations thereof. 62 + 63 + 2. Waiver. To the greatest extent permitted by, but not in contravention 64 + of, applicable law, Affirmer hereby overtly, fully, permanently, 65 + irrevocably and unconditionally waives, abandons, and surrenders all of 66 + Affirmer's Copyright and Related Rights and associated claims and causes 67 + of action, whether now known or unknown (including existing as well as 68 + future claims and causes of action), in the Work (i) in all territories 69 + worldwide, (ii) for the maximum duration provided by applicable law or 70 + treaty (including future time extensions), (iii) in any current or future 71 + medium and for any number of copies, and (iv) for any purpose whatsoever, 72 + including without limitation commercial, advertising or promotional 73 + purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 + member of the public at large and to the detriment of Affirmer's heirs and 75 + successors, fully intending that such Waiver shall not be subject to 76 + revocation, rescission, cancellation, termination, or any other legal or 77 + equitable action to disrupt the quiet enjoyment of the Work by the public 78 + as contemplated by Affirmer's express Statement of Purpose. 79 + 80 + 3. Public License Fallback. Should any part of the Waiver for any reason 81 + be judged legally invalid or ineffective under applicable law, then the 82 + Waiver shall be preserved to the maximum extent permitted taking into 83 + account Affirmer's express Statement of Purpose. In addition, to the 84 + extent the Waiver is so judged Affirmer hereby grants to each affected 85 + person a royalty-free, non transferable, non sublicensable, non exclusive, 86 + irrevocable and unconditional license to exercise Affirmer's Copyright and 87 + Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 + maximum duration provided by applicable law or treaty (including future 89 + time extensions), (iii) in any current or future medium and for any number 90 + of copies, and (iv) for any purpose whatsoever, including without 91 + limitation commercial, advertising or promotional purposes (the 92 + "License"). The License shall be deemed effective as of the date CC0 was 93 + applied by Affirmer to the Work. Should any part of the License for any 94 + reason be judged legally invalid or ineffective under applicable law, such 95 + partial invalidity or ineffectiveness shall not invalidate the remainder 96 + of the License, and in such case Affirmer hereby affirms that he or she 97 + will not (i) exercise any of his or her remaining Copyright and Related 98 + Rights in the Work or (ii) assert any associated claims and causes of 99 + action with respect to the Work, in either case contrary to Affirmer's 100 + express Statement of Purpose. 101 + 102 + 4. Limitations and Disclaimers. 103 + 104 + a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 + surrendered, licensed or otherwise affected by this document. 106 + b. Affirmer offers the Work as-is and makes no representations or 107 + warranties of any kind concerning the Work, express, implied, 108 + statutory or otherwise, including without limitation warranties of 109 + title, merchantability, fitness for a particular purpose, non 110 + infringement, or the absence of latent or other defects, accuracy, or 111 + the present or absence of errors, whether or not discoverable, all to 112 + the greatest extent permissible under applicable law. 113 + c. Affirmer disclaims responsibility for clearing rights of other persons 114 + that may apply to the Work or any use thereof, including without 115 + limitation any person's Copyright and Related Rights in the Work. 116 + Further, Affirmer disclaims responsibility for obtaining any necessary 117 + consents, permissions or other rights required for any use of the 118 + Work. 119 + d. Affirmer understands and acknowledges that Creative Commons is not a 120 + party to this document and has no duty or obligation with respect to 121 + this CC0 or use of the Work.
+92
build.gradle
··· 1 + plugins { 2 + id 'net.fabricmc.fabric-loom-remap' version "${loom_version}" 3 + id 'maven-publish' 4 + } 5 + 6 + version = project.mod_version 7 + group = project.maven_group 8 + 9 + base { 10 + archivesName = project.archives_base_name 11 + } 12 + 13 + repositories { 14 + maven { url "https://maven.shedaniel.me/" } 15 + maven { url "https://maven.terraformersmc.com/releases/" } 16 + // Add repositories to retrieve artifacts from in here. 17 + // You should only use this when depending on other mods because 18 + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. 19 + // See https://docs.gradle.org/current/userguide/declaring_repositories.html 20 + // for more information about repositories. 21 + } 22 + 23 + loom { 24 + splitEnvironmentSourceSets() 25 + 26 + mods { 27 + "coordinates" { 28 + sourceSet sourceSets.main 29 + sourceSet sourceSets.client 30 + } 31 + } 32 + 33 + } 34 + 35 + dependencies { 36 + // To change the versions see the gradle.properties file 37 + minecraft "com.mojang:minecraft:${project.minecraft_version}" 38 + mappings loom.officialMojangMappings() 39 + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 40 + modApi "me.shedaniel.cloth:cloth-config-fabric:15.0.127" 41 + // Fabric API. This is technically optional, but you probably want it anyway. 42 + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" 43 + 44 + } 45 + 46 + processResources { 47 + inputs.property "version", project.version 48 + 49 + filesMatching("fabric.mod.json") { 50 + expand "version": inputs.properties.version 51 + } 52 + } 53 + 54 + tasks.withType(JavaCompile).configureEach { 55 + it.options.release = 21 56 + } 57 + 58 + java { 59 + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 60 + // if it is present. 61 + // If you remove this line, sources will not be generated. 62 + withSourcesJar() 63 + 64 + sourceCompatibility = JavaVersion.VERSION_21 65 + targetCompatibility = JavaVersion.VERSION_21 66 + } 67 + 68 + jar { 69 + inputs.property "archivesName", project.base.archivesName 70 + 71 + from("LICENSE") { 72 + rename { "${it}_${inputs.properties.archivesName}"} 73 + } 74 + } 75 + 76 + // configure the maven publication 77 + publishing { 78 + publications { 79 + create("mavenJava", MavenPublication) { 80 + artifactId = project.archives_base_name 81 + from components.java 82 + } 83 + } 84 + 85 + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. 86 + repositories { 87 + // Add repositories to publish to here. 88 + // Notice: This block does NOT have the same function as the block in the top level. 89 + // The repositories here will be used for publishing your artifact, not for 90 + // retrieving dependencies. 91 + } 92 + }
+20
gradle.properties
··· 1 + # Done to increase the memory available to gradle. 2 + org.gradle.jvmargs=-Xmx1G 3 + org.gradle.parallel=true 4 + 5 + # IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349 6 + org.gradle.configuration-cache=false 7 + 8 + # Fabric Properties 9 + # check these on https://fabricmc.net/develop 10 + minecraft_version=1.21.11 11 + loader_version=0.18.4 12 + loom_version=1.14-SNAPSHOT 13 + 14 + # Mod Properties 15 + mod_version=1.0.0-1.21.11 16 + maven_group=com.jeff.duck 17 + archives_base_name=duckmod 18 + 19 + # Dependencies 20 + fabric_api_version=0.140.2+1.21.11
gradle/wrapper/gradle-wrapper.jar

This is a binary file and will not be displayed.

+7
gradle/wrapper/gradle-wrapper.properties
··· 1 + distributionBase=GRADLE_USER_HOME 2 + distributionPath=wrapper/dists 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 4 + networkTimeout=10000 5 + validateDistributionUrl=true 6 + zipStoreBase=GRADLE_USER_HOME 7 + zipStorePath=wrapper/dists
+248
gradlew
··· 1 + #!/bin/sh 2 + 3 + # 4 + # Copyright © 2015 the original authors. 5 + # 6 + # Licensed under the Apache License, Version 2.0 (the "License"); 7 + # you may not use this file except in compliance with the License. 8 + # You may obtain a copy of the License at 9 + # 10 + # https://www.apache.org/licenses/LICENSE-2.0 11 + # 12 + # Unless required by applicable law or agreed to in writing, software 13 + # distributed under the License is distributed on an "AS IS" BASIS, 14 + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + # See the License for the specific language governing permissions and 16 + # limitations under the License. 17 + # 18 + # SPDX-License-Identifier: Apache-2.0 19 + # 20 + 21 + ############################################################################## 22 + # 23 + # Gradle start up script for POSIX generated by Gradle. 24 + # 25 + # Important for running: 26 + # 27 + # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 + # noncompliant, but you have some other compliant shell such as ksh or 29 + # bash, then to run this script, type that shell name before the whole 30 + # command line, like: 31 + # 32 + # ksh Gradle 33 + # 34 + # Busybox and similar reduced shells will NOT work, because this script 35 + # requires all of these POSIX shell features: 36 + # * functions; 37 + # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 + # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 + # * compound commands having a testable exit status, especially «case»; 40 + # * various built-in commands including «command», «set», and «ulimit». 41 + # 42 + # Important for patching: 43 + # 44 + # (2) This script targets any POSIX shell, so it avoids extensions provided 45 + # by Bash, Ksh, etc; in particular arrays are avoided. 46 + # 47 + # The "traditional" practice of packing multiple parameters into a 48 + # space-separated string is a well documented source of bugs and security 49 + # problems, so this is (mostly) avoided, by progressively accumulating 50 + # options in "$@", and eventually passing that to Java. 51 + # 52 + # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 + # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 + # see the in-line comments for details. 55 + # 56 + # There are tweaks for specific operating systems such as AIX, CygWin, 57 + # Darwin, MinGW, and NonStop. 58 + # 59 + # (3) This script is generated from the Groovy template 60 + # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 + # within the Gradle project. 62 + # 63 + # You can find Gradle at https://github.com/gradle/gradle/. 64 + # 65 + ############################################################################## 66 + 67 + # Attempt to set APP_HOME 68 + 69 + # Resolve links: $0 may be a link 70 + app_path=$0 71 + 72 + # Need this for daisy-chained symlinks. 73 + while 74 + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 + [ -h "$app_path" ] 76 + do 77 + ls=$( ls -ld "$app_path" ) 78 + link=${ls#*' -> '} 79 + case $link in #( 80 + /*) app_path=$link ;; #( 81 + *) app_path=$APP_HOME$link ;; 82 + esac 83 + done 84 + 85 + # This is normally unused 86 + # shellcheck disable=SC2034 87 + APP_BASE_NAME=${0##*/} 88 + # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 + APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit 90 + 91 + # Use the maximum available, or set MAX_FD != -1 to use that value. 92 + MAX_FD=maximum 93 + 94 + warn () { 95 + echo "$*" 96 + } >&2 97 + 98 + die () { 99 + echo 100 + echo "$*" 101 + echo 102 + exit 1 103 + } >&2 104 + 105 + # OS specific support (must be 'true' or 'false'). 106 + cygwin=false 107 + msys=false 108 + darwin=false 109 + nonstop=false 110 + case "$( uname )" in #( 111 + CYGWIN* ) cygwin=true ;; #( 112 + Darwin* ) darwin=true ;; #( 113 + MSYS* | MINGW* ) msys=true ;; #( 114 + NONSTOP* ) nonstop=true ;; 115 + esac 116 + 117 + 118 + 119 + # Determine the Java command to use to start the JVM. 120 + if [ -n "$JAVA_HOME" ] ; then 121 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 122 + # IBM's JDK on AIX uses strange locations for the executables 123 + JAVACMD=$JAVA_HOME/jre/sh/java 124 + else 125 + JAVACMD=$JAVA_HOME/bin/java 126 + fi 127 + if [ ! -x "$JAVACMD" ] ; then 128 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 129 + 130 + Please set the JAVA_HOME variable in your environment to match the 131 + location of your Java installation." 132 + fi 133 + else 134 + JAVACMD=java 135 + if ! command -v java >/dev/null 2>&1 136 + then 137 + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 138 + 139 + Please set the JAVA_HOME variable in your environment to match the 140 + location of your Java installation." 141 + fi 142 + fi 143 + 144 + # Increase the maximum file descriptors if we can. 145 + if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 146 + case $MAX_FD in #( 147 + max*) 148 + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 149 + # shellcheck disable=SC2039,SC3045 150 + MAX_FD=$( ulimit -H -n ) || 151 + warn "Could not query maximum file descriptor limit" 152 + esac 153 + case $MAX_FD in #( 154 + '' | soft) :;; #( 155 + *) 156 + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 157 + # shellcheck disable=SC2039,SC3045 158 + ulimit -n "$MAX_FD" || 159 + warn "Could not set maximum file descriptor limit to $MAX_FD" 160 + esac 161 + fi 162 + 163 + # Collect all arguments for the java command, stacking in reverse order: 164 + # * args from the command line 165 + # * the main class name 166 + # * -classpath 167 + # * -D...appname settings 168 + # * --module-path (only if needed) 169 + # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 170 + 171 + # For Cygwin or MSYS, switch paths to Windows format before running java 172 + if "$cygwin" || "$msys" ; then 173 + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 174 + 175 + JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 + 177 + # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 + for arg do 179 + if 180 + case $arg in #( 181 + -*) false ;; # don't mess with options #( 182 + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 + [ -e "$t" ] ;; #( 184 + *) false ;; 185 + esac 186 + then 187 + arg=$( cygpath --path --ignore --mixed "$arg" ) 188 + fi 189 + # Roll the args list around exactly as many times as the number of 190 + # args, so each arg winds up back in the position where it started, but 191 + # possibly modified. 192 + # 193 + # NB: a `for` loop captures its iteration list before it begins, so 194 + # changing the positional parameters here affects neither the number of 195 + # iterations, nor the values presented in `arg`. 196 + shift # remove old arg 197 + set -- "$@" "$arg" # push replacement arg 198 + done 199 + fi 200 + 201 + 202 + # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 + DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 + 205 + # Collect all arguments for the java command: 206 + # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 + # and any embedded shellness will be escaped. 208 + # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 + # treated as '${Hostname}' itself on the command line. 210 + 211 + set -- \ 212 + "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ 214 + "$@" 215 + 216 + # Stop when "xargs" is not available. 217 + if ! command -v xargs >/dev/null 2>&1 218 + then 219 + die "xargs is not available" 220 + fi 221 + 222 + # Use "xargs" to parse quoted args. 223 + # 224 + # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 225 + # 226 + # In Bash we could simply go: 227 + # 228 + # readarray ARGS < <( xargs -n1 <<<"$var" ) && 229 + # set -- "${ARGS[@]}" "$@" 230 + # 231 + # but POSIX shell has neither arrays nor command substitution, so instead we 232 + # post-process each arg (as a line of input to sed) to backslash-escape any 233 + # character that might be a shell metacharacter, then use eval to reverse 234 + # that process (while maintaining the separation between arguments), and wrap 235 + # the whole thing up as a single "set" statement. 236 + # 237 + # This will of course break if any of these variables contains a newline or 238 + # an unmatched quote. 239 + # 240 + 241 + eval "set -- $( 242 + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 243 + xargs -n1 | 244 + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 245 + tr '\n' ' ' 246 + )" '"$@"' 247 + 248 + exec "$JAVACMD" "$@"
+93
gradlew.bat
··· 1 + @rem 2 + @rem Copyright 2015 the original author or authors. 3 + @rem 4 + @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 + @rem you may not use this file except in compliance with the License. 6 + @rem You may obtain a copy of the License at 7 + @rem 8 + @rem https://www.apache.org/licenses/LICENSE-2.0 9 + @rem 10 + @rem Unless required by applicable law or agreed to in writing, software 11 + @rem distributed under the License is distributed on an "AS IS" BASIS, 12 + @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 + @rem See the License for the specific language governing permissions and 14 + @rem limitations under the License. 15 + @rem 16 + @rem SPDX-License-Identifier: Apache-2.0 17 + @rem 18 + 19 + @if "%DEBUG%"=="" @echo off 20 + @rem ########################################################################## 21 + @rem 22 + @rem Gradle startup script for Windows 23 + @rem 24 + @rem ########################################################################## 25 + 26 + @rem Set local scope for the variables with windows NT shell 27 + if "%OS%"=="Windows_NT" setlocal 28 + 29 + set DIRNAME=%~dp0 30 + if "%DIRNAME%"=="" set DIRNAME=. 31 + @rem This is normally unused 32 + set APP_BASE_NAME=%~n0 33 + set APP_HOME=%DIRNAME% 34 + 35 + @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 + for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 + 38 + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 + set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 + 41 + @rem Find java.exe 42 + if defined JAVA_HOME goto findJavaFromJavaHome 43 + 44 + set JAVA_EXE=java.exe 45 + %JAVA_EXE% -version >NUL 2>&1 46 + if %ERRORLEVEL% equ 0 goto execute 47 + 48 + echo. 1>&2 49 + echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 + echo. 1>&2 51 + echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 + echo location of your Java installation. 1>&2 53 + 54 + goto fail 55 + 56 + :findJavaFromJavaHome 57 + set JAVA_HOME=%JAVA_HOME:"=% 58 + set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 + 60 + if exist "%JAVA_EXE%" goto execute 61 + 62 + echo. 1>&2 63 + echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 + echo. 1>&2 65 + echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 + echo location of your Java installation. 1>&2 67 + 68 + goto fail 69 + 70 + :execute 71 + @rem Setup the command line 72 + 73 + 74 + 75 + @rem Execute Gradle 76 + "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 77 + 78 + :end 79 + @rem End local scope for the variables with windows NT shell 80 + if %ERRORLEVEL% equ 0 goto mainEnd 81 + 82 + :fail 83 + rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 84 + rem the _cmd.exe /c_ return code! 85 + set EXIT_CODE=%ERRORLEVEL% 86 + if %EXIT_CODE% equ 0 set EXIT_CODE=1 87 + if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 88 + exit /b %EXIT_CODE% 89 + 90 + :mainEnd 91 + if "%OS%"=="Windows_NT" endlocal 92 + 93 + :omega
+48
qodana.yaml
··· 1 + #-------------------------------------------------------------------------------# 2 + # Qodana analysis is configured by qodana.yaml file # 3 + # https://www.jetbrains.com/help/qodana/qodana-yaml.html # 4 + #-------------------------------------------------------------------------------# 5 + 6 + ################################################################################# 7 + # WARNING: Do not store sensitive information in this file, # 8 + # as its contents will be included in the Qodana report. # 9 + ################################################################################# 10 + version: "1.0" 11 + 12 + #Specify inspection profile for code analysis 13 + profile: 14 + name: qodana.starter 15 + 16 + #Enable inspections 17 + #include: 18 + # - name: <SomeEnabledInspectionId> 19 + 20 + #Disable inspections 21 + #exclude: 22 + # - name: <SomeDisabledInspectionId> 23 + # paths: 24 + # - <path/where/not/run/inspection> 25 + 26 + projectJDK: "21" #(Applied in CI/CD pipeline) 27 + 28 + #Execute shell command before Qodana execution (Applied in CI/CD pipeline) 29 + #bootstrap: sh ./prepare-qodana.sh 30 + 31 + #Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) 32 + #plugins: 33 + # - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com) 34 + 35 + # Quality gate. Will fail the CI/CD pipeline if any condition is not met 36 + # severityThresholds - configures maximum thresholds for different problem severities 37 + # testCoverageThresholds - configures minimum code coverage on a whole project and newly added code 38 + # Code Coverage is available in Ultimate and Ultimate Plus plans 39 + #failureConditions: 40 + # severityThresholds: 41 + # any: 15 42 + # critical: 5 43 + # testCoverageThresholds: 44 + # fresh: 70 45 + # total: 50 46 + 47 + #Specify Qodana linter for analysis (Applied in CI/CD pipeline) 48 + linter: jetbrains/qodana-jvm-community:2025.2
+10
settings.gradle
··· 1 + pluginManagement { 2 + repositories { 3 + maven { 4 + name = 'Fabric' 5 + url = 'https://maven.fabricmc.net/' 6 + } 7 + mavenCentral() 8 + gradlePluginPortal() 9 + } 10 + }
+15
src/client/java/com/jeff/duck/DuckClient.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.fabricmc.api.ClientModInitializer; 4 + import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; 5 + import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; 6 + 7 + public class DuckClient implements ClientModInitializer { 8 + @Override 9 + public void onInitializeClient() { 10 + 11 + EntityRendererRegistry.register(DuckInitializer.DUCK, DuckRenderer::new); 12 + 13 + EntityModelLayerRegistry.registerModelLayer(DuckModel.LAYER_LOCATION, DuckModel::getTexturedModelData); 14 + } 15 + }
+67
src/client/java/com/jeff/duck/DuckModel.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.minecraft.client.model.EntityModel; 4 + import net.minecraft.client.model.geom.ModelLayerLocation; 5 + import net.minecraft.client.model.geom.ModelPart; 6 + import net.minecraft.client.model.geom.PartPose; 7 + import net.minecraft.client.model.geom.builders.*; 8 + import net.minecraft.resources.Identifier; 9 + import net.minecraft.util.Mth; 10 + import org.jetbrains.annotations.NotNull; 11 + 12 + public class DuckModel extends EntityModel<@NotNull DuckRenderState> { 13 + public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation( 14 + Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, "duck"), "main" 15 + ); 16 + private final ModelPart head; 17 + private final ModelPart rightLeg; 18 + private final ModelPart leftLeg; 19 + private final ModelPart rightWing; 20 + private final ModelPart leftWing; 21 + 22 + public DuckModel(final ModelPart root) { 23 + super(root); 24 + this.head = root.getChild("head"); 25 + this.rightLeg = root.getChild("right_leg"); 26 + this.leftLeg = root.getChild("left_leg"); 27 + this.rightWing = root.getChild("right_wing"); 28 + this.leftWing = root.getChild("left_wing"); 29 + } 30 + 31 + public static LayerDefinition getTexturedModelData() { 32 + MeshDefinition modelData = new MeshDefinition(); 33 + PartDefinition partDefinition = modelData.getRoot(); 34 + PartDefinition head = partDefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -5.0F, -1.5F, 3.0F, 6.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 15.0F, -4.0F)); 35 + 36 + PartDefinition bill = head.addOrReplaceChild("bill", CubeListBuilder.create().texOffs(14, 0).addBox(-1.0F, -3.9F, -3.1F, 2.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F)); 37 + 38 + PartDefinition chin = partDefinition.addOrReplaceChild("chin", CubeListBuilder.create(), PartPose.offset(0.0F, 15.0F, -4.0F)); 39 + 40 + PartDefinition body = partDefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(1, 10).addBox(-2.5F, -4.0F, -4.0F, 5.0F, 8.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 16.0F, 0.0F, 1.5708F, 0.0F, 0.0F)); 41 + 42 + PartDefinition left_wing = partDefinition.addOrReplaceChild("left_wing", CubeListBuilder.create().texOffs(24, 13).addBox(-1.5F, 0F, -3.0F, 1.0F, 3.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(4.0F, 15F, 0.0F)); 43 + 44 + PartDefinition right_wing = partDefinition.addOrReplaceChild("right_wing", CubeListBuilder.create().texOffs(24, 13).addBox(0.5F, 0F, -3.0F, 1.0F, 3.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(-4.0F, 15F, 0.0F)); 45 + 46 + PartDefinition left_leg = partDefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(26, 0).addBox(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(1.0F, 19.0F, 1.0F)); 47 + 48 + PartDefinition right_leg = partDefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(26, 0).addBox(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.0F, 19.0F, 1.0F)); 49 + 50 + PartDefinition tail = partDefinition.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(15, 4).addBox(-1.0F, -7.0F, 4.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); 51 + 52 + return LayerDefinition.create(modelData, 64, 32); 53 + } 54 + 55 + public void setupAnim(final DuckRenderState state) { 56 + super.setupAnim(state); 57 + float flapAngle = (Mth.sin(state.flap) + 1.0F) * state.flapSpeed; 58 + this.head.xRot = state.xRot * ((float) Math.PI / 180F); 59 + this.head.yRot = state.yRot * ((float) Math.PI / 180F); 60 + float animationSpeed = state.walkAnimationSpeed; 61 + float animationPos = state.walkAnimationPos; 62 + this.rightLeg.xRot = Mth.cos(animationPos * 0.6662F) * 1.4F * animationSpeed; 63 + this.leftLeg.xRot = Mth.cos(animationPos * 0.6662F + (float) Math.PI) * 1.4F * animationSpeed; 64 + this.rightWing.zRot = flapAngle; 65 + this.leftWing.zRot = -flapAngle; 66 + } 67 + }
+186
src/client/java/com/jeff/duck/DuckPet.java
··· 1 + package com.jeff.duck; 2 + 3 + import com.mojang.brigadier.arguments.StringArgumentType; 4 + import com.mojang.brigadier.suggestion.SuggestionProvider; 5 + import me.shedaniel.autoconfig.AutoConfig; 6 + import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; 7 + import net.fabricmc.api.ClientModInitializer; 8 + import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; 9 + import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; 10 + import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; 11 + import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; 12 + import net.minecraft.client.Minecraft; 13 + import net.minecraft.client.multiplayer.ClientLevel; 14 + import net.minecraft.client.player.LocalPlayer; 15 + import net.minecraft.commands.SharedSuggestionProvider; 16 + import net.minecraft.commands.synchronization.SuggestionProviders; 17 + import net.minecraft.network.chat.Component; 18 + import net.minecraft.world.entity.Entity; 19 + import net.minecraft.world.phys.Vec3; 20 + 21 + import java.util.ArrayList; 22 + import java.util.List; 23 + import java.util.Objects; 24 + 25 + import static com.jeff.duck.DuckInitializer.DUCK; 26 + 27 + public class DuckPet implements ClientModInitializer { 28 + 29 + public static final List<Entity> summonedEntity = new ArrayList<>(); 30 + private static final SuggestionProvider<SharedSuggestionProvider> DUCK_TYPES = (context, builder) -> 31 + SharedSuggestionProvider.suggest(new String[]{ 32 + "pekin", 33 + "mallard", 34 + }, builder); 35 + private static final SuggestionProvider<SharedSuggestionProvider> ON_OFF = (context, builder) -> 36 + SharedSuggestionProvider.suggest(new String[]{ 37 + "off", 38 + "on", 39 + }, builder); 40 + public static DuckSavedData CONFIG; 41 + public static int duckSkin; 42 + public Duck duck; 43 + int i; 44 + 45 + public DuckPet() { 46 + } 47 + 48 + public void onInitializeClient() { 49 + AutoConfig.register(DuckSavedData.class, GsonConfigSerializer::new); 50 + CONFIG = AutoConfig.getConfigHolder(DuckSavedData.class).getConfig(); 51 + 52 + if (CONFIG.duckTexturePath == null) { 53 + CONFIG.duckTexturePath = "textures/entity/mallard_male.png"; 54 + } 55 + 56 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("duck") 57 + .then(ClientCommandManager.argument("preference", StringArgumentType.string()) 58 + .suggests(SuggestionProviders.cast(ON_OFF)) 59 + .executes(context -> { 60 + String preference = StringArgumentType.getString(context, "preference"); 61 + if (Objects.equals(preference, "off")) { 62 + CONFIG.duckSummonedPreference = false; 63 + context.getSource().sendFeedback(Component.literal("§6Duck §coff.")); 64 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 65 + } else if (Objects.equals(preference, "on")) { 66 + CONFIG.duckSummonedPreference = true; 67 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 68 + context.getSource().sendFeedback(Component.literal("§6Duck §aon.")); 69 + 70 + } else { 71 + context.getSource().sendFeedback(Component.literal("§c§lUnknown value " + preference + "! Possible values: §r§aon, §6off")); 72 + } 73 + return 1; 74 + } 75 + ) 76 + ) 77 + )); 78 + 79 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("duckname") 80 + .then(ClientCommandManager.argument("name", StringArgumentType.greedyString()) 81 + .executes(context -> { 82 + CONFIG.duckName = StringArgumentType.getString(context, "name"); 83 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 84 + 85 + if (!summonedEntity.isEmpty()) { 86 + Entity activeDuck = summonedEntity.getFirst(); 87 + if (activeDuck != null) { 88 + activeDuck.setCustomName(Component.literal(CONFIG.duckName)); 89 + context.getSource().sendFeedback(Component.literal("§aYour duck's name has been set to §6" + CONFIG.duckName)); 90 + } 91 + } 92 + duck.setCustomName(Component.literal(CONFIG.duckName)); 93 + return 1; 94 + })))); 95 + 96 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("resetduckname") 97 + .executes((context) -> { 98 + CONFIG.duckName = ""; 99 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 100 + duck.setCustomName(Component.literal(CONFIG.duckName)); 101 + 102 + return 1; 103 + }))); 104 + 105 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("teleportduck") 106 + .executes((context) -> { 107 + if (duck != null) { 108 + duck.tryToTeleportToOwner(); 109 + } 110 + return 1; 111 + }))); 112 + 113 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("duckspecies") 114 + .then(ClientCommandManager.argument("species", StringArgumentType.greedyString()) 115 + .suggests(SuggestionProviders.cast(DUCK_TYPES)) 116 + .executes((context) -> { 117 + String species = StringArgumentType.getString(context, "species"); 118 + if (Objects.equals(species, "male mallard") || Objects.equals(species, "mallard") || Objects.equals(species, "default")) { 119 + CONFIG.duckTexturePath = "textures/entity/mallard_male.png"; 120 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 121 + } else if (Objects.equals(species, "pekin") || Objects.equals(species, "pekin duck")) { 122 + CONFIG.duckTexturePath = "textures/entity/pekin.png"; 123 + AutoConfig.getConfigHolder(DuckSavedData.class).save(); 124 + } else { 125 + context.getSource().sendFeedback(Component.literal("§c§lThat is not a valid species. Valid species: §r§2Mallard, §rPekin.")); 126 + } 127 + return 1; 128 + } 129 + )))); 130 + 131 + ClientTickEvents.END_CLIENT_TICK.register(client -> client.execute(() -> { 132 + 133 + Minecraft minecraft = Minecraft.getInstance(); 134 + ClientLevel world = minecraft.level; 135 + duckSkin = (int) (Math.random() * 3); 136 + if (client.player != null && CONFIG.duckSummonedPreference && summonedEntity.isEmpty()) { 137 + summonDuck(); 138 + } 139 + 140 + if (!CONFIG.duckSummonedPreference && !summonedEntity.isEmpty()) { 141 + assert world != null; 142 + world.removeEntity(i, Entity.RemovalReason.DISCARDED); 143 + summonedEntity.clear(); 144 + } 145 + 146 + })); 147 + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> client.execute(summonedEntity::clear)); 148 + } 149 + 150 + public void summonDuck() { 151 + 152 + Minecraft minecraft = Minecraft.getInstance(); 153 + 154 + LocalPlayer player = minecraft.player; 155 + ClientLevel world = minecraft.level; 156 + 157 + duck = new Duck(DUCK, world); 158 + 159 + Vec3 lookAngle; 160 + 161 + { 162 + assert player != null; 163 + lookAngle = player.getLookAngle(); 164 + } 165 + 166 + double x = player.getX() - (lookAngle.x * 0.5); 167 + double y = player.getY() + 0.5; 168 + double z = player.getZ() - (lookAngle.z * 0.5); 169 + 170 + if (world != null) { 171 + 172 + duck.setPos(x, y, z); 173 + i = duck.getId(); 174 + if (CONFIG.duckName == null) { 175 + CONFIG.duckName = ""; 176 + } 177 + duck.setCustomName(Component.literal(CONFIG.duckName)); 178 + CONFIG.uuid = duck.getId(); 179 + duck.setServerEntity(false); 180 + 181 + world.addEntity(duck); 182 + duck.tame(player); 183 + summonedEntity.add(duck); 184 + } 185 + } 186 + }
+10
src/client/java/com/jeff/duck/DuckRenderState.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; 4 + 5 + public class DuckRenderState extends LivingEntityRenderState { 6 + public float flap; 7 + public float flapSpeed; 8 + public boolean isServerEntity; 9 + public int duckSpecies; 10 + }
+46
src/client/java/com/jeff/duck/DuckRenderer.java
··· 1 + package com.jeff.duck; 2 + 3 + import me.shedaniel.autoconfig.annotation.Config; 4 + import net.minecraft.client.renderer.entity.EntityRendererProvider; 5 + import net.minecraft.client.renderer.entity.MobRenderer; 6 + import net.minecraft.resources.Identifier; 7 + import net.minecraft.util.Mth; 8 + import org.jetbrains.annotations.NotNull; 9 + 10 + import static com.jeff.duck.DuckPet.CONFIG; 11 + 12 + @Config(name = "duckrenderer") 13 + public class DuckRenderer extends MobRenderer<@NotNull Duck, @NotNull DuckRenderState, @NotNull DuckModel> { 14 + public DuckRenderer(final EntityRendererProvider.Context context) { 15 + super(context, new DuckModel(context.bakeLayer(DuckModel.LAYER_LOCATION)), 0.3F); 16 + } 17 + 18 + public DuckRenderState createRenderState() { 19 + return new DuckRenderState(); 20 + } 21 + 22 + @Override 23 + public void extractRenderState(final Duck entity, final DuckRenderState state, final float partialTicks) { 24 + state.isServerEntity = entity.isServerEntity(); 25 + state.duckSpecies = entity.getEntityData().get(Duck.DUCK_SKIN); 26 + state.flap = Mth.lerp(partialTicks, entity.oFlap, entity.flap); 27 + state.flapSpeed = Mth.lerp(partialTicks, entity.oFlapSpeed, entity.flapSpeed); 28 + super.extractRenderState(entity, state, partialTicks); 29 + } 30 + 31 + @Override 32 + public @NotNull Identifier getTextureLocation(final DuckRenderState state) { 33 + if (!state.isServerEntity) { 34 + return Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, CONFIG.duckTexturePath); 35 + } else { 36 + if (state.duckSpecies == 0) { 37 + return Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, "textures/entity/mallard_male.png"); 38 + } else if (state.duckSpecies == 1) { 39 + return Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, "textures/entity/pekin.png"); 40 + } else { 41 + return Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, "textures/entity/yeahitdidntwork"); 42 + } 43 + } 44 + //we use textures/entity/mallard_male.png because nothing else worked because this code fucking sucks 45 + } 46 + }
+12
src/client/java/com/jeff/duck/DuckSavedData.java
··· 1 + package com.jeff.duck; 2 + 3 + import me.shedaniel.autoconfig.ConfigData; 4 + import me.shedaniel.autoconfig.annotation.Config; 5 + 6 + @Config(name = "duckconfig") 7 + public class DuckSavedData implements ConfigData { 8 + public boolean duckSummonedPreference; 9 + public String duckName; 10 + public String duckTexturePath; 11 + public int uuid; 12 + }
+15
src/client/java/com/jeff/duck/mixin/client/ExampleClientMixin.java
··· 1 + package com.jeff.duck.mixin.client; 2 + 3 + import net.minecraft.client.Minecraft; 4 + import org.spongepowered.asm.mixin.Mixin; 5 + import org.spongepowered.asm.mixin.injection.At; 6 + import org.spongepowered.asm.mixin.injection.Inject; 7 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 8 + 9 + @Mixin(Minecraft.class) 10 + public class ExampleClientMixin { 11 + @Inject(at = @At("HEAD"), method = "run") 12 + private void init(CallbackInfo info) { 13 + // This code is injected into the start of Minecraft.run()V 14 + } 15 + }
+11
src/client/resources/duck.client.mixins.json
··· 1 + { 2 + "required": true, 3 + "package": "com.jeff.duck.mixin.client", 4 + "compatibilityLevel": "JAVA_21", 5 + "client": [ 6 + "ExampleClientMixin" 7 + ], 8 + "injectors": { 9 + "defaultRequire": 1 10 + } 11 + }
+303
src/main/java/com/jeff/duck/Duck.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.minecraft.core.BlockPos; 4 + import net.minecraft.core.particles.ParticleTypes; 5 + import net.minecraft.nbt.CompoundTag; 6 + import net.minecraft.network.protocol.Packet; 7 + import net.minecraft.network.protocol.game.ClientGamePacketListener; 8 + import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; 9 + import net.minecraft.network.syncher.EntityDataAccessor; 10 + import net.minecraft.network.syncher.EntityDataSerializers; 11 + import net.minecraft.network.syncher.SynchedEntityData; 12 + import net.minecraft.server.level.ServerEntity; 13 + import net.minecraft.server.level.ServerLevel; 14 + import net.minecraft.sounds.SoundEvent; 15 + import net.minecraft.sounds.SoundEvents; 16 + import net.minecraft.sounds.SoundSource; 17 + import net.minecraft.tags.ItemTags; 18 + import net.minecraft.util.Mth; 19 + import net.minecraft.world.DifficultyInstance; 20 + import net.minecraft.world.InteractionHand; 21 + import net.minecraft.world.InteractionResult; 22 + import net.minecraft.world.damagesource.DamageSource; 23 + import net.minecraft.world.entity.*; 24 + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; 25 + import net.minecraft.world.entity.ai.attributes.Attributes; 26 + import net.minecraft.world.entity.ai.goal.*; 27 + import net.minecraft.world.entity.animal.Animal; 28 + import net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity; 29 + import net.minecraft.world.entity.player.Player; 30 + import net.minecraft.world.item.ItemStack; 31 + import net.minecraft.world.level.Level; 32 + import net.minecraft.world.level.ServerLevelAccessor; 33 + import net.minecraft.world.level.block.state.BlockState; 34 + import net.minecraft.world.level.storage.ValueInput; 35 + import net.minecraft.world.level.storage.ValueOutput; 36 + import net.minecraft.world.phys.Vec3; 37 + import org.jetbrains.annotations.NotNull; 38 + import org.jspecify.annotations.Nullable; 39 + 40 + import static com.jeff.duck.DuckInitializer.DUCK; 41 + 42 + public class Duck extends ShoulderRidingEntity { 43 + 44 + public static final EntityDataAccessor<@NotNull Boolean> IS_SERVER_ENTITY = 45 + SynchedEntityData.defineId(Duck.class, EntityDataSerializers.BOOLEAN); 46 + 47 + public static final EntityDataAccessor<@NotNull Integer> DUCK_SKIN = 48 + SynchedEntityData.defineId(Duck.class, EntityDataSerializers.INT); 49 + public float flap; 50 + public float flapSpeed; 51 + public float oFlapSpeed; 52 + public float oFlap; 53 + public float flapping = 1.0F; 54 + private float nextFlap = 1.0F; 55 + public Duck(final EntityType<? extends @NotNull Duck> type, final Level level) { 56 + super(type, level); 57 + } 58 + 59 + public static AttributeSupplier.Builder createAttributes() { 60 + return Animal.createAnimalAttributes().add(Attributes.MAX_HEALTH, 500.0F).add(Attributes.MOVEMENT_SPEED, 0.25F); 61 + } 62 + 63 + @Override 64 + protected void defineSynchedData(SynchedEntityData.@NotNull Builder builder) { 65 + super.defineSynchedData(builder); 66 + builder.define(DUCK_SKIN, 1); 67 + builder.define(IS_SERVER_ENTITY, false); 68 + } 69 + 70 + public boolean isServerEntity() { 71 + return this.entityData.get(IS_SERVER_ENTITY); 72 + } 73 + 74 + public void setServerEntity(Boolean value) { 75 + this.entityData.set(IS_SERVER_ENTITY, value); 76 + } 77 + 78 + public float rotlerp(float start, float end) { 79 + float f = Mth.wrapDegrees(end - start); 80 + if (f > 10.0f) f = 10.0f; 81 + if (f < -10.0f) f = -10.0f; 82 + return start + f; 83 + } 84 + 85 + public void aiStep() { 86 + super.aiStep(); 87 + this.oFlap = this.flap; 88 + this.oFlapSpeed = this.flapSpeed; 89 + this.flapSpeed += (this.onGround() ? -1.0F : 4.0F) * 0.3F; 90 + this.flapSpeed = Mth.clamp(this.flapSpeed, 0.0F, 1.0F); 91 + if (!this.onGround() && this.flapping < 1.0F) { 92 + this.flapping = 1.0F; 93 + } 94 + 95 + this.flapping *= 0.9F; 96 + Vec3 movement = this.getDeltaMovement(); 97 + if (!this.onGround() && movement.y < (double) 0.0F) { 98 + this.setDeltaMovement(movement.multiply(1.0F, 0.6, 1.0F)); 99 + } 100 + 101 + this.flap += this.flapping * 2.0F; 102 + } 103 + 104 + protected boolean isFlapping() { 105 + return this.flyDist > this.nextFlap; 106 + } 107 + 108 + protected void onFlap() { 109 + this.nextFlap = this.flyDist + this.flapSpeed / 2.0F; 110 + } 111 + 112 + protected SoundEvent getAmbientSound() { 113 + return DuckSounds.DUCK_AMBIENT; 114 + } 115 + 116 + protected SoundEvent getHurtSound(final @NotNull DamageSource source) { 117 + return DuckSounds.DUCK_AMBIENT; 118 + } 119 + 120 + protected SoundEvent getDeathSound() { 121 + return DuckSounds.DUCK_AMBIENT; 122 + } 123 + 124 + protected void playStepSound(final @NotNull BlockPos pos, final @NotNull BlockState blockState) { 125 + this.playSound(SoundEvents.CHICKEN_STEP, 0.15F, 1.0F); 126 + } 127 + 128 + public @Nullable Duck getBreedOffspring(final @NotNull ServerLevel level, final @NotNull AgeableMob partner) { 129 + return DUCK.create(level, EntitySpawnReason.BREEDING); 130 + } 131 + 132 + public SpawnGroupData finalizeSpawn(final @NotNull ServerLevelAccessor level, final @NotNull DifficultyInstance difficulty, final @NotNull EntitySpawnReason spawnReason, final @Nullable SpawnGroupData groupData) { 133 + this.setServerEntity(true); 134 + this.entityData.set(DUCK_SKIN, this.random.nextInt(2)); 135 + return super.finalizeSpawn(level, difficulty, spawnReason, groupData); 136 + } 137 + 138 + public boolean isFood(final ItemStack itemStack) { 139 + return itemStack.is(ItemTags.CHICKEN_FOOD); 140 + } 141 + 142 + @Override 143 + public void registerGoals() { 144 + 145 + this.goalSelector.addGoal(2, new FloatGoal(this)); 146 + this.goalSelector.addGoal(3, new PanicGoal(this, 1.4d)); 147 + this.goalSelector.addGoal(4, new TemptGoal(this, 1.0f, stack -> stack.is(ItemTags.SKULLS), false)); 148 + 149 + this.goalSelector.addGoal(5, new RandomLookAroundGoal(this)); 150 + this.goalSelector.addGoal(6, new RandomStrollGoal(this, 1.0D)); 151 + this.goalSelector.addGoal(7, new EatBlockGoal(this)); 152 + this.goalSelector.addGoal(8, new FollowOwnerGoal(this, 1, 2, 10)); 153 + } 154 + 155 + @Override 156 + public @NotNull InteractionResult mobInteract(@NotNull Player player, @NotNull InteractionHand hand) { 157 + ItemStack itemStack = player.getItemInHand(hand); 158 + 159 + var x = this.getX(); 160 + var y = this.getY(); 161 + var z = this.getZ(); 162 + 163 + if (!this.isTame() && this.isFood(itemStack)) { 164 + if (this.random.nextInt(3) == 0) { 165 + this.tame(player); 166 + this.navigation.stop(); 167 + this.level().addParticle( 168 + ParticleTypes.HEART, 169 + 170 + x + (player.getRandom().nextFloat() * 0.4 - 0.25), 171 + y + (player.getRandom().nextFloat() * 0.4 - 0.25), 172 + z + (player.getRandom().nextFloat() * 0.4 - 0.25), 173 + 0, 1, 0 174 + ); 175 + } 176 + } 177 + 178 + if (this.isTame() && this.isOwnedBy(player)) { 179 + CompoundTag duckTag = new CompoundTag(); 180 + 181 + if (!this.level().isClientSide()) { 182 + 183 + if (((net.minecraft.server.level.ServerPlayer) player).setEntityOnShoulder(duckTag)) { 184 + this.tame(player); 185 + } 186 + } 187 + } 188 + return InteractionResult.SUCCESS; 189 + } 190 + 191 + @Override 192 + public void tick() { 193 + super.tick(); 194 + LivingEntity owner = this.getOwner(); 195 + if (owner != null) { 196 + 197 + double dx = owner.getX() - this.getX(); 198 + double dz = owner.getZ() - this.getZ(); 199 + 200 + double targetYaw = Math.atan2(dz, dx) * (180 / Math.PI) - 90f; 201 + 202 + double distance = this.distanceTo(owner); 203 + float rotation = this.getRotationVector().x; 204 + var rotationToOwner = rotation + this.getOwner().getRotationVector().x; 205 + float horizontalDistance = (float) this.getDeltaMovement().horizontalDistance(); 206 + float animationSpeed = 1.0f; 207 + float bodyYawDiff = Mth.wrapDegrees(this.getYHeadRot() - this.yBodyRot); 208 + 209 + if (rotationToOwner >= 50) { 210 + this.yBodyRot = this.getYHeadRot() - (Mth.sign(bodyYawDiff) * 50.0F); 211 + } 212 + 213 + if (distance > 2.0) { 214 + 215 + this.walkAnimation.update(animationSpeed, horizontalDistance, 0.7f); 216 + this.walkAnimation.setSpeed(0.7F); 217 + 218 + Vec3 targetPos = owner.position(); 219 + Vec3 dir = targetPos.subtract(this.position()).normalize(); 220 + 221 + this.setYRot(rotlerp(this.getYRot(), (float) targetYaw)); 222 + this.setYHeadRot(this.getYRot()); 223 + this.yBodyRot = Mth.rotateIfNecessary(this.yBodyRot, this.yHeadRot, 50.0f); 224 + 225 + double speed = 0.15; 226 + this.setDeltaMovement(dir.x * speed, this.getDeltaMovement().y, dir.z * speed); 227 + } else { 228 + this.lookAt(owner, 5, 0); 229 + this.walkAnimation.update(horizontalDistance, animationSpeed, 0f); 230 + this.setDeltaMovement(this.getDeltaMovement().multiply(0.8, 1.0, 0.8)); 231 + } 232 + 233 + int yHeightToOwner = (int) (owner.getY() - this.getY()); 234 + 235 + if (yHeightToOwner > 1) { 236 + this.jumpFromGround(); 237 + } 238 + 239 + if (!this.onGround()) { 240 + this.processFlappingMovement(); 241 + } 242 + this.setYRot(rotlerp(this.getYRot(), (float) targetYaw)); 243 + this.setYHeadRot(this.getYRot()); 244 + 245 + if (Math.abs(bodyYawDiff) > 50) { 246 + this.yBodyRot = this.getYHeadRot() - (Mth.sign(bodyYawDiff) * 50); 247 + } else { 248 + this.yBodyRot = Mth.rotateIfNecessary(this.yBodyRot, this.getYHeadRot(), 10); 249 + } 250 + 251 + this.move(MoverType.SELF, this.getDeltaMovement()); 252 + 253 + if (!this.onGround()) { 254 + this.setDeltaMovement(this.getDeltaMovement().add(0, -0.04, 0)); 255 + } 256 + } 257 + if (owner != null) { 258 + if (distanceTo(owner) >= 10) { 259 + this.tryToTeleportToOwner(); 260 + } 261 + } 262 + 263 + if (this.walkAnimation.isMoving()) { 264 + level().playSound(this, this.blockPosition(), SoundEvents.CHICKEN_STEP, SoundSource.NEUTRAL); 265 + } 266 + 267 + int ambient = (int) (Math.random() * (60 * 20)); 268 + if (ambient == 1) { 269 + level().playLocalSound(this, DuckSounds.DUCK_AMBIENT, SoundSource.NEUTRAL, 1.0f, 1.0f); 270 + } 271 + } 272 + 273 + @Override 274 + public void onSyncedDataUpdated(@NotNull EntityDataAccessor<?> key) { 275 + if (!this.level().isClientSide()) { 276 + super.onSyncedDataUpdated(key); 277 + } 278 + } 279 + 280 + @Override 281 + public @NotNull Packet<@NotNull ClientGamePacketListener> getAddEntityPacket(@NotNull ServerEntity serverEntity) { 282 + if (this.level().isClientSide()) { 283 + return new ClientboundAddEntityPacket(this, serverEntity); 284 + } else { 285 + return super.getAddEntityPacket(serverEntity); 286 + } 287 + } 288 + 289 + @Override 290 + public void addAdditionalSaveData(@NotNull ValueOutput output) { 291 + super.addAdditionalSaveData(output); 292 + output.putBoolean("isServerEntity", true); 293 + output.putInt("variant", this.entityData.get(DUCK_SKIN)); 294 + } 295 + 296 + @Override 297 + public void readAdditionalSaveData(@NotNull ValueInput input) { 298 + super.readAdditionalSaveData(input); 299 + this.setServerEntity(input.getBooleanOr("isServerEntity", true)); 300 + this.entityData.set(DUCK_SKIN, input.getIntOr("variant", 1)); 301 + 302 + } 303 + }
+43
src/main/java/com/jeff/duck/DuckInitializer.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.fabricmc.api.ModInitializer; 4 + import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; 5 + import net.minecraft.core.Registry; 6 + import net.minecraft.core.registries.BuiltInRegistries; 7 + import net.minecraft.core.registries.Registries; 8 + import net.minecraft.resources.Identifier; 9 + import net.minecraft.resources.ResourceKey; 10 + import net.minecraft.world.entity.EntityType; 11 + import net.minecraft.world.entity.MobCategory; 12 + import org.jetbrains.annotations.NotNull; 13 + import org.slf4j.Logger; 14 + import org.slf4j.LoggerFactory; 15 + 16 + public class DuckInitializer implements ModInitializer { 17 + public static final String MOD_ID = "duck"; 18 + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); 19 + 20 + public static final ResourceKey<@NotNull EntityType<?>> DUCK_KEY = 21 + ResourceKey.create(Registries.ENTITY_TYPE, Identifier.fromNamespaceAndPath(MOD_ID, "duck")); 22 + 23 + 24 + public static final EntityType<@NotNull Duck> DUCK = Registry.register( 25 + BuiltInRegistries.ENTITY_TYPE, 26 + Identifier.fromNamespaceAndPath(MOD_ID, "duck"), 27 + EntityType.Builder.of(Duck::new, MobCategory.CREATURE) 28 + .sized(1f, 1f) 29 + .eyeHeight(1) 30 + .build(DUCK_KEY)); 31 + 32 + @Override 33 + public void onInitialize() { 34 + 35 + FabricDefaultAttributeRegistry.register(DUCK, Duck.createAttributes().build()); 36 + 37 + DuckSounds.initialize(); 38 + 39 + DuckSpawns.addDuckSpawn(); 40 + 41 + LOGGER.info("quack"); 42 + } 43 + }
+18
src/main/java/com/jeff/duck/DuckSounds.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.minecraft.core.Registry; 4 + import net.minecraft.core.registries.BuiltInRegistries; 5 + import net.minecraft.resources.Identifier; 6 + import net.minecraft.sounds.SoundEvent; 7 + 8 + public class DuckSounds { 9 + public static final SoundEvent DUCK_AMBIENT = registerSound(); 10 + 11 + private static SoundEvent registerSound() { 12 + Identifier identifier = Identifier.fromNamespaceAndPath(DuckInitializer.MOD_ID, "duck_ambient"); 13 + return Registry.register(BuiltInRegistries.SOUND_EVENT, identifier, SoundEvent.createVariableRangeEvent(identifier)); 14 + } 15 + 16 + public static void initialize() { 17 + } 18 + }
+19
src/main/java/com/jeff/duck/DuckSpawns.java
··· 1 + package com.jeff.duck; 2 + 3 + import net.fabricmc.fabric.api.biome.v1.BiomeModifications; 4 + import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; 5 + import net.minecraft.world.entity.MobCategory; 6 + import net.minecraft.world.entity.SpawnPlacementTypes; 7 + import net.minecraft.world.entity.SpawnPlacements; 8 + import net.minecraft.world.entity.animal.Animal; 9 + import net.minecraft.world.level.biome.Biomes; 10 + import net.minecraft.world.level.levelgen.Heightmap; 11 + 12 + public class DuckSpawns { 13 + public static void addDuckSpawn() { 14 + BiomeModifications.addSpawn(BiomeSelectors.includeByKey(Biomes.PLAINS, Biomes.CHERRY_GROVE, Biomes.BEACH, Biomes.DARK_FOREST, Biomes.FOREST, Biomes.SPARSE_JUNGLE), 15 + MobCategory.CREATURE, DuckInitializer.DUCK, 100, 2, 7); 16 + SpawnPlacements.register(DuckInitializer.DUCK, SpawnPlacementTypes.ON_GROUND, 17 + Heightmap.Types.WORLD_SURFACE, Animal::checkAnimalSpawnRules); 18 + } 19 + }
+15
src/main/java/com/jeff/duck/mixin/ExampleMixin.java
··· 1 + package com.jeff.duck.mixin; 2 + 3 + import net.minecraft.server.MinecraftServer; 4 + import org.spongepowered.asm.mixin.Mixin; 5 + import org.spongepowered.asm.mixin.injection.At; 6 + import org.spongepowered.asm.mixin.injection.Inject; 7 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 8 + 9 + @Mixin(MinecraftServer.class) 10 + public class ExampleMixin { 11 + @Inject(at = @At("HEAD"), method = "loadLevel") 12 + private void init(CallbackInfo info) { 13 + // This code is injected into the start of MinecraftServer.loadLevel()V 14 + } 15 + }
src/main/resources/assets/duck/icon.png

This is a binary file and will not be displayed.

+6
src/main/resources/assets/duck/sounds.json
··· 1 + { 2 + "duck_ambient": { 3 + "subtitle": "sound.duck.duck_ambient", 4 + "sounds": ["duck:duck_ambient"] 5 + } 6 + }
src/main/resources/assets/duck/sounds/duck_ambient.ogg

This is a binary file and will not be displayed.

src/main/resources/assets/duck/textures/entity/mallard_male.png

This is a binary file and will not be displayed.

src/main/resources/assets/duck/textures/entity/pekin.png

This is a binary file and will not be displayed.

+14
src/main/resources/duck.mixins.json
··· 1 + { 2 + "required": true, 3 + "package": "com.jeff.duck.mixin", 4 + "compatibilityLevel": "JAVA_21", 5 + "mixins": [ 6 + "ExampleMixin" 7 + ], 8 + "injectors": { 9 + "defaultRequire": 1 10 + }, 11 + "overwrites": { 12 + "requireAnnotations": true 13 + } 14 + }
+41
src/main/resources/fabric.mod.json
··· 1 + { 2 + "schemaVersion": 1, 3 + "id": "duck", 4 + "version": "${version}", 5 + "name": "Duck Mod", 6 + "description": "Adds a cute duck into your game to follow you around! /duck on or /duck off to toggle.", 7 + "authors": [ 8 + "The Pets Team", 9 + "downloadableduck" 10 + ], 11 + "contact": { 12 + "homepage": "https://fabricmc.net/", 13 + "sources": "https://github.com/FabricMC/fabric-example-mod" 14 + }, 15 + "license": "CC0-1.0", 16 + "icon": "assets/duck/icon.png", 17 + "environment": "*", 18 + "entrypoints": { 19 + "main": [ 20 + "com.jeff.duck.DuckInitializer" 21 + ], 22 + "client": [ 23 + "com.jeff.duck.DuckClient", 24 + "com.jeff.duck.DuckPet" 25 + ] 26 + }, 27 + "mixins": [ 28 + "duck.mixins.json", 29 + { 30 + "config": "duck.client.mixins.json", 31 + "environment": "client" 32 + } 33 + ], 34 + "depends": { 35 + "fabricloader": ">=0.18.4", 36 + "minecraft": "~1.21.11", 37 + "java": ">=21", 38 + "cloth-config": "*", 39 + "fabric-api": "*" 40 + } 41 + }