mirror of
https://github.com/AutismDevelopment/Autism-Client.git
synced 2026-10-28 19:39:48 +00:00
Release the tag update
This commit is contained in:
commit
9e00f40996
977 changed files with 219163 additions and 0 deletions
15
addon-templates/advanced/.editorconfig
Normal file
15
addon-templates/advanced/.editorconfig
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{json,yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
45
addon-templates/advanced/.github/workflows/build.yml
vendored
Normal file
45
addon-templates/advanced/.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
# NOTE: the build needs the AUTISM Client API artifact (com.autismclient:autism) to be resolvable.
|
||||
# mavenLocal() is empty on a fresh CI runner, so make it available one of these ways:
|
||||
# - publish AUTISM to a maven repo your build.gradle.kts lists (GitHub Packages, a maven server), or
|
||||
# - commit the AUTISM jar into a `libs/` folder and add `flatDir { dirs("libs") }` to repositories.
|
||||
- name: Build
|
||||
run: ./gradlew build --stacktrace
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: addon-jar
|
||||
path: build/libs/*.jar
|
||||
|
||||
- name: Release dev build
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: dev
|
||||
name: Dev Build
|
||||
prerelease: true
|
||||
files: build/libs/*.jar
|
||||
6
addon-templates/advanced/.gitignore
vendored
Normal file
6
addon-templates/advanced/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.gradle/
|
||||
build/
|
||||
run/
|
||||
*.log
|
||||
.idea/
|
||||
*.iml
|
||||
95
addon-templates/advanced/README.md
Normal file
95
addon-templates/advanced/README.md
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# AUTISM Advanced Addon Template
|
||||
|
||||
A standalone reference addon for AUTISM Client. It registers one of each supported extension point, so
|
||||
you can copy it when you need the full API surface.
|
||||
|
||||
Start small: keep `ExampleModule`, build once, then add macro actions, commands, HUD elements, events,
|
||||
or mixins as needed.
|
||||
|
||||
## What It Demonstrates
|
||||
|
||||
| Extension point | File |
|
||||
| --- | --- |
|
||||
| Addon lifecycle | `ExampleAddon` |
|
||||
| Module | `modules/ExampleModule` |
|
||||
| Macro action | `macro/ExampleSayAction` |
|
||||
| Macro condition | `macro/ExampleHeightCondition` + `macro/ExampleCondition` |
|
||||
| Macro preset | `macro/ExamplePresets` |
|
||||
| Command | `commands/ExampleCommand` |
|
||||
| HUD element | `hud/ExampleHud` |
|
||||
| Event hooks | `events/ExampleEvents` |
|
||||
| Mixin | `mixin/ExampleMixin` + `autism-advanced-addon-template.mixins.json` |
|
||||
|
||||
Presets are first-class addon entries. `ExamplePresets` appears in the macro editor `Presets` picker
|
||||
under this addon's category, and it can insert any normal stack of macro actions.
|
||||
|
||||
Your modules, macro actions, conditions and presets automatically group under a category named after
|
||||
your addon from `fabric.mod.json`. Custom categories are scoped under your addon so they cannot collide
|
||||
with built-ins or another addon.
|
||||
|
||||
## Build
|
||||
|
||||
1. In the AUTISM Client project, publish the API to your local Maven repo:
|
||||
```sh
|
||||
./gradlew publishToMavenLocal
|
||||
```
|
||||
2. Make sure the `autism` version in `gradle/libs.versions.toml` matches what you published.
|
||||
3. Build this addon:
|
||||
```sh
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
The addon jar lands in `build/libs/`.
|
||||
|
||||
## Run
|
||||
|
||||
Drop both jars into your `mods/` folder:
|
||||
|
||||
- the AUTISM Client jar;
|
||||
- this addon's jar from `build/libs/`.
|
||||
|
||||
## Make It Yours
|
||||
|
||||
Recommended (any OS, from the AUTISM Client repo root):
|
||||
|
||||
```sh
|
||||
python addon-templates/addon-toolkit.py setup --template advanced --output ../MyAdvancedAddon
|
||||
```
|
||||
|
||||
Windows PowerShell works the same: `.\addon-templates\addon-toolkit.ps1 -Action Setup -Template advanced -OutputPath ..\MyAdvancedAddon`. See `../README.md` for the Gradle (`./gradlew newAddon`) and `.sh` variants.
|
||||
|
||||
The toolkit asks for the addon name, output folder, version, and author. Blank version bumps the current
|
||||
template version by one patch step. It derives the boring stuff and rewrites Gradle files, package paths,
|
||||
`fabric.mod.json`, entrypoints, and the mixin config in one shot.
|
||||
|
||||
Manual path:
|
||||
|
||||
1. Rename the package `com.example.addon`.
|
||||
2. Change `ExampleAddon.ID`.
|
||||
3. Update `src/main/resources/fabric.mod.json`: `id`, `name`, `entrypoints`, `mixins`, and `autism:color`.
|
||||
4. Rename `autism-advanced-addon-template.mixins.json` and update its `package`.
|
||||
5. Keep `apiVersion()` and the `autism` dependency range honest for the client version you target.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```text
|
||||
addon-templates/advanced/
|
||||
|-- gradle/
|
||||
|-- src/main/java/com/example/addon/
|
||||
| |-- ExampleAddon.java
|
||||
| |-- ExampleInit.java
|
||||
| |-- modules/ExampleModule.java
|
||||
| |-- macro/ExampleSayAction.java
|
||||
| |-- macro/ExampleHeightCondition.java
|
||||
| |-- macro/ExampleCondition.java
|
||||
| |-- macro/ExamplePresets.java
|
||||
| |-- commands/ExampleCommand.java
|
||||
| |-- hud/ExampleHud.java
|
||||
| |-- events/ExampleEvents.java
|
||||
| `-- mixin/ExampleMixin.java
|
||||
|-- src/main/resources/
|
||||
| |-- fabric.mod.json
|
||||
| `-- autism-advanced-addon-template.mixins.json
|
||||
|-- build.gradle.kts
|
||||
`-- gradle.properties
|
||||
```
|
||||
67
addon-templates/advanced/build.gradle.kts
Normal file
67
addon-templates/advanced/build.gradle.kts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
plugins {
|
||||
alias(libs.plugins.fabric.loom)
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = properties["archives_base_name"] as String
|
||||
version = libs.versions.mod.version.get()
|
||||
group = properties["maven_group"] as String
|
||||
}
|
||||
|
||||
repositories {
|
||||
// AUTISM Client is consumed from your local Maven repo. In the AUTISM project run:
|
||||
// ./gradlew publishToMavenLocal
|
||||
mavenLocal()
|
||||
maven("https://maven.fabricmc.net/") { name = "Fabric" }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Mirrors the AUTISM Client build: official Mojang mappings are implicit for the configured version, so there is no
|
||||
// explicit `mappings(...)` line and dependencies use plain `implementation`.
|
||||
minecraft(libs.minecraft)
|
||||
implementation(libs.fabric.loader)
|
||||
implementation(libs.fabric.api)
|
||||
|
||||
// The AUTISM Client API (published to mavenLocal from the AUTISM project).
|
||||
implementation(libs.autism)
|
||||
}
|
||||
|
||||
// Turns an exact Minecraft version (e.g. "26.2") into a compatible range ("~26.2") so the addon
|
||||
// keeps loading across patch releases instead of pinning one exact build.
|
||||
fun toMinecraftCompat(version: String): String {
|
||||
val m = Regex("""^(\d+)\.(\d+)(?:\.(\d+))?$""").matchEntire(version)
|
||||
?: return version
|
||||
val (year, drop, _) = m.destructured
|
||||
return "~$year.$drop"
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
val propertyMap = mapOf(
|
||||
"version" to project.version,
|
||||
"mc_version" to libs.versions.minecraft.get(),
|
||||
"mc_compat" to toMinecraftCompat(libs.versions.minecraft.get()),
|
||||
"fabric_api_version" to libs.versions.fabric.api.get(),
|
||||
"autism_api_version" to libs.versions.autism.get()
|
||||
)
|
||||
inputs.properties(propertyMap)
|
||||
filteringCharset = "UTF-8"
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand(propertyMap)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_25
|
||||
targetCompatibility = JavaVersion.VERSION_25
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
}
|
||||
|
||||
withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(25)
|
||||
}
|
||||
}
|
||||
7
addon-templates/advanced/gradle.properties
Normal file
7
addon-templates/advanced/gradle.properties
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
maven_group=com.example.addon
|
||||
archives_base_name=autism-advanced-addon-template
|
||||
23
addon-templates/advanced/gradle/libs.versions.toml
Normal file
23
addon-templates/advanced/gradle/libs.versions.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# In this repo these are auto-synced from the client: run `gradlew syncAddonTemplateVersions` (it also runs
|
||||
# on publishToMavenLocal), which pins minecraft/fabric-loader/fabric-api/loom/autism to the client's
|
||||
# gradle/libs.versions.toml. In a copied-out addon, set them to the AUTISM Client release you build against.
|
||||
[versions]
|
||||
mod-version = "1.0.0"
|
||||
|
||||
minecraft = "26.2"
|
||||
fabric-loader = "0.19.3"
|
||||
fabric-api = "0.152.2+26.2"
|
||||
# The AUTISM Client release you compile against. The generated fabric.mod.json depends on `>=` this version, so a
|
||||
# built addon keeps loading on newer hosts in the same major line (the API-version handshake gates real breaks).
|
||||
autism = "3.4"
|
||||
|
||||
loom = "1.17.11"
|
||||
|
||||
[libraries]
|
||||
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
|
||||
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
|
||||
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }
|
||||
autism = { module = "com.autismclient:autism", version.ref = "autism" }
|
||||
|
||||
[plugins]
|
||||
fabric-loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" }
|
||||
BIN
addon-templates/advanced/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
addon-templates/advanced/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
addon-templates/advanced/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
addon-templates/advanced/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
248
addon-templates/advanced/gradlew
vendored
Executable file
248
addon-templates/advanced/gradlew
vendored
Executable file
|
|
@ -0,0 +1,248 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# 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/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# 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##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
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" )
|
||||
|
||||
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
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# 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" "$@"
|
||||
93
addon-templates/advanced/gradlew.bat
vendored
Normal file
93
addon-templates/advanced/gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
@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
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@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. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
: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
|
||||
9
addon-templates/advanced/settings.gradle.kts
Normal file
9
addon-templates/advanced/settings.gradle.kts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://maven.fabricmc.net/") { name = "Fabric" }
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "autism-advanced-addon-template"
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.example.addon;
|
||||
|
||||
import autismclient.api.AutismAddon;
|
||||
import autismclient.api.AutismAddons;
|
||||
import autismclient.api.ApiVersion;
|
||||
import autismclient.api.macro.MacroActionEntry;
|
||||
|
||||
import com.example.addon.commands.ExampleCommand;
|
||||
import com.example.addon.events.ExampleEvents;
|
||||
import com.example.addon.hud.ExampleHud;
|
||||
import com.example.addon.macro.ExampleHeightCondition;
|
||||
import com.example.addon.macro.ExamplePresets;
|
||||
import com.example.addon.macro.ExampleSayAction;
|
||||
import com.example.addon.modules.ExampleModule;
|
||||
|
||||
// Addon entrypoint (the "autism" entrypoint in fabric.mod.json). Start small:
|
||||
// register only ExampleModule first, launch the client, then add macro/actions/HUD/events as needed.
|
||||
// Modules, actions, conditions and presets all auto-group under a category named after this addon.
|
||||
public final class ExampleAddon extends AutismAddon {
|
||||
public static final String ID = "autism-advanced-addon-template";
|
||||
|
||||
@Override
|
||||
public int apiVersion() {
|
||||
return ApiVersion.CURRENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
AutismAddons.modules().register(new ExampleModule());
|
||||
|
||||
// Action: appears in the "add action" picker.
|
||||
AutismAddons.macroActions().register(MacroActionEntry.local("say", ExampleSayAction::new)
|
||||
.picker("Say", "Send a chat message.")
|
||||
.build());
|
||||
|
||||
// Condition: appears in the "add condition" picker (it waits).
|
||||
AutismAddons.macroActions().register(MacroActionEntry.local("wait-height", ExampleHeightCondition::new)
|
||||
.condition("Wait Height", "Wait until the player is at or above a Y level.")
|
||||
.build());
|
||||
|
||||
AutismAddons.presets().register("Reach Height", "Wait for Y 80, then say.",
|
||||
ExamplePresets::reachHeightThenSay);
|
||||
|
||||
AutismAddons.commands().register(new ExampleCommand());
|
||||
AutismAddons.hud().register(new ExampleHud());
|
||||
ExampleEvents.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackage() {
|
||||
return "com.example.addon";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.example.addon;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
// Fabric's required client entrypoint. The addon's real work is in ExampleAddon.
|
||||
public final class ExampleInit implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.example.addon.commands;
|
||||
|
||||
import autismclient.commands.AutismCommandSource;
|
||||
import autismclient.commands.Command;
|
||||
import autismclient.util.AutismClientMessaging;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
|
||||
// A Brigadier command. Users run it with the command prefix, e.g. .example or .example hi.
|
||||
public final class ExampleCommand extends Command {
|
||||
public ExampleCommand() {
|
||||
super("example", "Example addon command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<AutismCommandSource> root) {
|
||||
root.executes(ctx -> {
|
||||
AutismClientMessaging.sendPrefixed("\u00a7dExample addon command works!");
|
||||
return SUCCESS;
|
||||
});
|
||||
|
||||
root.then(RequiredArgumentBuilder.<AutismCommandSource, String>argument("text", StringArgumentType.greedyString())
|
||||
.executes(ctx -> {
|
||||
AutismClientMessaging.sendPrefixed("\u00a7dYou said: \u00a7f" + StringArgumentType.getString(ctx, "text"));
|
||||
return SUCCESS;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.example.addon.events;
|
||||
|
||||
import autismclient.api.AutismAddons;
|
||||
import autismclient.util.AutismClientMessaging;
|
||||
|
||||
// Event hooks. Register listeners once in onInitialize().
|
||||
// Available: onTick, onPacketSend (return true to cancel), onPacketReceive, onGameJoin, onGameLeft.
|
||||
public final class ExampleEvents {
|
||||
private ExampleEvents() {}
|
||||
|
||||
public static void register() {
|
||||
AutismAddons.events().onGameJoin(() ->
|
||||
AutismClientMessaging.sendPrefixed("\u00a7a[Example] joined a world!"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.example.addon.hud;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import autismclient.api.hud.HudElementProvider;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||
|
||||
// A HUD element. Report your size via width()/height(); draw in render() with the GuiGraphicsExtractor
|
||||
// (ctx.text / ctx.fill). The defaultX/Y/anchor/enabled are used until the user moves it in the HUD editor.
|
||||
public final class ExampleHud implements HudElementProvider {
|
||||
private static final int MIN_WIDTH = 94;
|
||||
private static final int TEXT_PAD = 2;
|
||||
|
||||
@Override public String id() { return ExampleAddon.ID + ":clock"; }
|
||||
@Override public String label() { return "Example Clock"; }
|
||||
@Override public String description() { return "Shows the in-game tick."; }
|
||||
|
||||
@Override
|
||||
public int width() {
|
||||
Font font = Minecraft.getInstance().font;
|
||||
String text = text();
|
||||
int textWidth = font != null ? font.width(text) : text.length() * 6;
|
||||
return Math.max(MIN_WIDTH, textWidth + TEXT_PAD * 2);
|
||||
}
|
||||
|
||||
@Override public int height() { return 10; }
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphicsExtractor ctx, Font font, int x, int y, float alpha) {
|
||||
ctx.text(font, text(), x + TEXT_PAD, y, 0xFFFFD7FF);
|
||||
}
|
||||
|
||||
private static String text() {
|
||||
long tick = Minecraft.getInstance().level != null ? Minecraft.getInstance().level.getGameTime() : 0L;
|
||||
return "Addon tick: " + tick;
|
||||
}
|
||||
|
||||
@Override public boolean defaultEnabled() { return false; }
|
||||
@Override public String defaultAnchor() { return "TOP_LEFT"; }
|
||||
@Override public int defaultX() { return 4; }
|
||||
@Override public int defaultY() { return 120; }
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.example.addon.macro;
|
||||
|
||||
import autismclient.api.macro.AddonCondition;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
// A reusable predicate: implement check(). A waiting step blocks on it via ctx.awaitCondition(...).
|
||||
public final class ExampleCondition extends AddonCondition {
|
||||
private final double minY;
|
||||
|
||||
public ExampleCondition(double minY) {
|
||||
this.minY = minY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Minecraft mc) {
|
||||
return mc.player != null && mc.player.getY() >= minY;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.example.addon.macro;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import autismclient.api.macro.ActionSchema;
|
||||
import autismclient.api.macro.AddonContextAction;
|
||||
import autismclient.api.macro.MacroExecutionContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
// A macro condition: a step that waits. Extend AddonContextAction and block in run(), e.g. with
|
||||
// ctx.awaitCondition(...). Register it with .condition(...) so it lands in the condition picker.
|
||||
public final class ExampleHeightCondition extends AddonContextAction {
|
||||
public static final String TYPE_ID = ExampleAddon.ID + ":wait-height";
|
||||
|
||||
public double minY = 64.0;
|
||||
|
||||
public ExampleHeightCondition() {
|
||||
super(TYPE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MacroExecutionContext ctx) throws InterruptedException {
|
||||
ctx.setStatus("Waiting until Y >= " + minY);
|
||||
ctx.awaitCondition(new ExampleCondition(minY));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save(CompoundTag tag) {
|
||||
putDouble(tag, "minY", minY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(CompoundTag tag) {
|
||||
minY = getDouble(tag, "minY", minY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionSchema schema() {
|
||||
return ActionSchema.builder().decimal("minY", "Min Y").decRange(-64, 320).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Wait until Y >= " + minY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon() {
|
||||
return "Y";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.example.addon.macro;
|
||||
|
||||
import autismclient.util.macro.MacroAction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// Presets insert a ready-made stack of steps. Return a fresh list each call; don't reuse instances.
|
||||
public final class ExamplePresets {
|
||||
private ExamplePresets() {}
|
||||
|
||||
// Wait until the player is high up, then announce it.
|
||||
public static List<MacroAction> reachHeightThenSay() {
|
||||
List<MacroAction> stack = new ArrayList<>();
|
||||
|
||||
ExampleHeightCondition waitForHeight = new ExampleHeightCondition();
|
||||
waitForHeight.minY = 80.0;
|
||||
stack.add(waitForHeight);
|
||||
|
||||
ExampleSayAction say = new ExampleSayAction();
|
||||
say.message = "Reached Y 80!";
|
||||
stack.add(say);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.example.addon.macro;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import autismclient.api.macro.ActionSchema;
|
||||
import autismclient.api.macro.AddonAction;
|
||||
import autismclient.util.AutismClientMessaging;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
// A macro action: runs once when the step is reached. Extend AddonAction and pass a namespaced id.
|
||||
public final class ExampleSayAction extends AddonAction {
|
||||
public static final String TYPE_ID = ExampleAddon.ID + ":say";
|
||||
|
||||
public String message = "Hello from an addon!";
|
||||
|
||||
public ExampleSayAction() {
|
||||
super(TYPE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Minecraft mc) {
|
||||
AutismClientMessaging.sendPrefixed("\u00a7d[Example] " + message);
|
||||
}
|
||||
|
||||
// Field keys here, in load(), and in the schema must match.
|
||||
@Override
|
||||
protected void save(CompoundTag tag) {
|
||||
putString(tag, "message", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(CompoundTag tag) {
|
||||
message = getString(tag, "message", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionSchema schema() {
|
||||
return ActionSchema.builder().text("message", "Say").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Say: " + message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon() {
|
||||
return "S";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.addon.mixin;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
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. List your mixin classes in autism-advanced-addon-template.mixins.json (referenced from
|
||||
// fabric.mod.json). An @Inject handler matches the target method's params, then CallbackInfo.
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class ExampleMixin {
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void onClientInit(GameConfig gameConfig, CallbackInfo ci) {
|
||||
org.slf4j.LoggerFactory.getLogger(ExampleAddon.ID).info("Hello from ExampleMixin!");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.example.addon.modules;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import autismclient.api.module.BoolSetting;
|
||||
import autismclient.api.module.EnumSetting;
|
||||
import autismclient.api.module.IntSetting;
|
||||
import autismclient.modules.Module;
|
||||
import autismclient.util.AutismClientMessaging;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
// A toggleable module built on the typed setting API. Declare each setting as a final field with
|
||||
// add(new XSetting(...)) and read it at runtime with field.get() — no string ids, no casting. An EnumSetting
|
||||
// is backed by a real enum, so reads are compiler-checked (style.get() == Style.LOUD). Visibility is a plain
|
||||
// predicate over other settings. With no category, the module auto-lands under a menu column named after your addon.
|
||||
public final class ExampleModule extends Module {
|
||||
public enum Style { FRIENDLY, LOUD }
|
||||
|
||||
private final BoolSetting greet = add(new BoolSetting("greet", "Greet on enable", true)
|
||||
.group("General"));
|
||||
private final IntSetting amount = add(new IntSetting("amount", "Amount", 3, 1, 10, 1)
|
||||
.group("General"));
|
||||
private final EnumSetting<Style> style = add(new EnumSetting<>("style", "Style", Style.FRIENDLY, Style.values())
|
||||
.group("Display"));
|
||||
private final BoolSetting shout = add(new BoolSetting("shout", "Shout in caps", false)
|
||||
.group("Display")
|
||||
.visibleWhen(() -> style.get() == Style.LOUD));
|
||||
|
||||
public ExampleModule() {
|
||||
super(ExampleAddon.ID + ":example", "Example", "Demonstrates an AUTISM addon module.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (greet.get()) {
|
||||
String msg = "[Example] enabled - amount " + amount.get() + ", style " + style.get();
|
||||
if (shout.get()) msg = msg.toUpperCase(Locale.ROOT);
|
||||
AutismClientMessaging.sendPrefixed("§b" + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "com.example.addon.mixin",
|
||||
"compatibilityLevel": "JAVA_25",
|
||||
"client": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
37
addon-templates/advanced/src/main/resources/fabric.mod.json
Normal file
37
addon-templates/advanced/src/main/resources/fabric.mod.json
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "autism-advanced-addon-template",
|
||||
"version": "${version}",
|
||||
"name": "AUTISM Advanced",
|
||||
"description": "Reference addon for AUTISM Client: a module, macro action, preset, condition, command, HUD element, and event hook.",
|
||||
"authors": [
|
||||
"You"
|
||||
],
|
||||
"custom": {
|
||||
"autism:color": "255,80,80",
|
||||
"modmenu": {
|
||||
"parent": {
|
||||
"id": "autism"
|
||||
}
|
||||
}
|
||||
},
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.example.addon.ExampleInit"
|
||||
],
|
||||
"autism": [
|
||||
"com.example.addon.ExampleAddon"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"autism-advanced-addon-template.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"java": ">=25",
|
||||
"minecraft": "${mc_compat}",
|
||||
"fabricloader": ">=0.19.3",
|
||||
"fabric-api": ">=${fabric_api_version}",
|
||||
"autism": ">=${autism_api_version}"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue