├── .gitignore ├── LICENSE ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── dependencies.kt │ └── versions.kt ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── minecraftapi-core ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── pw │ └── stamina │ └── minecraftapi │ ├── MinecraftApi.kt │ ├── MinecraftApiAdapter.kt │ ├── client │ ├── Minecraft.kt │ ├── PlayerController.kt │ └── ScaledResolution.kt │ ├── entity │ ├── Entity.kt │ ├── animal │ │ ├── Animal.kt │ │ ├── Horse.kt │ │ ├── Tamable.kt │ │ └── Wolf.kt │ ├── item │ │ ├── Boat.kt │ │ └── Minecart.kt │ ├── living │ │ ├── ClientPlayer.kt │ │ ├── Golem.kt │ │ ├── IronGolem.kt │ │ ├── Living.kt │ │ └── Player.kt │ └── monster │ │ ├── Enderman.kt │ │ ├── Monster.kt │ │ └── ZombiePigman.kt │ ├── item │ ├── Item.kt │ ├── ItemBlock.kt │ ├── ItemRegistry.kt │ ├── ItemStack.kt │ └── Items.kt │ ├── module │ ├── MinecraftApiModule.kt │ └── MinecraftApiModuleLoader.kt │ ├── network │ ├── AbstractPacketAdapter.kt │ ├── NetHandlerPlayClient.kt │ ├── NetworkManager.kt │ ├── Packet.kt │ ├── PacketAdapter.kt │ ├── PacketAdapters.kt │ ├── incoming │ │ ├── ChatPacket.kt │ │ ├── ExplosionPacket.kt │ │ ├── IncomingPacketAdapters.kt │ │ └── VelocityPacket.kt │ └── outgoing │ │ ├── ChatPacket.kt │ │ ├── LookPacket.kt │ │ ├── OnGroundPacket.kt │ │ ├── OutgoingPacketAdapters.kt │ │ ├── PositionLookPacket.kt │ │ └── PositionPacket.kt │ ├── render │ ├── FontRenderer.kt │ └── RenderManager.kt │ ├── util │ ├── BoundingBox.kt │ ├── BoundingBoxBuilder.kt │ ├── CurrentPreviousPair.kt │ ├── Hand.kt │ ├── Position.kt │ ├── ResourceLocation.kt │ └── Rotation.kt │ └── world │ └── World.kt ├── minecraftapi-events ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── pw │ └── stamina │ └── minecraftapi │ └── event │ ├── input │ └── InputEvents.kt │ ├── network │ └── PacketEvents.kt │ ├── player │ └── MotionUpdateEvent.kt │ └── render │ ├── CapeRenderEvent.kt │ ├── HandRenderEvent.kt │ ├── LightmapUpdateEvent.kt │ ├── ScreenRenderEvent.kt │ └── WorldRenderEvent.kt ├── minecraftapi-tweaker ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── pw │ └── stamina │ └── minecraftapi │ └── tweak │ ├── MinecraftApiDevelopmentTweaker.kt │ └── MinecraftApiProductionTweaker.kt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | ### Java 2 | 3 | *.class 4 | *.log 5 | *.jar 6 | *.war 7 | *.ear 8 | *.zip 9 | *.tar.gz 10 | *.rar 11 | hs_err_pid* 12 | 13 | ### Gradle 14 | 15 | .gradle 16 | build/ 17 | !gradle-wrapper.jar 18 | 19 | ### JetBrains 20 | 21 | .idea/ 22 | *.iml 23 | *.iws 24 | *ipr 25 | out/ 26 | classes/ 27 | 28 | ### ForgeGradle 29 | run/ 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Stamina Development 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 26 | 27 | plugins { 28 | kotlin("jvm") version Versions.kotlin apply false 29 | } 30 | 31 | subprojects { 32 | group = "pw.stamina.minecraftapi" 33 | 34 | repositories { 35 | mavenCentral() 36 | mavenLocal() 37 | } 38 | 39 | tasks.withType { 40 | kotlinOptions.jvmTarget = "1.8" 41 | } 42 | } 43 | 44 | /* 45 | if (project.name != 'minecraftapi-core') { 46 | dependencies { 47 | compile project(':minecraftapi-core') 48 | } 49 | } 50 | */ -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/dependencies.kt: -------------------------------------------------------------------------------- 1 | 2 | import Dependencies.minecraftApiCore 3 | import org.gradle.api.Project 4 | import org.gradle.kotlin.dsl.dependencies 5 | import org.gradle.kotlin.dsl.kotlin 6 | 7 | object Dependencies { 8 | const val minecraftApiCore = ":minecraftapi-core" 9 | 10 | const val launchwrapper = "net.minecraft:launchwrapper:${Versions.launchwrapper}" 11 | const val mixin = "org.spongepowered:mixin:${Versions.mixin}" 12 | } 13 | 14 | fun Project.applyStandardDependencies() { 15 | 16 | dependencies { 17 | "implementation"(kotlin("stdlib-jdk8")) 18 | 19 | val minecraftApiCoreProject = project(minecraftApiCore) 20 | 21 | if (project != minecraftApiCoreProject) { 22 | "implementation"(minecraftApiCoreProject) 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/versions.kt: -------------------------------------------------------------------------------- 1 | object Versions { 2 | const val kotlin = "1.2.60" 3 | 4 | const val launchwrapper = "1.11" 5 | const val mixin = "0.7.4-SNAPSHOT" 6 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/staminadevelopment/minecraftapi/b2e94e8f4674602fe1995a5e319be3f426ece4a0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /minecraftapi-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | plugins { 26 | kotlin("jvm") 27 | } 28 | 29 | version = "1.0.0-SNAPSHOT" 30 | 31 | applyStandardDependencies() 32 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/MinecraftApi.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi 26 | 27 | import pw.stamina.minecraftapi.module.MinecraftApiModule 28 | import pw.stamina.minecraftapi.module.MinecraftApiModuleLoader 29 | import java.util.concurrent.atomic.AtomicBoolean 30 | 31 | object MinecraftApi { 32 | private val BOOTSTRAPPED = AtomicBoolean() 33 | 34 | private lateinit var adapter: MinecraftApiAdapter 35 | private lateinit var module: MinecraftApiModule 36 | 37 | fun bootstrap(adapter: MinecraftApiAdapter) { 38 | if (!BOOTSTRAPPED.compareAndSet(false, true)) { 39 | throw Error("MinecraftApi has already been bootstrapped") 40 | } 41 | 42 | this.adapter = adapter 43 | 44 | module = MinecraftApiModuleLoader.loadModule() 45 | module.bootstrap(adapter) 46 | } 47 | 48 | fun getAdapter() = adapter 49 | 50 | fun bootstrapModule() { 51 | module.bootstrap(adapter) 52 | } 53 | 54 | fun emitEvent(event: T) { 55 | module.consumeEvent(event) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/MinecraftApiAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi 26 | 27 | import pw.stamina.minecraftapi.client.Minecraft 28 | import pw.stamina.minecraftapi.item.ItemRegistry 29 | import pw.stamina.minecraftapi.network.incoming.IncomingPacketAdapters 30 | import pw.stamina.minecraftapi.network.outgoing.OutgoingPacketAdapters 31 | import pw.stamina.minecraftapi.util.BoundingBox 32 | import pw.stamina.minecraftapi.util.Hand 33 | import pw.stamina.minecraftapi.util.ResourceLocation 34 | 35 | interface MinecraftApiAdapter { 36 | 37 | val minecraft: Minecraft 38 | 39 | val boundingBoxFactory: BoundingBox.Factory 40 | val handAdapter: Hand.Adapter 41 | val resourceLocationFactory: ResourceLocation.Factory 42 | 43 | val incomingPacketAdapters: IncomingPacketAdapters 44 | val outingPacketAdapters: OutgoingPacketAdapters 45 | 46 | val itemRegistry: ItemRegistry 47 | } 48 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/client/Minecraft.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.client 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | import pw.stamina.minecraftapi.entity.living.ClientPlayer 29 | import pw.stamina.minecraftapi.render.FontRenderer 30 | import pw.stamina.minecraftapi.render.RenderManager 31 | import pw.stamina.minecraftapi.world.World 32 | 33 | interface Minecraft { 34 | 35 | val player: ClientPlayer 36 | 37 | val world: World 38 | 39 | val playerController: PlayerController 40 | 41 | val fontRenderer: FontRenderer 42 | 43 | val renderManager: RenderManager 44 | 45 | val scaledResolution: ScaledResolution 46 | 47 | val displayWidth: Int 48 | 49 | val displayHeight: Int 50 | 51 | var rightClickDelay: Int 52 | 53 | // TODO: Add ChatComponent based alternative when that API has been implemented 54 | fun printChatMessage(message: String) 55 | 56 | companion object { 57 | 58 | val minecraft: Minecraft 59 | get() = MinecraftApi.getAdapter().minecraft 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/client/PlayerController.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.client 26 | 27 | import pw.stamina.minecraftapi.entity.Entity 28 | import pw.stamina.minecraftapi.entity.living.Player 29 | 30 | interface PlayerController { 31 | 32 | fun attackEntity(attacker: Player, target: Entity) 33 | } 34 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/client/ScaledResolution.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.client 26 | 27 | interface ScaledResolution { 28 | 29 | val scaledWidth: Int 30 | 31 | val scaledHeight: Int 32 | 33 | val scaledWidthAsDouble: Double 34 | 35 | val scaledHeightAsDouble: Double 36 | 37 | val scaleFactor: Int 38 | } 39 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/Entity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity 26 | 27 | import pw.stamina.minecraftapi.util.BoundingBox 28 | import pw.stamina.minecraftapi.util.Rotation 29 | import java.util.* 30 | 31 | interface Entity { 32 | 33 | val entityId: Int 34 | val uniqueId: UUID 35 | 36 | val riddenByEntities: List 37 | 38 | var rotation: Rotation 39 | get() = Rotation(yaw, pitch) 40 | set(rotation) { 41 | yaw = rotation.yaw 42 | pitch = rotation.pitch 43 | } 44 | 45 | val boundingBox: BoundingBox 46 | 47 | val isDead: Boolean 48 | 49 | val eyeHeight: Float 50 | 51 | var isNoClipping: Boolean 52 | 53 | val ticksExisted: Int 54 | 55 | var posX: Double 56 | var posY: Double 57 | var posZ: Double 58 | 59 | val prevPosX: Double 60 | val prevPosY: Double 61 | val prevPosZ: Double 62 | 63 | var motionX: Double 64 | var motionY: Double 65 | var motionZ: Double 66 | 67 | var yaw: Float 68 | var pitch: Float 69 | 70 | var onGround: Boolean 71 | 72 | val width: Float 73 | val height: Float 74 | 75 | fun getDistanceToEntity(other: Entity): Float 76 | } 77 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/animal/Animal.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.animal 26 | 27 | import pw.stamina.minecraftapi.entity.living.Living 28 | 29 | interface Animal : Living 30 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/animal/Horse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.animal 26 | 27 | interface Horse : Animal 28 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/animal/Tamable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.animal 26 | 27 | import pw.stamina.minecraftapi.entity.living.Living 28 | import java.util.* 29 | 30 | interface Tamable : Animal { 31 | 32 | val isTamed: Boolean 33 | 34 | val owner: Living? 35 | 36 | val ownerId: UUID? 37 | 38 | val ownerIdAsString: String? 39 | 40 | fun isOwner(entity: Living): Boolean 41 | } 42 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/animal/Wolf.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.animal 26 | 27 | interface Wolf : Tamable { 28 | 29 | val isAngry: Boolean 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/item/Boat.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.item 26 | 27 | import pw.stamina.minecraftapi.entity.Entity 28 | 29 | interface Boat : Entity 30 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/item/Minecart.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.item 26 | 27 | import pw.stamina.minecraftapi.entity.Entity 28 | 29 | interface Minecart : Entity 30 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/living/ClientPlayer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.living 26 | 27 | import pw.stamina.minecraftapi.network.NetHandlerPlayClient 28 | import pw.stamina.minecraftapi.util.Hand 29 | 30 | interface ClientPlayer : Player { 31 | 32 | val sendQueue: NetHandlerPlayClient 33 | 34 | fun swingArm(hand: Hand? = null) 35 | } 36 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/living/Golem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.living 26 | 27 | interface Golem : Living 28 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/living/IronGolem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.living 26 | 27 | interface IronGolem : Golem { 28 | 29 | val isPlayerCreated: Boolean 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/living/Living.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.living 26 | 27 | import pw.stamina.minecraftapi.entity.Entity 28 | 29 | interface Living : Entity { 30 | 31 | val health: Float 32 | } 33 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/living/Player.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.living 26 | 27 | import pw.stamina.minecraftapi.item.ItemStack 28 | import pw.stamina.minecraftapi.util.Hand 29 | 30 | interface Player : Living { 31 | 32 | fun getHeldItem(hand: Hand? = null): ItemStack 33 | } 34 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/monster/Enderman.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.monster 26 | 27 | interface Enderman : Monster { 28 | 29 | val isScreaming: Boolean 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/monster/Monster.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.monster 26 | 27 | import pw.stamina.minecraftapi.entity.living.Living 28 | 29 | interface Monster : Living 30 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/entity/monster/ZombiePigman.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.entity.monster 26 | 27 | interface ZombiePigman : Monster { 28 | 29 | val isAngry: Boolean 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/item/Item.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.item 26 | 27 | interface Item 28 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/item/ItemBlock.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.item 26 | 27 | interface ItemBlock : Item 28 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/item/ItemRegistry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.item 26 | 27 | interface ItemRegistry { 28 | 29 | fun getRegisteredItemOrAir(name: String): Item 30 | 31 | fun getRegisteredItem(name: String): Item? 32 | } 33 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/item/ItemStack.kt: -------------------------------------------------------------------------------- 1 | package pw.stamina.minecraftapi.item 2 | 3 | interface ItemStack { 4 | 5 | val item: Item 6 | } -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/item/Items.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.item 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | 29 | object Items { 30 | 31 | val AIR: Item 32 | val IRON_SHOVEL: Item 33 | val IRON_PICKAXE: Item 34 | val IRON_AXE: Item 35 | val FLINT_AND_STEEL: Item 36 | val APPLE: Item 37 | val BOW: Item 38 | val ARROW: Item 39 | val SPECTRAL_ARROW: Item 40 | val TIPPED_ARROW: Item 41 | val COAL: Item 42 | val DIAMOND: Item 43 | val IRON_INGOT: Item 44 | val GOLD_INGOT: Item 45 | val IRON_SWORD: Item 46 | val WOODEN_SWORD: Item 47 | val WOODEN_SHOVEL: Item 48 | val WOODEN_PICKAXE: Item 49 | val WOODEN_AXE: Item 50 | val STONE_SWORD: Item 51 | val STONE_SHOVEL: Item 52 | val STONE_PICKAXE: Item 53 | val STONE_AXE: Item 54 | val DIAMOND_SWORD: Item 55 | val DIAMOND_SHOVEL: Item 56 | val DIAMOND_PICKAXE: Item 57 | val DIAMOND_AXE: Item 58 | val STICK: Item 59 | val BOWL: Item 60 | val MUSHROOM_STEW: Item 61 | val GOLDEN_SWORD: Item 62 | val GOLDEN_SHOVEL: Item 63 | val GOLDEN_PICKAXE: Item 64 | val GOLDEN_AXE: Item 65 | val STRING: Item 66 | val FEATHER: Item 67 | val GUNPOWDER: Item 68 | val WOODEN_HOE: Item 69 | val STONE_HOE: Item 70 | val IRON_HOE: Item 71 | val DIAMOND_HOE: Item 72 | val GOLDEN_HOE: Item 73 | val WHEAT_SEEDS: Item 74 | val WHEAT: Item 75 | val BREAD: Item 76 | val LEATHER_HELMET: Item 77 | val LEATHER_CHESTPLATE: Item 78 | val LEATHER_LEGGINGS: Item 79 | val LEATHER_BOOTS: Item 80 | val CHAINMAIL_HELMET: Item 81 | val CHAINMAIL_CHESTPLATE: Item 82 | val CHAINMAIL_LEGGINGS: Item 83 | val CHAINMAIL_BOOTS: Item 84 | val IRON_HELMET: Item 85 | val IRON_CHESTPLATE: Item 86 | val IRON_LEGGINGS: Item 87 | val IRON_BOOTS: Item 88 | val DIAMOND_HELMET: Item 89 | val DIAMOND_CHESTPLATE: Item 90 | val DIAMOND_LEGGINGS: Item 91 | val DIAMOND_BOOTS: Item 92 | val GOLDEN_HELMET: Item 93 | val GOLDEN_CHESTPLATE: Item 94 | val GOLDEN_LEGGINGS: Item 95 | val GOLDEN_BOOTS: Item 96 | val FLINT: Item 97 | val PORKCHOP: Item 98 | val COOKED_PORKCHOP: Item 99 | val PAINTING: Item 100 | val GOLDEN_APPLE: Item 101 | val SIGN: Item 102 | val OAK_DOOR: Item 103 | val SPRUCE_DOOR: Item 104 | val BIRCH_DOOR: Item 105 | val JUNGLE_DOOR: Item 106 | val ACACIA_DOOR: Item 107 | val DARK_OAK_DOOR: Item 108 | val BUCKET: Item 109 | val WATER_BUCKET: Item 110 | val LAVA_BUCKET: Item 111 | val MINECART: Item 112 | val SADDLE: Item 113 | val IRON_DOOR: Item 114 | val REDSTONE: Item 115 | val SNOWBALL: Item 116 | val BOAT: Item 117 | val SPRUCE_BOAT: Item 118 | val BIRCH_BOAT: Item 119 | val JUNGLE_BOAT: Item 120 | val ACACIA_BOAT: Item 121 | val DARK_OAK_BOAT: Item 122 | val LEATHER: Item 123 | val MILK_BUCKET: Item 124 | val BRICK: Item 125 | val CLAY_BALL: Item 126 | val REEDS: Item 127 | val PAPER: Item 128 | val BOOK: Item 129 | val SLIME_BALL: Item 130 | val CHEST_MINECART: Item 131 | val FURNACE_MINECART: Item 132 | val EGG: Item 133 | val COMPASS: Item 134 | val FISHING_ROD: Item 135 | val CLOCK: Item 136 | val GLOWSTONE_DUST: Item 137 | val FISH: Item 138 | val COOKED_FISH: Item 139 | val DYE: Item 140 | val BONE: Item 141 | val SUGAR: Item 142 | val CAKE: Item 143 | val BED: Item 144 | val REPEATER: Item 145 | val COOKIE: Item 146 | val FILLED_MAP: Item 147 | val SHEARS: Item 148 | val MELON: Item 149 | val PUMPKIN_SEEDS: Item 150 | val MELON_SEEDS: Item 151 | val BEEF: Item 152 | val COOKED_BEEF: Item 153 | val CHICKEN: Item 154 | val COOKED_CHICKEN: Item 155 | val MUTTON: Item 156 | val COOKED_MUTTON: Item 157 | val RABBIT: Item 158 | val COOKED_RABBIT: Item 159 | val RABBIT_STEW: Item 160 | val RABBIT_FOOT: Item 161 | val RABBIT_HIDE: Item 162 | val ROTTEN_FLESH: Item 163 | val ENDER_PEARL: Item 164 | val BLAZE_ROD: Item 165 | val GHAST_TEAR: Item 166 | val GOLD_NUGGET: Item 167 | val NETHER_WART: Item 168 | val POTIONITEM: Item 169 | val SPLASH_POTION: Item 170 | val LINGERING_POTION: Item 171 | val GLASS_BOTTLE: Item 172 | val DRAGON_BREATH: Item 173 | val SPIDER_EYE: Item 174 | val FERMENTED_SPIDER_EYE: Item 175 | val BLAZE_POWDER: Item 176 | val MAGMA_CREAM: Item 177 | val BREWING_STAND: Item 178 | val CAULDRON: Item 179 | val ENDER_EYE: Item 180 | val SPECKLED_MELON: Item 181 | val SPAWN_EGG: Item 182 | val EXPERIENCE_BOTTLE: Item 183 | val FIRE_CHARGE: Item 184 | val WRITABLE_BOOK: Item 185 | val WRITTEN_BOOK: Item 186 | val EMERALD: Item 187 | val ITEM_FRAME: Item 188 | val FLOWER_POT: Item 189 | val CARROT: Item 190 | val POTATO: Item 191 | val BAKED_POTATO: Item 192 | val POISONOUS_POTATO: Item 193 | val MAP: Item 194 | val GOLDEN_CARROT: Item 195 | val SKULL: Item 196 | val CARROT_ON_A_STICK: Item 197 | val NETHER_STAR: Item 198 | val PUMPKIN_PIE: Item 199 | val FIREWORKS: Item 200 | val FIREWORK_CHARGE: Item 201 | val ENCHANTED_BOOK: Item 202 | val COMPARATOR: Item 203 | val NETHERBRICK: Item 204 | val QUARTZ: Item 205 | val TNT_MINECART: Item 206 | val HOPPER_MINECART: Item 207 | val ARMOR_STAND: Item 208 | val IRON_HORSE_ARMOR: Item 209 | val GOLDEN_HORSE_ARMOR: Item 210 | val DIAMOND_HORSE_ARMOR: Item 211 | val LEAD: Item 212 | val NAME_TAG: Item 213 | val COMMAND_BLOCK_MINECART: Item 214 | val RECORD_13: Item 215 | val RECORD_CAT: Item 216 | val RECORD_BLOCKS: Item 217 | val RECORD_CHIRP: Item 218 | val RECORD_FAR: Item 219 | val RECORD_MALL: Item 220 | val RECORD_MELLOHI: Item 221 | val RECORD_STAL: Item 222 | val RECORD_STRAD: Item 223 | val RECORD_WARD: Item 224 | val RECORD_11: Item 225 | val RECORD_WAIT: Item 226 | val PRISMARINE_SHARD: Item 227 | val PRISMARINE_CRYSTALS: Item 228 | val BANNER: Item 229 | val END_CRYSTAL: Item 230 | val SHIELD: Item 231 | val ELYTRA: Item 232 | val CHORUS_FRUIT: Item 233 | val CHORUS_FRUIT_POPPED: Item 234 | val BEETROOT_SEEDS: Item 235 | val BEETROOT: Item 236 | val BEETROOT_SOUP: Item 237 | val TOTEM_OF_UNDYING: Item 238 | val SHULKER_SHELL: Item 239 | val IRON_NUGGET: Item 240 | val KNOWLEDGE_BOOK: Item 241 | 242 | init { 243 | val registry = MinecraftApi.getAdapter().itemRegistry 244 | 245 | AIR = registry.getRegisteredItemOrAir("air") 246 | IRON_SHOVEL = registry.getRegisteredItemOrAir("iron_shovel") 247 | IRON_PICKAXE = registry.getRegisteredItemOrAir("iron_pickaxe") 248 | IRON_AXE = registry.getRegisteredItemOrAir("iron_axe") 249 | FLINT_AND_STEEL = registry.getRegisteredItemOrAir("flint_and_steel") 250 | APPLE = registry.getRegisteredItemOrAir("apple") 251 | BOW = registry.getRegisteredItemOrAir("bow") 252 | ARROW = registry.getRegisteredItemOrAir("arrow") 253 | SPECTRAL_ARROW = registry.getRegisteredItemOrAir("spectral_arrow") 254 | TIPPED_ARROW = registry.getRegisteredItemOrAir("tipped_arrow") 255 | COAL = registry.getRegisteredItemOrAir("coal") 256 | DIAMOND = registry.getRegisteredItemOrAir("diamond") 257 | IRON_INGOT = registry.getRegisteredItemOrAir("iron_ingot") 258 | GOLD_INGOT = registry.getRegisteredItemOrAir("gold_ingot") 259 | IRON_SWORD = registry.getRegisteredItemOrAir("iron_sword") 260 | WOODEN_SWORD = registry.getRegisteredItemOrAir("wooden_sword") 261 | WOODEN_SHOVEL = registry.getRegisteredItemOrAir("wooden_shovel") 262 | WOODEN_PICKAXE = registry.getRegisteredItemOrAir("wooden_pickaxe") 263 | WOODEN_AXE = registry.getRegisteredItemOrAir("wooden_axe") 264 | STONE_SWORD = registry.getRegisteredItemOrAir("stone_sword") 265 | STONE_SHOVEL = registry.getRegisteredItemOrAir("stone_shovel") 266 | STONE_PICKAXE = registry.getRegisteredItemOrAir("stone_pickaxe") 267 | STONE_AXE = registry.getRegisteredItemOrAir("stone_axe") 268 | DIAMOND_SWORD = registry.getRegisteredItemOrAir("diamond_sword") 269 | DIAMOND_SHOVEL = registry.getRegisteredItemOrAir("diamond_shovel") 270 | DIAMOND_PICKAXE = registry.getRegisteredItemOrAir("diamond_pickaxe") 271 | DIAMOND_AXE = registry.getRegisteredItemOrAir("diamond_axe") 272 | STICK = registry.getRegisteredItemOrAir("stick") 273 | BOWL = registry.getRegisteredItemOrAir("bowl") 274 | MUSHROOM_STEW = registry.getRegisteredItemOrAir("mushroom_stew") 275 | GOLDEN_SWORD = registry.getRegisteredItemOrAir("golden_sword") 276 | GOLDEN_SHOVEL = registry.getRegisteredItemOrAir("golden_shovel") 277 | GOLDEN_PICKAXE = registry.getRegisteredItemOrAir("golden_pickaxe") 278 | GOLDEN_AXE = registry.getRegisteredItemOrAir("golden_axe") 279 | STRING = registry.getRegisteredItemOrAir("string") 280 | FEATHER = registry.getRegisteredItemOrAir("feather") 281 | GUNPOWDER = registry.getRegisteredItemOrAir("gunpowder") 282 | WOODEN_HOE = registry.getRegisteredItemOrAir("wooden_hoe") 283 | STONE_HOE = registry.getRegisteredItemOrAir("stone_hoe") 284 | IRON_HOE = registry.getRegisteredItemOrAir("iron_hoe") 285 | DIAMOND_HOE = registry.getRegisteredItemOrAir("diamond_hoe") 286 | GOLDEN_HOE = registry.getRegisteredItemOrAir("golden_hoe") 287 | WHEAT_SEEDS = registry.getRegisteredItemOrAir("wheat_seeds") 288 | WHEAT = registry.getRegisteredItemOrAir("wheat") 289 | BREAD = registry.getRegisteredItemOrAir("bread") 290 | LEATHER_HELMET = registry.getRegisteredItemOrAir("leather_helmet") 291 | LEATHER_CHESTPLATE = registry.getRegisteredItemOrAir("leather_chestplate") 292 | LEATHER_LEGGINGS = registry.getRegisteredItemOrAir("leather_leggings") 293 | LEATHER_BOOTS = registry.getRegisteredItemOrAir("leather_boots") 294 | CHAINMAIL_HELMET = registry.getRegisteredItemOrAir("chainmail_helmet") 295 | CHAINMAIL_CHESTPLATE = registry.getRegisteredItemOrAir("chainmail_chestplate") 296 | CHAINMAIL_LEGGINGS = registry.getRegisteredItemOrAir("chainmail_leggings") 297 | CHAINMAIL_BOOTS = registry.getRegisteredItemOrAir("chainmail_boots") 298 | IRON_HELMET = registry.getRegisteredItemOrAir("iron_helmet") 299 | IRON_CHESTPLATE = registry.getRegisteredItemOrAir("iron_chestplate") 300 | IRON_LEGGINGS = registry.getRegisteredItemOrAir("iron_leggings") 301 | IRON_BOOTS = registry.getRegisteredItemOrAir("iron_boots") 302 | DIAMOND_HELMET = registry.getRegisteredItemOrAir("diamond_helmet") 303 | DIAMOND_CHESTPLATE = registry.getRegisteredItemOrAir("diamond_chestplate") 304 | DIAMOND_LEGGINGS = registry.getRegisteredItemOrAir("diamond_leggings") 305 | DIAMOND_BOOTS = registry.getRegisteredItemOrAir("diamond_boots") 306 | GOLDEN_HELMET = registry.getRegisteredItemOrAir("golden_helmet") 307 | GOLDEN_CHESTPLATE = registry.getRegisteredItemOrAir("golden_chestplate") 308 | GOLDEN_LEGGINGS = registry.getRegisteredItemOrAir("golden_leggings") 309 | GOLDEN_BOOTS = registry.getRegisteredItemOrAir("golden_boots") 310 | FLINT = registry.getRegisteredItemOrAir("flint") 311 | PORKCHOP = registry.getRegisteredItemOrAir("porkchop") 312 | COOKED_PORKCHOP = registry.getRegisteredItemOrAir("cooked_porkchop") 313 | PAINTING = registry.getRegisteredItemOrAir("painting") 314 | GOLDEN_APPLE = registry.getRegisteredItemOrAir("golden_apple") 315 | SIGN = registry.getRegisteredItemOrAir("sign") 316 | OAK_DOOR = registry.getRegisteredItemOrAir("wooden_door") 317 | SPRUCE_DOOR = registry.getRegisteredItemOrAir("spruce_door") 318 | BIRCH_DOOR = registry.getRegisteredItemOrAir("birch_door") 319 | JUNGLE_DOOR = registry.getRegisteredItemOrAir("jungle_door") 320 | ACACIA_DOOR = registry.getRegisteredItemOrAir("acacia_door") 321 | DARK_OAK_DOOR = registry.getRegisteredItemOrAir("dark_oak_door") 322 | BUCKET = registry.getRegisteredItemOrAir("bucket") 323 | WATER_BUCKET = registry.getRegisteredItemOrAir("water_bucket") 324 | LAVA_BUCKET = registry.getRegisteredItemOrAir("lava_bucket") 325 | MINECART = registry.getRegisteredItemOrAir("minecart") 326 | SADDLE = registry.getRegisteredItemOrAir("saddle") 327 | IRON_DOOR = registry.getRegisteredItemOrAir("iron_door") 328 | REDSTONE = registry.getRegisteredItemOrAir("redstone") 329 | SNOWBALL = registry.getRegisteredItemOrAir("snowball") 330 | BOAT = registry.getRegisteredItemOrAir("boat") 331 | SPRUCE_BOAT = registry.getRegisteredItemOrAir("spruce_boat") 332 | BIRCH_BOAT = registry.getRegisteredItemOrAir("birch_boat") 333 | JUNGLE_BOAT = registry.getRegisteredItemOrAir("jungle_boat") 334 | ACACIA_BOAT = registry.getRegisteredItemOrAir("acacia_boat") 335 | DARK_OAK_BOAT = registry.getRegisteredItemOrAir("dark_oak_boat") 336 | LEATHER = registry.getRegisteredItemOrAir("leather") 337 | MILK_BUCKET = registry.getRegisteredItemOrAir("milk_bucket") 338 | BRICK = registry.getRegisteredItemOrAir("brick") 339 | CLAY_BALL = registry.getRegisteredItemOrAir("clay_ball") 340 | REEDS = registry.getRegisteredItemOrAir("reeds") 341 | PAPER = registry.getRegisteredItemOrAir("paper") 342 | BOOK = registry.getRegisteredItemOrAir("book") 343 | SLIME_BALL = registry.getRegisteredItemOrAir("slime_ball") 344 | CHEST_MINECART = registry.getRegisteredItemOrAir("chest_minecart") 345 | FURNACE_MINECART = registry.getRegisteredItemOrAir("furnace_minecart") 346 | EGG = registry.getRegisteredItemOrAir("egg") 347 | COMPASS = registry.getRegisteredItemOrAir("compass") 348 | FISHING_ROD = registry.getRegisteredItemOrAir("fishing_rod") 349 | CLOCK = registry.getRegisteredItemOrAir("clock") 350 | GLOWSTONE_DUST = registry.getRegisteredItemOrAir("glowstone_dust") 351 | FISH = registry.getRegisteredItemOrAir("fish") 352 | COOKED_FISH = registry.getRegisteredItemOrAir("cooked_fish") 353 | DYE = registry.getRegisteredItemOrAir("dye") 354 | BONE = registry.getRegisteredItemOrAir("bone") 355 | SUGAR = registry.getRegisteredItemOrAir("sugar") 356 | CAKE = registry.getRegisteredItemOrAir("cake") 357 | BED = registry.getRegisteredItemOrAir("bed") 358 | REPEATER = registry.getRegisteredItemOrAir("repeater") 359 | COOKIE = registry.getRegisteredItemOrAir("cookie") 360 | FILLED_MAP = registry.getRegisteredItemOrAir("filled_map") 361 | SHEARS = registry.getRegisteredItemOrAir("shears") 362 | MELON = registry.getRegisteredItemOrAir("melon") 363 | PUMPKIN_SEEDS = registry.getRegisteredItemOrAir("pumpkin_seeds") 364 | MELON_SEEDS = registry.getRegisteredItemOrAir("melon_seeds") 365 | BEEF = registry.getRegisteredItemOrAir("beef") 366 | COOKED_BEEF = registry.getRegisteredItemOrAir("cooked_beef") 367 | CHICKEN = registry.getRegisteredItemOrAir("chicken") 368 | COOKED_CHICKEN = registry.getRegisteredItemOrAir("cooked_chicken") 369 | MUTTON = registry.getRegisteredItemOrAir("mutton") 370 | COOKED_MUTTON = registry.getRegisteredItemOrAir("cooked_mutton") 371 | RABBIT = registry.getRegisteredItemOrAir("rabbit") 372 | COOKED_RABBIT = registry.getRegisteredItemOrAir("cooked_rabbit") 373 | RABBIT_STEW = registry.getRegisteredItemOrAir("rabbit_stew") 374 | RABBIT_FOOT = registry.getRegisteredItemOrAir("rabbit_foot") 375 | RABBIT_HIDE = registry.getRegisteredItemOrAir("rabbit_hide") 376 | ROTTEN_FLESH = registry.getRegisteredItemOrAir("rotten_flesh") 377 | ENDER_PEARL = registry.getRegisteredItemOrAir("ender_pearl") 378 | BLAZE_ROD = registry.getRegisteredItemOrAir("blaze_rod") 379 | GHAST_TEAR = registry.getRegisteredItemOrAir("ghast_tear") 380 | GOLD_NUGGET = registry.getRegisteredItemOrAir("gold_nugget") 381 | NETHER_WART = registry.getRegisteredItemOrAir("nether_wart") 382 | POTIONITEM = registry.getRegisteredItemOrAir("potion") 383 | SPLASH_POTION = registry.getRegisteredItemOrAir("splash_potion") 384 | LINGERING_POTION = registry.getRegisteredItemOrAir("lingering_potion") 385 | GLASS_BOTTLE = registry.getRegisteredItemOrAir("glass_bottle") 386 | DRAGON_BREATH = registry.getRegisteredItemOrAir("dragon_breath") 387 | SPIDER_EYE = registry.getRegisteredItemOrAir("spider_eye") 388 | FERMENTED_SPIDER_EYE = registry.getRegisteredItemOrAir("fermented_spider_eye") 389 | BLAZE_POWDER = registry.getRegisteredItemOrAir("blaze_powder") 390 | MAGMA_CREAM = registry.getRegisteredItemOrAir("magma_cream") 391 | BREWING_STAND = registry.getRegisteredItemOrAir("brewing_stand") 392 | CAULDRON = registry.getRegisteredItemOrAir("cauldron") 393 | ENDER_EYE = registry.getRegisteredItemOrAir("ender_eye") 394 | SPECKLED_MELON = registry.getRegisteredItemOrAir("speckled_melon") 395 | SPAWN_EGG = registry.getRegisteredItemOrAir("spawn_egg") 396 | EXPERIENCE_BOTTLE = registry.getRegisteredItemOrAir("experience_bottle") 397 | FIRE_CHARGE = registry.getRegisteredItemOrAir("fire_charge") 398 | WRITABLE_BOOK = registry.getRegisteredItemOrAir("writable_book") 399 | WRITTEN_BOOK = registry.getRegisteredItemOrAir("written_book") 400 | EMERALD = registry.getRegisteredItemOrAir("emerald") 401 | ITEM_FRAME = registry.getRegisteredItemOrAir("item_frame") 402 | FLOWER_POT = registry.getRegisteredItemOrAir("flower_pot") 403 | CARROT = registry.getRegisteredItemOrAir("carrot") 404 | POTATO = registry.getRegisteredItemOrAir("potato") 405 | BAKED_POTATO = registry.getRegisteredItemOrAir("baked_potato") 406 | POISONOUS_POTATO = registry.getRegisteredItemOrAir("poisonous_potato") 407 | MAP = registry.getRegisteredItemOrAir("map") 408 | GOLDEN_CARROT = registry.getRegisteredItemOrAir("golden_carrot") 409 | SKULL = registry.getRegisteredItemOrAir("skull") 410 | CARROT_ON_A_STICK = registry.getRegisteredItemOrAir("carrot_on_a_stick") 411 | NETHER_STAR = registry.getRegisteredItemOrAir("nether_star") 412 | PUMPKIN_PIE = registry.getRegisteredItemOrAir("pumpkin_pie") 413 | FIREWORKS = registry.getRegisteredItemOrAir("fireworks") 414 | FIREWORK_CHARGE = registry.getRegisteredItemOrAir("firework_charge") 415 | ENCHANTED_BOOK = registry.getRegisteredItemOrAir("enchanted_book") 416 | COMPARATOR = registry.getRegisteredItemOrAir("comparator") 417 | NETHERBRICK = registry.getRegisteredItemOrAir("netherbrick") 418 | QUARTZ = registry.getRegisteredItemOrAir("quartz") 419 | TNT_MINECART = registry.getRegisteredItemOrAir("tnt_minecart") 420 | HOPPER_MINECART = registry.getRegisteredItemOrAir("hopper_minecart") 421 | ARMOR_STAND = registry.getRegisteredItemOrAir("armor_stand") 422 | IRON_HORSE_ARMOR = registry.getRegisteredItemOrAir("iron_horse_armor") 423 | GOLDEN_HORSE_ARMOR = registry.getRegisteredItemOrAir("golden_horse_armor") 424 | DIAMOND_HORSE_ARMOR = registry.getRegisteredItemOrAir("diamond_horse_armor") 425 | LEAD = registry.getRegisteredItemOrAir("lead") 426 | NAME_TAG = registry.getRegisteredItemOrAir("name_tag") 427 | COMMAND_BLOCK_MINECART = registry.getRegisteredItemOrAir("command_block_minecart") 428 | RECORD_13 = registry.getRegisteredItemOrAir("record_13") 429 | RECORD_CAT = registry.getRegisteredItemOrAir("record_cat") 430 | RECORD_BLOCKS = registry.getRegisteredItemOrAir("record_blocks") 431 | RECORD_CHIRP = registry.getRegisteredItemOrAir("record_chirp") 432 | RECORD_FAR = registry.getRegisteredItemOrAir("record_far") 433 | RECORD_MALL = registry.getRegisteredItemOrAir("record_mall") 434 | RECORD_MELLOHI = registry.getRegisteredItemOrAir("record_mellohi") 435 | RECORD_STAL = registry.getRegisteredItemOrAir("record_stal") 436 | RECORD_STRAD = registry.getRegisteredItemOrAir("record_strad") 437 | RECORD_WARD = registry.getRegisteredItemOrAir("record_ward") 438 | RECORD_11 = registry.getRegisteredItemOrAir("record_11") 439 | RECORD_WAIT = registry.getRegisteredItemOrAir("record_wait") 440 | PRISMARINE_SHARD = registry.getRegisteredItemOrAir("prismarine_shard") 441 | PRISMARINE_CRYSTALS = registry.getRegisteredItemOrAir("prismarine_crystals") 442 | BANNER = registry.getRegisteredItemOrAir("banner") 443 | END_CRYSTAL = registry.getRegisteredItemOrAir("end_crystal") 444 | SHIELD = registry.getRegisteredItemOrAir("shield") 445 | ELYTRA = registry.getRegisteredItemOrAir("elytra") 446 | CHORUS_FRUIT = registry.getRegisteredItemOrAir("chorus_fruit") 447 | CHORUS_FRUIT_POPPED = registry.getRegisteredItemOrAir("chorus_fruit_popped") 448 | BEETROOT_SEEDS = registry.getRegisteredItemOrAir("beetroot_seeds") 449 | BEETROOT = registry.getRegisteredItemOrAir("beetroot") 450 | BEETROOT_SOUP = registry.getRegisteredItemOrAir("beetroot_soup") 451 | TOTEM_OF_UNDYING = registry.getRegisteredItemOrAir("totem_of_undying") 452 | SHULKER_SHELL = registry.getRegisteredItemOrAir("shulker_shell") 453 | IRON_NUGGET = registry.getRegisteredItemOrAir("iron_nugget") 454 | KNOWLEDGE_BOOK = registry.getRegisteredItemOrAir("knowledge_book") 455 | } 456 | } 457 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/module/MinecraftApiModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.module 26 | 27 | import pw.stamina.minecraftapi.MinecraftApiAdapter 28 | 29 | interface MinecraftApiModule { 30 | 31 | fun bootstrap(adapter: MinecraftApiAdapter) 32 | 33 | fun consumeEvent(event: T) 34 | } 35 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/module/MinecraftApiModuleLoader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.module 26 | 27 | import java.util.* 28 | 29 | object MinecraftApiModuleLoader { 30 | 31 | fun loadModule(): MinecraftApiModule { 32 | val moduleServiceLoader = createModuleServiceLoader() 33 | return moduleServiceLoader.single() 34 | } 35 | 36 | private fun createModuleServiceLoader(): ServiceLoader { 37 | return ServiceLoader.load(MinecraftApiModule::class.java) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/AbstractPacketAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | abstract class AbstractPacketAdapter protected constructor(private val packetType: Class) : PacketAdapter { 28 | 29 | override fun `is`(packet: Packet): Boolean { 30 | return packetType.isInstance(packet) 31 | } 32 | 33 | override fun cast(packet: Packet): T { 34 | return packetType.cast(packet) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/NetHandlerPlayClient.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | interface NetHandlerPlayClient { 28 | 29 | fun queuePacket(packet: Packet) 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/NetworkManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | interface NetworkManager { 28 | 29 | fun sendPacket(packet: Packet) 30 | } 31 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/Packet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | interface Packet { 28 | 29 | fun `is`(adapter: PacketAdapter): Boolean { 30 | return adapter.`is`(this) 31 | } 32 | 33 | fun cast(adapter: PacketAdapter): T { 34 | return adapter.cast(this) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/PacketAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | interface PacketAdapter { 28 | 29 | fun `is`(packet: Packet): Boolean 30 | 31 | fun cast(packet: Packet): T 32 | } 33 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/PacketAdapters.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | import pw.stamina.minecraftapi.network.incoming.IncomingPacketAdapters 29 | import pw.stamina.minecraftapi.network.outgoing.OutgoingPacketAdapters 30 | 31 | class PacketAdapters private constructor() { 32 | 33 | init { 34 | throw Error() 35 | } 36 | 37 | companion object { 38 | private val INCOMING_ADAPTERS: IncomingPacketAdapters 39 | private val OUTGOING_ADAPTERS: OutgoingPacketAdapters 40 | 41 | init { 42 | val adapter = MinecraftApi.getAdapter() 43 | 44 | INCOMING_ADAPTERS = adapter.incomingPacketAdapters 45 | OUTGOING_ADAPTERS = adapter.outingPacketAdapters 46 | } 47 | 48 | fun incoming(): IncomingPacketAdapters { 49 | return INCOMING_ADAPTERS 50 | } 51 | 52 | fun outgoing(): OutgoingPacketAdapters { 53 | return OUTGOING_ADAPTERS 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/incoming/ChatPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.incoming 26 | 27 | import pw.stamina.minecraftapi.network.Packet 28 | import pw.stamina.minecraftapi.network.PacketAdapter 29 | 30 | //TODO: Add getMessage when a ChatComponent API has been implemented 31 | interface ChatPacket : Packet { 32 | 33 | val textMessage: String 34 | 35 | interface Adapter : PacketAdapter 36 | } 37 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/incoming/ExplosionPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.incoming 26 | 27 | import pw.stamina.minecraftapi.network.Packet 28 | import pw.stamina.minecraftapi.network.PacketAdapter 29 | 30 | interface ExplosionPacket : Packet { 31 | 32 | var motionX: Float 33 | 34 | var motionY: Float 35 | 36 | var motionZ: Float 37 | 38 | fun multiplyMotion(multiplier: Double) 39 | 40 | interface Adapter : PacketAdapter 41 | } 42 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/incoming/IncomingPacketAdapters.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.incoming 26 | 27 | interface IncomingPacketAdapters { 28 | 29 | fun chat(): ChatPacket.Adapter 30 | 31 | fun velocity(): VelocityPacket.Adapter 32 | 33 | fun explosion(): ExplosionPacket.Adapter 34 | } 35 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/incoming/VelocityPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.incoming 26 | 27 | import pw.stamina.minecraftapi.network.Packet 28 | import pw.stamina.minecraftapi.network.PacketAdapter 29 | 30 | interface VelocityPacket : Packet { 31 | 32 | val entityId: Int 33 | 34 | var motionX: Int 35 | 36 | var motionY: Int 37 | 38 | var motionZ: Int 39 | 40 | fun multiplyMotion(multiplier: Double) 41 | 42 | interface Adapter : PacketAdapter 43 | } 44 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/ChatPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | import pw.stamina.minecraftapi.network.Packet 28 | import pw.stamina.minecraftapi.network.PacketAdapter 29 | 30 | interface ChatPacket : Packet { 31 | 32 | val message: String 33 | 34 | fun setMessage(message: String): String 35 | 36 | interface Adapter : PacketAdapter { 37 | 38 | fun create(message: String): ChatPacket 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/LookPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | import pw.stamina.minecraftapi.network.PacketAdapter 28 | import pw.stamina.minecraftapi.util.Rotation 29 | 30 | interface LookPacket : OnGroundPacket { 31 | 32 | var rotation: Rotation 33 | get() = Rotation(yaw, pitch) 34 | set(rotation) { 35 | yaw = rotation.yaw 36 | pitch = rotation.pitch 37 | } 38 | 39 | val isRotating: Boolean 40 | 41 | var yaw: Float 42 | var pitch: Float 43 | 44 | interface Adapter : PacketAdapter { 45 | 46 | fun create(yaw: Float, pitch: Float, onGround: Boolean): LookPacket 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/OnGroundPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | import pw.stamina.minecraftapi.network.Packet 28 | import pw.stamina.minecraftapi.network.PacketAdapter 29 | 30 | interface OnGroundPacket : Packet { 31 | 32 | fun onGround(): Boolean 33 | fun onGround(onGround: Boolean) 34 | 35 | interface Adapter : PacketAdapter { 36 | 37 | fun create(onGround: Boolean): OnGroundPacket 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/OutgoingPacketAdapters.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | interface OutgoingPacketAdapters { 28 | 29 | fun chat(): ChatPacket.Adapter 30 | 31 | fun onGround(): OnGroundPacket.Adapter 32 | 33 | fun position(): PositionPacket.Adapter 34 | 35 | fun look(): LookPacket.Adapter 36 | 37 | fun positionLook(): PositionLookPacket.Adapter 38 | } 39 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/PositionLookPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | import pw.stamina.minecraftapi.network.PacketAdapter 28 | 29 | interface PositionLookPacket : PositionPacket, LookPacket { 30 | 31 | interface Adapter : PacketAdapter { 32 | 33 | fun create(x: Double, y: Double, z: Double, 34 | yaw: Float, pitch: Float, onGround: Boolean): PositionLookPacket 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/network/outgoing/PositionPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.network.outgoing 26 | 27 | import pw.stamina.minecraftapi.network.PacketAdapter 28 | 29 | interface PositionPacket : OnGroundPacket { 30 | 31 | val isMoving: Boolean 32 | 33 | fun x(): Double 34 | fun x(x: Double) 35 | 36 | fun y(): Double 37 | fun y(y: Double) 38 | 39 | fun z(): Double 40 | fun z(z: Double) 41 | 42 | interface Adapter : PacketAdapter { 43 | 44 | fun create(x: Double, y: Double, z: Double, onGround: Boolean): PositionPacket 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/render/FontRenderer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.render 26 | 27 | interface FontRenderer { 28 | 29 | fun drawString(text: String, x: Float, y: Float, color: Int) 30 | 31 | fun drawStringWithShadow(text: String, x: Float, y: Float, color: Int) 32 | 33 | fun getStringWidth(text: String): Int 34 | 35 | fun getCharacterWidth(character: Char): Int 36 | } 37 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/render/RenderManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.render 26 | 27 | interface RenderManager { 28 | 29 | val originYOffset: Float 30 | 31 | val renderPosX: Double 32 | val renderPosY: Double 33 | val renderPosZ: Double 34 | 35 | val viewerPosX: Double 36 | val viewerPosY: Double 37 | val viewerPosZ: Double 38 | } 39 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/BoundingBox.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | 29 | interface BoundingBox { 30 | 31 | val minX: Double 32 | 33 | val maxX: Double 34 | 35 | val minY: Double 36 | 37 | val maxY: Double 38 | 39 | val minZ: Double 40 | 41 | val maxZ: Double 42 | 43 | fun expand(x: Double, y: Double, z: Double): BoundingBox 44 | 45 | fun contract(x: Double, y: Double, z: Double): BoundingBox 46 | 47 | fun offset(x: Double, y: Double, z: Double): BoundingBox 48 | 49 | fun grow(x: Double, y: Double, z: Double): BoundingBox 50 | 51 | fun shrink(x: Double, y: Double, z: Double): BoundingBox 52 | 53 | fun calculateXOffset(other: BoundingBox, distance: Double): Double 54 | 55 | fun calculateYOffset(other: BoundingBox, distance: Double): Double 56 | 57 | fun calculateZOffset(other: BoundingBox, distance: Double): Double 58 | 59 | interface Factory { 60 | fun create(x1: Double, y1: Double, z1: Double, 61 | x2: Double, y2: Double, z2: Double): BoundingBox 62 | } 63 | 64 | companion object { 65 | 66 | fun fromBounds(x1: Double, y1: Double, z1: Double, 67 | x2: Double, y2: Double, z2: Double): BoundingBox { 68 | return MinecraftApi.getAdapter().boundingBoxFactory.create(x1, y1, z1, x2, y2, z2) 69 | } 70 | 71 | fun builder(): BoundingBoxBuilder { 72 | return BoundingBoxBuilder() 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/BoundingBoxBuilder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | class BoundingBoxBuilder { 28 | private var x1: Double = 0.toDouble() 29 | private var y1: Double = 0.toDouble() 30 | private var z1: Double = 0.toDouble() 31 | private var x2: Double = 0.toDouble() 32 | private var y2: Double = 0.toDouble() 33 | private var z2: Double = 0.toDouble() 34 | 35 | fun x1(x1: Double): BoundingBoxBuilder { 36 | this.x1 = x1 37 | return this 38 | } 39 | 40 | fun y1(y1: Double): BoundingBoxBuilder { 41 | this.y1 = y1 42 | return this 43 | } 44 | 45 | fun z1(z1: Double): BoundingBoxBuilder { 46 | this.z1 = z1 47 | return this 48 | } 49 | 50 | fun x2(x2: Double): BoundingBoxBuilder { 51 | this.x2 = x2 52 | return this 53 | } 54 | 55 | fun y2(y2: Double): BoundingBoxBuilder { 56 | this.y2 = y2 57 | return this 58 | } 59 | 60 | fun z2(z2: Double): BoundingBoxBuilder { 61 | this.z2 = z2 62 | return this 63 | } 64 | 65 | fun x(x1: Double, x2: Double): BoundingBoxBuilder { 66 | this.x1 = x1 67 | this.x2 = x2 68 | return this 69 | } 70 | 71 | fun y(y1: Double, y2: Double): BoundingBoxBuilder { 72 | this.y1 = y1 73 | this.y2 = y2 74 | return this 75 | } 76 | 77 | fun z(z1: Double, z2: Double): BoundingBoxBuilder { 78 | this.z1 = z1 79 | this.z2 = z2 80 | return this 81 | } 82 | 83 | fun build(): BoundingBox { 84 | return BoundingBox.fromBounds(x1, y1, z1, x2, y2, z2) 85 | } 86 | } -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/CurrentPreviousPair.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | data class CurrentPreviousPair(val current: T, val previous: T) -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/Hand.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | 29 | interface Hand { 30 | 31 | interface Adapter { 32 | 33 | val mainHand: Hand 34 | 35 | val offHand: Hand 36 | } 37 | 38 | companion object { 39 | private val adapter = MinecraftApi.getAdapter().handAdapter 40 | 41 | val main = adapter.mainHand 42 | 43 | val off = adapter.offHand 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/Position.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | data class Position(val x: Double, val y: Double, val z: Double) -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/ResourceLocation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | import pw.stamina.minecraftapi.MinecraftApi 28 | 29 | interface ResourceLocation { 30 | 31 | val resourcePath: String 32 | 33 | val resourceDomain: String 34 | 35 | interface Factory { 36 | 37 | fun create(resourceName: String): ResourceLocation 38 | 39 | fun create(resourceDomain: String, resourcePath: String): ResourceLocation 40 | } 41 | 42 | companion object { 43 | private val resourceLocationFactory = MinecraftApi.getAdapter().resourceLocationFactory 44 | 45 | fun from(resourceName: String): ResourceLocation { 46 | return resourceLocationFactory.create(resourceName) 47 | } 48 | 49 | fun from(resourceDomain: String, resourcePath: String): ResourceLocation { 50 | return resourceLocationFactory.create(resourceDomain, resourcePath) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/util/Rotation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.util 26 | 27 | data class Rotation(val yaw: Float, val pitch: Float) -------------------------------------------------------------------------------- /minecraftapi-core/src/main/kotlin/pw/stamina/minecraftapi/world/World.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.world 26 | 27 | import pw.stamina.minecraftapi.entity.Entity 28 | 29 | interface World { 30 | 31 | val loadedEntities: List 32 | } 33 | -------------------------------------------------------------------------------- /minecraftapi-events/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | plugins { 26 | kotlin("jvm") 27 | } 28 | 29 | version = "1.0.0-SNAPSHOT" 30 | 31 | applyStandardDependencies() 32 | 33 | dependencies { 34 | implementation("pw.stamina.causam:causam:1.0.0-SNAPSHOT") 35 | } 36 | -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/input/InputEvents.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.input 26 | 27 | class KeyInputEvent(val key: Int, val inputType: KeyInputType) 28 | 29 | enum class KeyInputType { 30 | PRESS, 31 | REPEAT, 32 | RELEASE 33 | } 34 | 35 | class MouseInputEvent(val button: Int, val isPressed: Boolean) -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/network/PacketEvents.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.network 26 | 27 | import pw.stamina.causam.event.AbstractCancellable 28 | import pw.stamina.minecraftapi.network.NetworkManager 29 | import pw.stamina.minecraftapi.network.Packet 30 | import java.util.* 31 | 32 | sealed class PacketEvent(val packet: Packet, private val networkManager: NetworkManager) : AbstractCancellable() { 33 | 34 | private val packetsDelegate = lazy { LinkedList() } 35 | private val packets by packetsDelegate 36 | 37 | fun sendPacket(packet: Packet) { 38 | networkManager.sendPacket(packet) 39 | } 40 | 41 | fun addPacket(packet: Packet) { 42 | packets.add(packet) 43 | } 44 | 45 | fun sendPackets(sender: (Packet) -> Unit) { 46 | if (!packetsDelegate.isInitialized()) { 47 | return 48 | } 49 | 50 | packets.forEach(sender) 51 | packets.clear() 52 | } 53 | } 54 | 55 | class IncomingPacketEvent(packet: Packet, networkManager: NetworkManager) : PacketEvent(packet, networkManager) 56 | 57 | class OutgoingPacketEvent(packet: Packet, networkManager: NetworkManager) : PacketEvent(packet, networkManager) -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/player/MotionUpdateEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.player 26 | 27 | import pw.stamina.causam.event.AbstractCancellable 28 | import pw.stamina.minecraftapi.entity.living.ClientPlayer 29 | import pw.stamina.minecraftapi.network.Packet 30 | import pw.stamina.minecraftapi.util.CurrentPreviousPair 31 | import pw.stamina.minecraftapi.util.Position 32 | import pw.stamina.minecraftapi.util.Rotation 33 | import java.util.* 34 | 35 | class MotionUpdateEvent( 36 | val player: ClientPlayer, 37 | 38 | position: Position, 39 | rotation: Rotation, 40 | 41 | val oldPosition: Position, 42 | val oldRotation: Rotation, 43 | 44 | sprinting: CurrentPreviousPair, 45 | sneaking: CurrentPreviousPair, 46 | 47 | var onGround: Boolean, 48 | private val packetSender: (Packet) -> Unit 49 | ) : AbstractCancellable() { 50 | 51 | var offsetX: Double = 0.0 52 | private set 53 | var offsetY: Double = 0.0 54 | private set 55 | var offsetZ: Double = 0.0 56 | private set 57 | 58 | private val packetsDelegate = lazy { LinkedList() } 59 | private val actionsDelegate = lazy { LinkedList<() -> Unit>() } 60 | 61 | private val packets by packetsDelegate 62 | private val actions by actionsDelegate 63 | 64 | var yaw = rotation.yaw 65 | var pitch = rotation.pitch 66 | 67 | var rotation: Rotation 68 | get() = Rotation(yaw, pitch) 69 | set(rotation) { 70 | yaw = rotation.yaw 71 | pitch = rotation.pitch 72 | } 73 | 74 | var x = position.x 75 | set(x) { 76 | offsetX += (x - field) 77 | field = x 78 | } 79 | 80 | var y = position.y 81 | set(y) { 82 | offsetY += (y - field) 83 | field = y 84 | } 85 | 86 | var z = position.z 87 | set(z) { 88 | offsetY += (z - field) 89 | field = z 90 | } 91 | 92 | var position: Position 93 | get() = Position(x, y, z) 94 | set(position) { 95 | x = position.x 96 | y = position.y 97 | z = position.z 98 | } 99 | 100 | fun offset(x: Double, y: Double, z: Double) { 101 | this.x += x 102 | this.y += y 103 | this.z += z 104 | } 105 | 106 | val isMoving: Boolean 107 | get() { 108 | val x = this.x - oldPosition.x 109 | val y = this.y - oldPosition.y 110 | val z = this.z - oldPosition.z 111 | 112 | return x * x + y * y + z * z > 9.0E-4 113 | } 114 | 115 | val isRotating: Boolean 116 | get() = rotation != oldRotation 117 | 118 | var sprinting = sprinting.current 119 | val wasSprinting = sprinting.previous 120 | 121 | var sneaking = sneaking.current 122 | val wasSneaking = sneaking.previous 123 | 124 | fun sendPacket(packet: Packet) { 125 | packetSender(packet) 126 | } 127 | 128 | fun sendAfter(packet: Packet) { 129 | packets.add(packet) 130 | } 131 | 132 | fun sendPackets(sender: (Packet) -> Unit) { 133 | if (!packetsDelegate.isInitialized()) { 134 | return 135 | } 136 | 137 | packets.forEach(sender) 138 | packets.clear() 139 | } 140 | 141 | fun doAfter(action: () -> Unit) { 142 | actions.add(action) 143 | } 144 | 145 | fun performActions() { 146 | if (!packetsDelegate.isInitialized()) { 147 | return 148 | } 149 | 150 | actions.forEach { it() } 151 | actions.clear() 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/render/CapeRenderEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.render 26 | 27 | import pw.stamina.minecraftapi.entity.living.Player 28 | import pw.stamina.minecraftapi.util.ResourceLocation 29 | 30 | class CapeRenderEvent(val player: Player) { 31 | private var overridingCapeLocation: ResourceLocation? = null 32 | 33 | val isCapeLocationOverridden: Boolean 34 | get() = overridingCapeLocation != null 35 | 36 | fun overrideCapeLocation(capeLocation: ResourceLocation) { 37 | this.overridingCapeLocation = capeLocation 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/render/HandRenderEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.render 26 | 27 | import pw.stamina.causam.event.AbstractCancellable 28 | 29 | class HandRenderEvent(val partialRenderTick: Float) : AbstractCancellable() 30 | -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/render/LightmapUpdateEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.render 26 | 27 | class LightmapUpdateEvent { 28 | 29 | private var calculator: LightmapCalculator? = null 30 | 31 | var isLightUpdateForced: Boolean = false 32 | private set 33 | 34 | fun forceLightUpdate() { 35 | isLightUpdateForced = true 36 | } 37 | 38 | fun setCalculator(calculator: LightmapCalculator) { 39 | this.calculator = calculator 40 | } 41 | 42 | fun calculate(red: Int, green: Int, blue: Int, color: Int): Int { 43 | return calculator?.invoke(red, green, blue, color) ?: color 44 | } 45 | } 46 | 47 | typealias LightmapCalculator = (red: Int, green: Int, blue: Int, color: Int) -> Int -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/render/ScreenRenderEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.render 26 | 27 | object ScreenRenderEvent 28 | -------------------------------------------------------------------------------- /minecraftapi-events/src/main/kotlin/pw/stamina/minecraftapi/event/render/WorldRenderEvent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.event.render 26 | 27 | import pw.stamina.minecraftapi.client.Minecraft 28 | 29 | /** 30 | * This is essentially pre world render, and HandRenderEvent 31 | * is post world render. 32 | * 33 | * @see HandRenderEvent 34 | */ 35 | class WorldRenderEvent(val minecraft: Minecraft, val partialRenderTick: Float) 36 | -------------------------------------------------------------------------------- /minecraftapi-tweaker/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | plugins { 26 | kotlin("jvm") 27 | } 28 | 29 | version = "1.0.0-SNAPSHOT" 30 | 31 | applyStandardDependencies() 32 | 33 | repositories { 34 | maven { 35 | name = "sponge" 36 | setUrl("http://repo.spongepowered.org/maven") 37 | } 38 | 39 | maven { 40 | name = "minecraft" 41 | setUrl("https://libraries.minecraft.net/") 42 | } 43 | } 44 | version = "1.0.0-SNAPSHOT" 45 | 46 | dependencies { 47 | implementation(Dependencies.launchwrapper) { 48 | isTransitive = false 49 | } 50 | 51 | // Fixes an issue with Mixin"s transitive dependencies 52 | compileOnly(Dependencies.mixin) 53 | implementation(Dependencies.mixin) { 54 | isTransitive = false 55 | } 56 | } -------------------------------------------------------------------------------- /minecraftapi-tweaker/src/main/kotlin/pw/stamina/minecraftapi/tweak/MinecraftApiDevelopmentTweaker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.tweak 26 | 27 | import net.minecraft.launchwrapper.ITweaker 28 | import net.minecraft.launchwrapper.LaunchClassLoader 29 | import org.spongepowered.asm.launch.MixinBootstrap 30 | import org.spongepowered.asm.mixin.MixinEnvironment 31 | import org.spongepowered.asm.mixin.Mixins 32 | import java.io.File 33 | import java.util.* 34 | 35 | open class MinecraftApiDevelopmentTweaker : ITweaker { 36 | private val arguments = ArrayList() 37 | 38 | override fun acceptOptions(list: List, gameDir: File?, assetsDir: File?, profile: String?) { 39 | arguments.addAll(list) 40 | 41 | if (profile != null && !arguments.contains("--version")) { 42 | arguments.add("--version") 43 | arguments.add(profile) 44 | } 45 | 46 | if (assetsDir != null && !arguments.contains("--assetsDir")) { 47 | arguments.add("--assetsDir") 48 | arguments.add(assetsDir.path) 49 | } 50 | 51 | if (gameDir != null && !arguments.contains("--gameDir")) { 52 | arguments.add("--gameDir") 53 | arguments.add(gameDir.path) 54 | } 55 | } 56 | 57 | override fun injectIntoClassLoader(classLoader: LaunchClassLoader) { 58 | excludeLog4JPackages(classLoader) 59 | 60 | MixinBootstrap.init() 61 | 62 | Mixins.addConfiguration("mixins.minecraftapi-core.json") 63 | Mixins.addConfiguration("mixins.minecraftapi-events.json") 64 | 65 | MixinEnvironment.getDefaultEnvironment().obfuscationContext = "notch" 66 | 67 | MixinEnvironment.getDefaultEnvironment().side = MixinEnvironment.Side.CLIENT 68 | } 69 | 70 | // Fixes a bug causing Mixin to crash when injecting from the launcher 71 | private fun excludeLog4JPackages(classLoader: LaunchClassLoader) { 72 | classLoader.addClassLoaderExclusion("org.apache.logging.log4j.") 73 | } 74 | 75 | override fun getLaunchTarget() = "net.minecraft.client.main.Main" 76 | 77 | override fun getLaunchArguments() = arguments.toTypedArray() 78 | } 79 | -------------------------------------------------------------------------------- /minecraftapi-tweaker/src/main/kotlin/pw/stamina/minecraftapi/tweak/MinecraftApiProductionTweaker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package pw.stamina.minecraftapi.tweak 26 | 27 | class MinecraftApiProductionTweaker : MinecraftApiDevelopmentTweaker() { 28 | 29 | // These methods are supposed to be empty, to prevent issues 30 | // with duplicate arguments when running from the launcher 31 | override fun getLaunchArguments(): Array = emptyArray() 32 | } 33 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Stamina Development 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | rootProject.name = 'minecraftapi' 26 | 27 | include 'minecraftapi-core', 28 | 'minecraftapi-events', 29 | 'minecraftapi-tweaker' 30 | --------------------------------------------------------------------------------