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
cb6910b424
1300 changed files with 317229 additions and 0 deletions
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue