diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 0000000..4ec6ab5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +[*] +charset = utf-8 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +indent_size = 4 +ij_continuation_indent_size = 4 + +[*.{json, yml}] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml new file mode 100755 index 0000000..05f693a --- /dev/null +++ b/.github/workflows/dev_build.yml @@ -0,0 +1,25 @@ +name: Publish Development Build +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Set up Java + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: adopt + - name: Build with Gradle + run: ./gradlew build + - name: Release + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: '${{ secrets.GITHUB_TOKEN }}' + automatic_release_tag: latest + prerelease: true + title: Dev Build + files: | + ./build/libs/*.jar diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100755 index 0000000..e0b5026 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,23 @@ +name: Build Pull Request Artifacts +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Wrapper Validation + uses: gradle/actions/wrapper-validation@v3 + - name: Set up Java + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: adopt + - name: Build with Gradle + run: ./gradlew build + - name: Release + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: build/libs/ diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..09cd281 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/README.md b/README.md old mode 100644 new mode 100755 index a3ad3cc..92043ce --- a/README.md +++ b/README.md @@ -1,2 +1,85 @@ -# meteor-baritone - Experementing with meteor and barotone +# Meteor Addon Template + +A template to allow easy usage of the Meteor Addon API. + +### How to use + +- Clone this project +- Use this template to create new modules/commands +- Build the executable using the gradle `build` task. +- Run the mod with Meteor. + +### Project structure + +```text +. +│── .github +│ ╰── workflows +│ │── dev_build.yml +│ ╰── pull_request.yml +│── gradle +│ ╰── wrapper +│ │── gradle-wrapper.jar +│ ╰── gradle-wrapper.properties +│── src +│ ╰── main +│ │── java +│ │ ╰── com +│ │ ╰── example +│ │ ╰── addon +│ │ │── commands +│ │ │ ╰── CommandExample +│ │ │── hud +│ │ │ ╰── HudExample +│ │ │── modules +│ │ │ ╰── ModuleExample +│ │ ╰── AddonTemplate +│ ╰── resources +│ │── assets +│ │ ╰── template +│ │ ╰── icon.png +│ │── addon-template.mixins.json +│ ╰── fabric.mod.json +│── .editorconfig +│── .gitignore +│── build.gradle +│── gradle.properties +│── gradlew +│── gradlew.bat +│── LICENSE +│── README.md +╰── settings.gradle +``` + +This is the default project structure. Each folder/file has a specific purpose. +Here is a brief explanation of the ones you might need to modify: + +- `.github/workflows`: Contains the GitHub Actions configuration files. +- `gradle`: Contains the Gradle wrapper files. + Edit the `gradle.properties` file to change the version of the Gradle wrapper. +- `src/main/java/com/example/addon`: Contains the main class of the addon. + Here you can register your custom commands, modules, and HUDs. + Edit the `getPackage` method to reflect the package of your addon. +- `src/main/resources`: Contains the resources of the addon. + - `assets`: Contains the assets of the addon. + You can add your own assets here, separated in subfolders. + - `template`: Contains the assets of the template. + You can replace the `icon.png` file with your own addon icon. + Also, rename this folder to reflect the name of your addon. + - `addon-template.mixins.json`: Contains the Mixin configuration for the addon. + You can add your own mixins in the `client` array. + - `fabric.mod.json`: Contains the metadata of the addon. + Edit the various fields to reflect the metadata of your addon. +- `build.gradle`: Contains the Gradle build script. + You can manage the dependencies of the addon here. + Remember to keep the `fabric-loom` version up-to-date. +- `gradle.properties`: Contains the properties of the Gradle build. + These will be used by the build script. +- `LICENSE`: Contains the license of the addon. + You can edit this file to change the license of your addon. +- `README.md`: Contains the documentation of the addon. + You can edit this file to reflect the documentation of your addon, and showcase its features. + +## License + +This template is available under the CC0 license. Feel free to use it for your own projects. diff --git a/build.gradle b/build.gradle new file mode 100755 index 0000000..e4db899 --- /dev/null +++ b/build.gradle @@ -0,0 +1,62 @@ +plugins { + id "fabric-loom" version "1.8-SNAPSHOT" +} + +base { + archivesBaseName = project.archives_base_name + version = project.mod_version + group = project.maven_group +} + +repositories { + maven { + name = "Meteor Dev Releases" + url = "https://maven.meteordev.org/releases" + } + maven { + name = "Meteor Dev Snapshots" + url = "https://maven.meteordev.org/snapshots" + } +} + +dependencies { + // Fabric + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Meteor + modImplementation "meteordevelopment:meteor-client:${project.meteor_version}" + + // Baritone (https://github.com/MeteorDevelopment/baritone) + modCompileOnly "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT" +} + +tasks { + processResources { + def propertyMap = [ + "version" : project.version, + "mc_version": project.minecraft_version, + ] + + filesMatching("fabric.mod.json") { + expand(propertyMap) + } + } + + jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesBaseName}" } + } + } + + java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + } + + tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + it.options.release = 21 + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100755 index 0000000..042f341 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +org.gradle.jvmargs=-Xmx2G + +# Fabric Properties (https://fabricmc.net/develop) +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 + +# Mod Properties +mod_version=0.1.0 +maven_group=com.example +archives_base_name=addon-template + +# Dependencies + +# Meteor (https://maven.meteordev.org) +meteor_version=0.5.9-SNAPSHOT + +# Baritone (https://github.com/MeteorDevelopment/baritone) +baritone_version=1.21.3 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000..943f0cb Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000..9355b41 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100755 index 0000000..93e3f59 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100755 index 0000000..b02216b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} diff --git a/src/main/java/com/example/addon/AddonTemplate.java b/src/main/java/com/example/addon/AddonTemplate.java new file mode 100755 index 0000000..6ba9e59 --- /dev/null +++ b/src/main/java/com/example/addon/AddonTemplate.java @@ -0,0 +1,52 @@ +package com.example.addon; + +import com.example.addon.commands.CommandExample; +import com.example.addon.hud.HudExample; +import com.example.addon.modules.BaseFinder; +import com.example.addon.modules.ModuleExample; +import com.mojang.logging.LogUtils; +import meteordevelopment.meteorclient.addons.GithubRepo; +import meteordevelopment.meteorclient.addons.MeteorAddon; +import meteordevelopment.meteorclient.commands.Commands; +import meteordevelopment.meteorclient.systems.hud.Hud; +import meteordevelopment.meteorclient.systems.hud.HudGroup; +import meteordevelopment.meteorclient.systems.modules.Category; +import meteordevelopment.meteorclient.systems.modules.Modules; +import org.slf4j.Logger; + +public class AddonTemplate extends MeteorAddon { + public static final Logger LOG = LogUtils.getLogger(); + public static final Category CATEGORY = new Category("Example"); + public static final HudGroup HUD_GROUP = new HudGroup("Example"); + + @Override + public void onInitialize() { + LOG.info("Initializing Meteor Addon Template"); + + // Modules + BaseFinder baseFinder = new BaseFinder(); + Modules.get().add(new ModuleExample()); + Modules.get().add(baseFinder); + + // Commands + Commands.add(new CommandExample(baseFinder)); + + // HUD + Hud.get().register(HudExample.INFO); + } + + @Override + public void onRegisterCategories() { + Modules.registerCategory(CATEGORY); + } + + @Override + public String getPackage() { + return "com.example.addon"; + } + + @Override + public GithubRepo getRepo() { + return new GithubRepo("MeteorDevelopment", "meteor-addon-template"); + } +} diff --git a/src/main/java/com/example/addon/LavacastGenerator.java b/src/main/java/com/example/addon/LavacastGenerator.java new file mode 100644 index 0000000..2af7b0c --- /dev/null +++ b/src/main/java/com/example/addon/LavacastGenerator.java @@ -0,0 +1,127 @@ +package com.example.addon; + +import java.util.ArrayList; +import java.util.List; + +public class LavacastGenerator { + + public static class Position { + public int x, z; + + public Position(int x, int z) { + this.x = x; + this.z = z; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Position)) return false; + Position p = (Position) o; + return x == p.x && z == p.z; + } + + public double distanceTo(Position other){ + return Math.sqrt(Math.pow(x - other.x, 2) + Math.pow(z - other.z, 2)); + } + + public Position IncPosX(){ + return new Position(x+1, z); + } + public Position IncPosZ(){ + return new Position(x, z+1); + } + public Position IncNegX(){ + return new Position(x-1, z); + } + public Position IncNegZ(){ + return new Position(x, z-1); + } + } + + public static class MovementNode { + public Position position; + public int depth; + public int depthBeyond = 0; + public MovementNode(Position pos, int depth){ + position = pos; + this.depth = depth; + } + public MovementNode PosX = null; + public MovementNode PosZ = null; + public MovementNode NegX = null; + public MovementNode NegZ = null; + + boolean hasExpanded = false; + + public void expand(List targetTiles, List visited) { +// Set + + if(hasExpanded) { + if(PosX != null) PosX.expand(targetTiles, visited); + if(PosZ != null) PosZ.expand(targetTiles, visited); + if(NegX != null) NegX.expand(targetTiles, visited); + if(NegZ != null) NegZ.expand(targetTiles, visited); + depthBeyond += 1; + return; + } + + Position IncPosX = position.IncPosX(); + if(!visited.contains(IncPosX) && ShouldMoveInDirection(targetTiles, visited, position, IncPosX)) { + PosX = new MovementNode(IncPosX, depth + 1); + visited.add(IncPosX); + } + + Position IncPosZ = position.IncPosZ(); + if(!visited.contains(IncPosZ) && ShouldMoveInDirection(targetTiles, visited, position, IncPosZ)) { + PosZ = new MovementNode(IncPosZ, depth + 1); + visited.add(IncPosZ); + } + + Position IncNegX = position.IncNegX(); + if(!visited.contains(IncNegX) && ShouldMoveInDirection(targetTiles, visited, position, IncNegX)) { + NegX = new MovementNode(IncNegX, depth + 1); + visited.add(IncNegX); + } + + Position IncNegZ = position.IncNegZ(); + if(!visited.contains(IncNegZ) && ShouldMoveInDirection(targetTiles, visited, position, IncNegZ)) { + NegZ = new MovementNode(IncNegZ, depth + 1); + visited.add(IncNegZ); + } + + + hasExpanded = true; + } + } + + private static boolean ShouldMoveInDirection(List targetTiles, List visited, Position origin, Position newPos){ + for(Position tile : targetTiles){ + if(visited.contains(tile)) continue; + + if(newPos.equals(tile)) return true; + + double distance = newPos.distanceTo(tile); + + if(distance > 2) continue; + + if(distance + < origin.distanceTo(tile)) { + return true; + } + + } + + System.out.println("False"); + + return false; + } + +// public static MovementNode findSolution(List targetTiles, Position start) { +// +// +// +// return root; +// } + +} diff --git a/src/main/java/com/example/addon/LavacastPlacer.java b/src/main/java/com/example/addon/LavacastPlacer.java new file mode 100644 index 0000000..affcfa8 --- /dev/null +++ b/src/main/java/com/example/addon/LavacastPlacer.java @@ -0,0 +1,7 @@ +package com.example.addon; + +import baritone.api.BaritoneAPI; + +public class LavacastPlacer { +// public static +} diff --git a/src/main/java/com/example/addon/commands/CommandExample.java b/src/main/java/com/example/addon/commands/CommandExample.java new file mode 100755 index 0000000..db61469 --- /dev/null +++ b/src/main/java/com/example/addon/commands/CommandExample.java @@ -0,0 +1,38 @@ +package com.example.addon.commands; + +import com.example.addon.modules.BaseFinder; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import meteordevelopment.meteorclient.commands.Command; +import net.minecraft.command.CommandSource; + +/** + * The Meteor Client command API uses the same command system as Minecraft does. + */ +public class CommandExample extends Command { + /** + * The {@code name} parameter should be in kebab-case. + */ + + BaseFinder baseFinder; + + public CommandExample(BaseFinder basefinder) { + super("example", "Sends a message."); + this.baseFinder = basefinder; + } + + @Override + public void build(LiteralArgumentBuilder builder) { + builder.executes(context -> { + info("Running generator"); + baseFinder.generate(); + return SINGLE_SUCCESS; + }); + + builder.then(literal("name").then(argument("nameArgument", StringArgumentType.word()).executes(context -> { + String argument = StringArgumentType.getString(context, "nameArgument"); + info("hi, " + argument); + return SINGLE_SUCCESS; + }))); + } +} diff --git a/src/main/java/com/example/addon/hud/HudExample.java b/src/main/java/com/example/addon/hud/HudExample.java new file mode 100755 index 0000000..bdf5928 --- /dev/null +++ b/src/main/java/com/example/addon/hud/HudExample.java @@ -0,0 +1,29 @@ +package com.example.addon.hud; + +import com.example.addon.AddonTemplate; +import meteordevelopment.meteorclient.systems.hud.HudElement; +import meteordevelopment.meteorclient.systems.hud.HudElementInfo; +import meteordevelopment.meteorclient.systems.hud.HudRenderer; +import meteordevelopment.meteorclient.utils.render.color.Color; + +public class HudExample extends HudElement { + /** + * The {@code name} parameter should be in kebab-case. + */ + public static final HudElementInfo INFO = new HudElementInfo<>(AddonTemplate.HUD_GROUP, "example", "HUD element example.", HudExample::new); + + public HudExample() { + super(INFO); + } + + @Override + public void render(HudRenderer renderer) { + setSize(renderer.textWidth("Example element", true), renderer.textHeight(true)); + + // Render background + renderer.quad(x, y, getWidth(), getHeight(), Color.LIGHT_GRAY); + + // Render text + renderer.text("Example element", x, y, Color.WHITE, true); + } +} diff --git a/src/main/java/com/example/addon/mixin/ExampleMixin.java b/src/main/java/com/example/addon/mixin/ExampleMixin.java new file mode 100755 index 0000000..a5556c2 --- /dev/null +++ b/src/main/java/com/example/addon/mixin/ExampleMixin.java @@ -0,0 +1,31 @@ +package com.example.addon.mixin; + +import com.example.addon.AddonTemplate; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.RunArgs; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** + * Example Mixin class. + * For more resources, visit: + * + */ +@Mixin(MinecraftClient.class) +public abstract class ExampleMixin { + /** + * Example Mixin injection targeting the {@code } method (the constructor) at {@code TAIL} (end of method). + */ + @Inject(method = "", at = @At("TAIL")) + private void onGameLoaded(RunArgs args, CallbackInfo ci) { + AddonTemplate.LOG.info("Hello from ExampleMixin!"); + } +} diff --git a/src/main/java/com/example/addon/modules/BaseFinder.java b/src/main/java/com/example/addon/modules/BaseFinder.java new file mode 100755 index 0000000..dd6f1a2 --- /dev/null +++ b/src/main/java/com/example/addon/modules/BaseFinder.java @@ -0,0 +1,764 @@ +package com.example.addon.modules; + + +import baritone.api.pathing.goals.GoalBlock; +import baritone.api.pathing.goals.GoalXZ; +import baritone.process.CustomGoalProcess; +import com.example.addon.AddonTemplate; +import com.example.addon.LavacastGenerator; +import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.render.Render3DEvent; +import meteordevelopment.meteorclient.events.world.ChunkDataEvent; +import meteordevelopment.meteorclient.renderer.ShapeMode; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.meteorclient.utils.render.color.Color; +import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.Heightmap; +import net.minecraft.world.chunk.WorldChunk; +import baritone.api.BaritoneAPI; + +import java.util.*; + +public class BaseFinder extends Module { + + public BaseFinder() { + super(AddonTemplate.CATEGORY, "EXAMPLE thuig", "eeeeeeeeeee"); + } + +// private final SettingGroup sgGeneral = this.settings.getDefaultGroup(); + private final SettingGroup sgUnnaturalBlocks = this.settings.createGroup("Unnatural Blocks"); + private final SettingGroup sgSyntheticBlocks = this.settings.createGroup("Synthetic Blocks"); + private final SettingGroup sgDoubleChest = this.settings.createGroup("Double chest detector"); + + + + + + + + private final Setting> Unnaturalblocks = sgUnnaturalBlocks.add(new BlockListSetting.Builder() + .name("Unnatural Blocks") + .description("Blocks to search for.") + .onChanged(blocks1 -> { + if (isActive() && Utils.canUpdate()) onActivate(); + }) + .defaultValue(DEFAULT_NATURAL_BLOCKS) + .build() + ); + + private final Setting UnnaturalMinHeight = sgUnnaturalBlocks.add(new IntSetting.Builder() + .name("Min height") + .description("Minimum height to detect blocks") + .defaultValue(64) + .range(-64, 319) + .sliderRange(-64, 319) + .build() + ); + + private final Setting UnnaturalBlockThreshold = sgUnnaturalBlocks.add(new IntSetting.Builder() + .name("Block Threshold") + .description("Minimum amount of unnatural blocks") + .defaultValue(64) + .range(0, 500) + .sliderRange(0, 500) + .build() + ); + + private final Setting UnnaturalBlocksColor = sgUnnaturalBlocks.add(new ColorSetting.Builder() + .name("Unnatural Blocks Color") + .description("The color of the marker.") + .defaultValue(Color.GREEN) + .build() + ); + + + + + + + + + + + + private final Setting> Syntheticblocks = sgSyntheticBlocks.add(new BlockListSetting.Builder() + .name("Unnatural Blocks") + .description("Blocks to search for.") + .onChanged(blocks1 -> { + if (isActive() && Utils.canUpdate()) onActivate(); + }) + .defaultValue(DEFAULT_SYNTHETIC_BLOCKS) + .build() + ); + + private final Setting SyntheticBlockThreshold = sgSyntheticBlocks.add(new IntSetting.Builder() + .name("Block Threshold") + .description("Minimum amount of unnatural blocks") + .defaultValue(3) + .range(0, 20) + .sliderRange(0, 20) + .build() + ); + + private final Setting SyntheticBlocksColor = sgSyntheticBlocks.add(new ColorSetting.Builder() + .name("Synthetic Blocks Color") + .description("The color of the marker.") + .defaultValue(Color.MAGENTA) + .build() + ); + + + + + + private final Setting DoubleChestColor = sgDoubleChest.add(new ColorSetting.Builder() + .name("Synthetic Blocks Color") + .description("The color of the marker.") + .defaultValue(Color.RED) + .build() + ); + + + + + + + + private static final int CHUNK_CENTER_OFFSET = 8; + + private class ChunkPosition { + int start_x; + int start_y; + int start_z; + int end_x; + int end_y; + int end_z; + + public Vec3d getCenterPos() { + return new Vec3d(start_x + CHUNK_CENTER_OFFSET, end_y, start_z + CHUNK_CENTER_OFFSET); + } + } + + List AlreadyScannedChunks = new ArrayList<>(); + + List UnnaturalPositions = new ArrayList<>(); + List UnnaturalChunkPositions = new ArrayList<>(); + List SyntheticPositions = new ArrayList<>(); + + List SyntheticChunkPositions = new ArrayList<>(); + List PlaceBlocks = new ArrayList<>(); + + @Override + public void onActivate() { + UnnaturalPositions.clear(); + UnnaturalChunkPositions.clear(); + SyntheticPositions.clear(); + SyntheticChunkPositions.clear(); + AlreadyScannedChunks.clear(); + PlaceBlocks.clear(); + AlreadyChosenChunks.clear(); + + info(BaritoneAPI.getProvider().getPrimaryBaritone().toString()); + } + + @EventHandler + private void onChunkData(ChunkDataEvent event) { + WorldChunk chunk = event.chunk(); + + for(int i = 0; i < AlreadyScannedChunks.size(); i++) { + if (chunk.getPos().getStartX() == AlreadyScannedChunks.get(i).start_x && + chunk.getPos().getStartZ() == AlreadyScannedChunks.get(i).start_z) { + return; + } + } + + List UnnaturalBlocks = Unnaturalblocks.get(); + List SyntheticBlocks = Syntheticblocks.get(); + + List chests = new ArrayList<>(); + List SpawnerYLevels = new ArrayList<>(); + + BlockPos.Mutable blockPos = new BlockPos.Mutable(); + + int UnnaturalBlockCount = 0; + int SyntheticBlockCount = 0; +// List positions = new ArrayList<>(); + int minSearchY = UnnaturalMinHeight.get(); + + int maxY = -5000; + int minY = 5000; + + for(int x = chunk.getPos().getStartX(); x <= chunk.getPos().getEndX(); ++x) { + for(int z = chunk.getPos().getStartZ(); z <= chunk.getPos().getEndZ(); ++z) { + int height = chunk.getHeightmap(Heightmap.Type.WORLD_SURFACE).get(x - chunk.getPos().getStartX(), z - chunk.getPos().getStartZ()); + + if(height > maxY){ + maxY = height; + } + +// for(int y = MeteorClient.mc.world.getBottomY(); y < minHeight; ++y) { + for(int y = Math.max(MeteorClient.mc.world.getBottomY(), minSearchY); y < height; ++y) { + blockPos.set(x, y, z); + BlockState bs = chunk.getBlockState(blockPos); + Vec3d curpos = new Vec3d(x, y, z); + + if(!UnnaturalBlocks.contains(bs.getBlock())) { + UnnaturalPositions.add(curpos); + UnnaturalBlockCount++; +// info(bs.getBlock().getName()); + if(y < minY){ + minY = y; + } + } + + if(SyntheticBlocks.contains(bs.getBlock())) { + SyntheticPositions.add(curpos); + SyntheticBlockCount++; +// info(bs.getBlock().getName()); + if(y < minY){ + minY = y; + } + } + + if(bs.getBlock().equals(Blocks.CHEST)) + chests.add(curpos); + + if(bs.getBlock().equals(Blocks.SPAWNER)) + SpawnerYLevels.add(y); + } + } + } + + ChunkPosition c = new ChunkPosition(); + c.start_x = chunk.getPos().getStartX(); + c.start_y = minY; + c.start_z = chunk.getPos().getStartZ(); + c.end_x = chunk.getPos().getEndX() + 1; + c.end_y = maxY; + c.end_z = chunk.getPos().getEndZ() + 1; + + if(UnnaturalBlockCount >= UnnaturalBlockThreshold.get()) { + UnnaturalChunkPositions.add(c); + info("Unnatural chunk found (" + c.start_x + ", " + c.start_z + ")"); + } + if(SyntheticBlockCount >= SyntheticBlockThreshold.get()) { + SyntheticChunkPositions.add(c); + info("Base chunk found using synthetic blocks: (" + c.start_x + ", " + c.start_z + ")"); + } + + for(int i = 0; i < chests.size(); i++){ + Vec3d chest = chests.get(i); + + if(SpawnerYLevels.contains((int) chest.y)) + continue; + + blockPos.set(chest.x+1, chest.y, chest.z); + Block bs1 = chunk.getBlockState(blockPos).getBlock(); + blockPos.set(chest.x-1, chest.y, chest.z); + Block bs2 = chunk.getBlockState(blockPos).getBlock(); + blockPos.set(chest.x, chest.y, chest.z+1); + Block bs3 = chunk.getBlockState(blockPos).getBlock(); + blockPos.set(chest.x, chest.y, chest.z-1); + Block bs4 = chunk.getBlockState(blockPos).getBlock(); + + if((bs1.equals(Blocks.CHEST) || + bs2.equals(Blocks.CHEST) || + bs3.equals(Blocks.CHEST) || + bs4.equals(Blocks.CHEST)) && + !SyntheticChunkPositions.contains(c)) { + SyntheticChunkPositions.add(c); + info("Base chunk found using double chests: (" + c.start_x + ", " + c.start_z + ")"); + } + } + + + AlreadyScannedChunks.add(c); + +// false_positions.addAll(positions); + } + + @EventHandler + private void onRender(Render3DEvent event) { + for(Vec3d pos : UnnaturalPositions) { + Box tmpbox = new Box( + pos.x, pos.y, pos.z, pos.x+1, pos.y+1, pos.z+1 + ); + event.renderer.box(tmpbox, UnnaturalBlocksColor.get(), UnnaturalBlocksColor.get(), ShapeMode.Lines, 0); + } + for(ChunkPosition chunkpos : UnnaturalChunkPositions) { + Box tmpbox = new Box( + chunkpos.start_x, + chunkpos.start_y, + chunkpos.start_z, + chunkpos.end_x, + chunkpos.end_y, + chunkpos.end_z + ); + event.renderer.box(tmpbox, UnnaturalBlocksColor.get(), UnnaturalBlocksColor.get(), ShapeMode.Lines, 0); + } + + + + + + for(Vec3d pos : SyntheticPositions) { + Box tmpbox = new Box( + pos.x, pos.y, pos.z, pos.x+1, pos.y+1, pos.z+1 + ); + event.renderer.box(tmpbox, SyntheticBlocksColor.get(), SyntheticBlocksColor.get(), ShapeMode.Lines, 0); + } + for(ChunkPosition chunkpos : SyntheticChunkPositions) { + Box tmpbox = new Box( + chunkpos.start_x, + chunkpos.start_y, + chunkpos.start_z, + chunkpos.end_x, + chunkpos.end_y + 1, + chunkpos.end_z + ); + event.renderer.box(tmpbox, SyntheticBlocksColor.get(), SyntheticBlocksColor.get(), ShapeMode.Lines, 0); + } + + for(Vec3d pos : PlaceBlocks) { + Box tmpbox = new Box( + pos.x, pos.y, pos.z, pos.x+1, pos.y+1, pos.z+1 + ); + event.renderer.box(tmpbox, Color.WHITE, Color.WHITE, ShapeMode.Lines, 0); + } + + } + + + + + + + private double XZDistance(Vec3d p1, Vec3d p2){ + return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.z - p2.z, 2)); + } + + private List AlreadyChosenChunks = new ArrayList<>(); + private Thread runThread; + + public void generate() { + PlaceBlocks.clear(); + AlreadyChosenChunks.clear(); + + runThread = new Thread(() -> { + try { + for (int i = 0; i < SyntheticChunkPositions.size(); i++) { + + if (AlreadyChosenChunks.contains(SyntheticChunkPositions.get(i))) continue; + Vec3d originpos = SyntheticChunkPositions.get(i).getCenterPos(); + List chunks = new ArrayList<>(); + chunks.add(originpos); + SearchNearbyChunks(chunks, originpos); + + info("Found region with " + chunks.size() + " chunks"); + info("Generating path"); + + int maxY = Integer.MIN_VALUE; + + int sumX = 0; + int sumZ = 0; + + List targetTiles = new ArrayList<>(); + for (int a = 0; a < chunks.size(); a++) { + Vec3d chunk = chunks.get(a); + + maxY = Math.max(maxY, (int) chunk.y); + + LavacastGenerator.Position pos = new LavacastGenerator.Position( + (int) ((chunk.x - CHUNK_CENTER_OFFSET) / 16), + (int) ((chunk.z - CHUNK_CENTER_OFFSET) / 16) + ); + + targetTiles.add(pos); + + sumX += pos.x; + sumZ += pos.z; + } + + + LavacastGenerator.Position origin = new LavacastGenerator.Position( + (int) Math.round((double) sumX / targetTiles.size()), + (int) Math.round((double) sumZ / targetTiles.size()) + ); + + + LavacastGenerator.MovementNode path = new LavacastGenerator.MovementNode(origin, 0); + List visited = new ArrayList<>(); + visited.add(origin); + + while (!visited.containsAll(targetTiles)) { + path.expand(targetTiles, visited); + } + + // info("Found path with " + countMoves(optimizedPath) + " Moves"); + + int Yoffset = (path.depthBeyond * 16) + maxY + 16; + + if (path != null) + recurseAddBlocks(path, 0, null, Yoffset); + + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath( + new GoalBlock( + (path.position.x * 16) + CHUNK_CENTER_OFFSET, + Yoffset + 1, + (path.position.z * 16) + CHUNK_CENTER_OFFSET + ) + ); + + while(BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().isActive()) + Thread.sleep(100); + + recurseBuild(path, 0, null, Yoffset); + + +// BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath( +// new GoalBlock( +// (path.position.x * 16) + CHUNK_CENTER_OFFSET, +// 0, +// (path.position.z * 16) + CHUNK_CENTER_OFFSET +// ) +// ); + } + } catch(InterruptedException v){ + System.out.println(v); + } + }); + + runThread.start(); + } + + @Override + public void onDeactivate() { + if(runThread != null) + runThread.interrupt(); + } + + private void recurseBuild(LavacastGenerator.MovementNode node, int depth, LavacastGenerator.Position prevPosition, int Yoffset) { + if(prevPosition != null) { + int deltaX = node.position.x - prevPosition.x; + int deltaZ = node.position.z - prevPosition.z; + +// BaritoneAPI.getProvider().getPrimaryBaritone().getProcess( +// new GoalBlock( +// (path.position.x * 16) + CHUNK_CENTER_OFFSET, +// Yoffset + 1, +// (path.position.z * 16) + CHUNK_CENTER_OFFSET +// ) +// ); + +// while(BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().isActive()) +// Thread.sleep(100); + +// for (int i = -16; i < 0; i++) { +// PlaceBlocks.add(new Vec3d( +// (node.position.x * 16) + CHUNK_CENTER_OFFSET + (i * deltaX), +// Yoffset - (depth * 16) - i, +// (node.position.z * 16) + CHUNK_CENTER_OFFSET + (i * deltaZ) +// )); +// } + } +// PlaceBlocks.add(new Vec3d( +// (node.position.x * 16) + CHUNK_CENTER_OFFSET, +// Yoffset - (depth * 16), +// (node.position.z * 16) + CHUNK_CENTER_OFFSET +// )); +// } + + if(node.PosX != null) + recurseAddBlocks(node.PosX, depth+1, node.position, Yoffset); + if(node.PosZ != null) + recurseAddBlocks(node.PosZ, depth+1, node.position, Yoffset); + if(node.NegX != null) + recurseAddBlocks(node.NegX, depth+1, node.position, Yoffset); + if(node.NegZ != null) + recurseAddBlocks(node.NegZ, depth+1, node.position, Yoffset); + } + + + + private void recurseAddBlocks(LavacastGenerator.MovementNode node, int depth, LavacastGenerator.Position prevPosition, int Yoffset) { + + if(prevPosition != null) { + int deltaX = node.position.x - prevPosition.x; + int deltaZ = node.position.z - prevPosition.z; + + for (int i = -16; i < 0; i++) { + PlaceBlocks.add(new Vec3d( + (node.position.x * 16) + CHUNK_CENTER_OFFSET + (i * deltaX), + Yoffset - (depth * 16) - i, + (node.position.z * 16) + CHUNK_CENTER_OFFSET + (i * deltaZ) + )); + } + }else{ + PlaceBlocks.add(new Vec3d( + (node.position.x * 16) + CHUNK_CENTER_OFFSET, + Yoffset - (depth * 16), + (node.position.z * 16) + CHUNK_CENTER_OFFSET + )); + } + + if(node.PosX != null) + recurseAddBlocks(node.PosX, depth+1, node.position, Yoffset); + if(node.PosZ != null) + recurseAddBlocks(node.PosZ, depth+1, node.position, Yoffset); + if(node.NegX != null) + recurseAddBlocks(node.NegX, depth+1, node.position, Yoffset); + if(node.NegZ != null) + recurseAddBlocks(node.NegZ, depth+1, node.position, Yoffset); + + } + + + private void SearchNearbyChunks(List chunks, Vec3d origin) { + for(int i = 0; i < UnnaturalChunkPositions.size(); i++){ + ChunkPosition chunkpos = UnnaturalChunkPositions.get(i); +// chunkpos.getEndPos() + Vec3d pos = chunkpos.getCenterPos(); + if(chunks.contains(pos)) continue; + if(AlreadyChosenChunks.contains(chunkpos)) continue; + double distance = XZDistance(pos, origin); + if(distance > 32) continue; + + chunks.add(pos); + AlreadyChosenChunks.add(chunkpos); + + SearchNearbyChunks(chunks, pos); + } + for(int i = 0; i < SyntheticChunkPositions.size(); i++){ + ChunkPosition chunkpos = SyntheticChunkPositions.get(i); +// chunkpos.getEndPos() + Vec3d pos = chunkpos.getCenterPos(); + if(chunks.contains(pos)) continue; + if(AlreadyChosenChunks.contains(chunkpos)) continue; + double distance = XZDistance(pos, origin); + if(distance > 32) continue; + + chunks.add(pos); + AlreadyChosenChunks.add(chunkpos); + + SearchNearbyChunks(chunks, pos); + } + } + + + + + + + + + + + + public static final List DEFAULT_SYNTHETIC_BLOCKS = List.of( + Blocks.CRAFTING_TABLE, + Blocks.FURNACE, +// Blocks.CHEST, + Blocks.ENDER_CHEST, + Blocks.NETHER_PORTAL + ); + + public static final List DEFAULT_NATURAL_BLOCKS = List.of( + Blocks.AIR, + Blocks.CAVE_AIR, + Blocks.VOID_AIR, + + Blocks.GRASS_BLOCK, + Blocks.SHORT_GRASS, + Blocks.TALL_GRASS, + Blocks.SEAGRASS, + Blocks.TALL_SEAGRASS, + Blocks.KELP, + Blocks.KELP_PLANT, + Blocks.CLAY, + + Blocks.VINE, + Blocks.BAMBOO, + Blocks.FERN, + Blocks.LARGE_FERN, + Blocks.LILAC, + Blocks.LILY_PAD, + Blocks.LILY_OF_THE_VALLEY, + Blocks.DANDELION, + Blocks.POPPY, + Blocks.BLUE_ORCHID, + Blocks.ALLIUM, + Blocks.MUSHROOM_STEM, + Blocks.RED_MUSHROOM, + Blocks.BROWN_MUSHROOM, + Blocks.RED_MUSHROOM_BLOCK, + Blocks.BROWN_MUSHROOM_BLOCK, + Blocks.SUGAR_CANE, + Blocks.PEONY, + Blocks.ROSE_BUSH, + Blocks.AZURE_BLUET, + Blocks.RED_TULIP, + Blocks.ORANGE_TULIP, + Blocks.WHITE_TULIP, + Blocks.CORNFLOWER, + Blocks.PINK_TULIP, + Blocks.BEE_NEST, + Blocks.OXEYE_DAISY, + Blocks.PUMPKIN, + Blocks.MELON, + Blocks.PUMPKIN, + Blocks.PINK_PETALS, +// Block + + Blocks.MOSS_BLOCK, + Blocks.MOSS_CARPET, + Blocks.AZALEA, + Blocks.FLOWERING_AZALEA, + Blocks.FLOWERING_AZALEA_LEAVES, + Blocks.CAVE_VINES, + Blocks.CAVE_VINES_PLANT, + Blocks.SPORE_BLOSSOM, + Blocks.AZALEA_LEAVES, + Blocks.ROOTED_DIRT, + Blocks.SWEET_BERRY_BUSH, + + Blocks.PACKED_ICE, + Blocks.ICE, + Blocks.SNOW, + Blocks.SNOW_BLOCK, + Blocks.MAGMA_BLOCK, + Blocks.OBSIDIAN, + Blocks.COARSE_DIRT, + Blocks.PODZOL, + Blocks.POWDER_SNOW, + Blocks.BLUE_ICE, + + Blocks.POLISHED_TUFF, + Blocks.CHISELED_TUFF, + Blocks.WAXED_CUT_COPPER, + Blocks.WAXED_CUT_COPPER_SLAB, + Blocks.WAXED_WEATHERED_COPPER_BULB, + Blocks.WAXED_CHISELED_COPPER, + Blocks.WAXED_EXPOSED_COPPER_BULB, + Blocks.WAXED_COPPER_GRATE, + Blocks.WAXED_OXIDIZED_COPPER_TRAPDOOR, + Blocks.TUFF_BRICKS, + Blocks.CHISELED_TUFF_BRICKS, + Blocks.TRIAL_SPAWNER, + Blocks.VAULT, + Blocks.WAXED_COPPER_BLOCK, + Blocks.WAXED_COPPER_BULB, + Blocks.WAXED_OXIDIZED_COPPER, + Blocks.WAXED_OXIDIZED_COPPER_BULB, + Blocks.WAXED_OXIDIZED_CUT_COPPER, + Blocks.WAXED_OXIDIZED_CUT_COPPER_STAIRS, + + Blocks.LAVA, + Blocks.WATER, + Blocks.BUBBLE_COLUMN, + + Blocks.DIRT, + Blocks.STONE, + Blocks.ANDESITE, + Blocks.DIORITE, + Blocks.GRANITE, + Blocks.TUFF, + Blocks.GRAVEL, + Blocks.DIRT_PATH, + Blocks.MYCELIUM, + Blocks.DEAD_BUSH, + + Blocks.INFESTED_STONE, + Blocks.INFESTED_DEEPSLATE, + + Blocks.AMETHYST_BLOCK, + Blocks.AMETHYST_CLUSTER, + Blocks.BUDDING_AMETHYST, + Blocks.LARGE_AMETHYST_BUD, + Blocks.MEDIUM_AMETHYST_BUD, + Blocks.SMALL_AMETHYST_BUD, + + Blocks.SPAWNER, + Blocks.COBBLESTONE, + Blocks.MOSSY_COBBLESTONE, + +// Blocks.OAK_PLANKS, +// Blocks.CHAIN, +// Blocks.COBWEB, +// Blocks.OAK_FENCE, + Blocks.RAIL, + + + + Blocks.DEEPSLATE, + Blocks.DRIPSTONE_BLOCK, + Blocks.POINTED_DRIPSTONE, + Blocks.SMALL_DRIPLEAF, + Blocks.BIG_DRIPLEAF, + Blocks.BIG_DRIPLEAF_STEM, + Blocks.SCULK_CATALYST, + Blocks.SCULK_SENSOR, + Blocks.SCULK_VEIN, + Blocks.SCULK, + Blocks.SMOOTH_BASALT, + Blocks.CALCITE, + Blocks.GLOW_LICHEN, + + Blocks.COAL_ORE, + Blocks.DEEPSLATE_COAL_ORE, + Blocks.COPPER_ORE, + Blocks.DEEPSLATE_COPPER_ORE, + Blocks.DIAMOND_ORE, + Blocks.DEEPSLATE_DIAMOND_ORE, + Blocks.EMERALD_ORE, + Blocks.DEEPSLATE_EMERALD_ORE, + Blocks.GOLD_ORE, + Blocks.DEEPSLATE_GOLD_ORE, + Blocks.IRON_ORE, + Blocks.DEEPSLATE_IRON_ORE, + Blocks.LAPIS_ORE, + Blocks.DEEPSLATE_LAPIS_ORE, + Blocks.REDSTONE_ORE, + Blocks.DEEPSLATE_REDSTONE_ORE, + + Blocks.RAW_IRON_BLOCK, + Blocks.RAW_COPPER_BLOCK, + + Blocks.SAND, + Blocks.RED_SAND, + Blocks.SANDSTONE, + + Blocks.ACACIA_LOG, + Blocks.BIRCH_LOG, + Blocks.CHERRY_LOG, + Blocks.DARK_OAK_LOG, + Blocks.MANGROVE_LOG, + Blocks.OAK_LOG, + Blocks.JUNGLE_LOG, + Blocks.PALE_OAK_LOG, + Blocks.SPRUCE_LOG, + + Blocks.ACACIA_LEAVES, + Blocks.BIRCH_LEAVES, + Blocks.CHERRY_LEAVES, + Blocks.DARK_OAK_LEAVES, + Blocks.MANGROVE_LEAVES, + Blocks.OAK_LEAVES, + Blocks.JUNGLE_LEAVES, + Blocks.PALE_OAK_LEAVES, + Blocks.SPRUCE_LEAVES, + + Blocks.BEDROCK + ); + + + +} diff --git a/src/main/java/com/example/addon/modules/ModuleExample.java b/src/main/java/com/example/addon/modules/ModuleExample.java new file mode 100755 index 0000000..10a4bb6 --- /dev/null +++ b/src/main/java/com/example/addon/modules/ModuleExample.java @@ -0,0 +1,66 @@ +package com.example.addon.modules; + +import com.example.addon.AddonTemplate; +import meteordevelopment.meteorclient.events.render.Render3DEvent; +import meteordevelopment.meteorclient.renderer.ShapeMode; +import meteordevelopment.meteorclient.settings.ColorSetting; +import meteordevelopment.meteorclient.settings.DoubleSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.render.color.Color; +import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; + +public class ModuleExample extends Module { + private final SettingGroup sgGeneral = this.settings.getDefaultGroup(); + private final SettingGroup sgRender = this.settings.createGroup("Render"); + + /** + * Example setting. + * The {@code name} parameter should be in kebab-case. + * If you want to access the setting from another class, simply make the setting {@code public}, and use + * {@link meteordevelopment.meteorclient.systems.modules.Modules#get(Class)} to access the {@link Module} object. + */ + private final Setting scale = sgGeneral.add(new DoubleSetting.Builder() + .name("scale") + .description("The size of the marker.") + .defaultValue(2.0d) + .range(0.5d, 10.0d) + .build() + ); + + private final Setting color = sgRender.add(new ColorSetting.Builder() + .name("color") + .description("The color of the marker.") + .defaultValue(Color.MAGENTA) + .build() + ); + + /** + * The {@code name} parameter should be in kebab-case. + */ + public ModuleExample() { + super(AddonTemplate.CATEGORY, "world-origin", "An example module that highlights the center of the world."); + } + + /** + * Example event handling method. + * Requires {@link AddonTemplate#getPackage()} to be setup correctly, will fail silently otherwise. + */ + @EventHandler + private void onRender3d(Render3DEvent event) { + // Create & stretch the marker object + Box marker = new Box(BlockPos.ORIGIN); + marker.stretch( + scale.get() * marker.getLengthX(), + scale.get() * marker.getLengthY(), + scale.get() * marker.getLengthZ() + ); + + // Render the marker based on the color setting + event.renderer.box(marker, color.get(), color.get(), ShapeMode.Both, 0); + } +} diff --git a/src/main/resources/addon-template.mixins.json b/src/main/resources/addon-template.mixins.json new file mode 100755 index 0000000..39d1c99 --- /dev/null +++ b/src/main/resources/addon-template.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "com.example.addon.mixin", + "compatibilityLevel": "JAVA_21", + "client": [ + "ExampleMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/assets/template/icon.png b/src/main/resources/assets/template/icon.png new file mode 100755 index 0000000..3fb2e7f Binary files /dev/null and b/src/main/resources/assets/template/icon.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100755 index 0000000..bb8c721 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,31 @@ +{ + "schemaVersion": 1, + "id": "addon-template", + "version": "${version}", + "name": "Addon Template", + "description": "An addon template for Meteor Client addons.", + "authors": [ + "seasnail" + ], + "contact": { + "repo": "https://github.com/MeteorDevelopment/meteor-addon-template" + }, + "icon": "assets/template/icon.png", + "environment": "client", + "entrypoints": { + "meteor": [ + "com.example.addon.AddonTemplate" + ] + }, + "mixins": [ + "addon-template.mixins.json" + ], + "custom": { + "meteor-client:color": "225,25,25" + }, + "depends": { + "java": ">=21", + "minecraft": ["${mc_version}"], + "meteor-client": "*" + } +}