mirror of
https://github.com/AutismDevelopment/Autism-Client.git
synced 2026-10-28 21:59:46 +00:00
Initial release
This commit is contained in:
commit
e2f3f4759d
679 changed files with 156544 additions and 0 deletions
|
|
@ -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,28 @@
|
|||
package com.example.addon.modules;
|
||||
|
||||
import com.example.addon.ExampleAddon;
|
||||
import autismclient.modules.PackModule;
|
||||
import autismclient.modules.PackModuleOption;
|
||||
import autismclient.util.AutismClientMessaging;
|
||||
|
||||
// A toggleable module. With no category it auto-lands under a menu column named after your addon.
|
||||
// Read option values with bool/integer/decimal/choice/text/list(id). Group options with .group("...").
|
||||
public final class ExampleModule extends PackModule {
|
||||
public ExampleModule() {
|
||||
super(ExampleAddon.ID + ":example", "Example", "Demonstrates an AUTISM addon module.");
|
||||
|
||||
option(PackModuleOption.bool("greet", "Greet on enable", true).group("General"));
|
||||
option(PackModuleOption.integer("amount", "Amount", 3, 1, 10, 1).group("General"));
|
||||
option(PackModuleOption.enumChoice("style", "Style", "Friendly", "Friendly", "Loud").group("Display"));
|
||||
option(PackModuleOption.bool("shout", "Shout in caps", false).group("Display"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (bool("greet")) {
|
||||
String msg = "[Example] enabled - amount " + integer("amount") + ", style " + choice("style");
|
||||
if (bool("shout")) msg = msg.toUpperCase(java.util.Locale.ROOT);
|
||||
AutismClientMessaging.sendPrefixed("\u00a7b" + 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.18.4",
|
||||
"fabric-api": "*",
|
||||
"autism": ">=2.3"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue