added files.

This commit is contained in:
nitrogenoliquido committed 2026-11-23 23:48:56 -05:00
commit 03a7ed8358
9721 files changed
+828024

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import java.io.File;
import java.util.Arrays;
import net.minecraft.client.main.Main;
public class Start {
public static Object[] concat(Object[] array, Object[] array2) {
Object[] array3 = Arrays.copyOf(array, array.length + array2.length);
System.arraycopy(array2, 0, array3, array.length, array2.length);
return array3;
}
public static void main(String[] args) {
String assetsDir = new File("assets/indexes").isDirectory()
? "assets"
: (new File("run/assets").isDirectory() ? "run/assets" : "assets");
Main.main(
(String[])concat(new String[]{"--version", "1.8.9", "--accessToken", "0", "--assetsDir", assetsDir, "--assetIndex", "1.8", "--userProperties", "{}"}, args)
);
}
}
@@ -0,0 +1,37 @@
import java.io.File;
import java.util.Arrays;
import net.augustus.utils.OSUtil;
import net.minecraft.client.main.Main;
public class StartMinecraftDirectory {
public static Object[] concat(Object[] array, Object[] array2) {
Object[] array3 = Arrays.copyOf(array, array.length + array2.length);
System.arraycopy(array2, 0, array3, array.length, array2.length);
return array3;
}
public static void main(String[] args) {
File file = new File(OSUtil.detectOS().getMinecraftDirectory());
File file2 = new File(file + File.separator + "assets");
Main.main(
(String[])concat(
new String[]{
"--version",
"1.8.9",
"--accessToken",
"0",
"--assetsDir",
file2.toString(),
"--gameDir",
file.toString(),
"--assetIndex",
"1.8",
"--userProperties",
"{}"
},
args
)
);
}
}
+299
View File
@@ -0,0 +1,299 @@
package baritone;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.Settings;
import baritone.api.behavior.IBehavior;
import baritone.api.behavior.ILookBehavior;
import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IWorldProvider;
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.listener.IEventBus;
import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.IBaritoneProcess;
import baritone.api.process.IBuilderProcess;
import baritone.api.process.ICustomGoalProcess;
import baritone.api.process.IExploreProcess;
import baritone.api.process.IFarmProcess;
import baritone.api.process.IFollowProcess;
import baritone.api.process.IGetToBlockProcess;
import baritone.api.process.IMineProcess;
import baritone.api.selection.ISelectionManager;
import baritone.api.utils.IPlayerContext;
import baritone.behavior.InventoryBehavior;
import baritone.behavior.LookBehavior;
import baritone.behavior.PathingBehavior;
import baritone.behavior.WaypointBehavior;
import baritone.cache.WorldProvider;
import baritone.command.manager.CommandManager;
import baritone.event.GameEventHandler;
import baritone.process.InventoryPauserProcess;
import baritone.utils.player.BaritonePlayerContext;
import baritone.api.utils.IInputOverrideHandler;
import baritone.process.BackfillProcess;
import baritone.process.BuilderProcess;
import baritone.process.CustomGoalProcess;
import baritone.process.ExploreProcess;
import baritone.process.FarmProcess;
import baritone.process.FollowProcess;
import baritone.process.GetToBlockProcess;
import baritone.process.MineProcess;
import baritone.selection.SelectionManager;
import baritone.utils.BlockStateInterface;
import baritone.utils.GuiClick;
import baritone.utils.InputOverrideHandler;
import baritone.utils.PathingControlManager;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import net.minecraft.client.Minecraft;
public class Baritone implements IBaritone {
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
private final Minecraft mc;
private final Path directory;
private final GameEventHandler gameEventHandler;
private final PathingBehavior pathingBehavior;
private final LookBehavior lookBehavior;
private final InventoryBehavior inventoryBehavior;
private final InputOverrideHandler inputOverrideHandler;
private final FollowProcess followProcess;
private final MineProcess mineProcess;
private final GetToBlockProcess getToBlockProcess;
private final CustomGoalProcess customGoalProcess;
private final BuilderProcess builderProcess;
private final ExploreProcess exploreProcess;
private final FarmProcess farmProcess;
private final InventoryPauserProcess inventoryPauserProcess;
private final PathingControlManager pathingControlManager;
private final SelectionManager selectionManager;
private final CommandManager commandManager;
private final IPlayerContext playerContext;
private final WorldProvider worldProvider;
public BlockStateInterface bsi;
@Override
public IGetToBlockProcess getGetToBlockProcess() {
return this.getGetToBlockProcess2();
}
public SelectionManager getSelectionManager2() {
return this.selectionManager;
}
public static Executor getThreadPool() {
return threadPool;
}
@Override
public ILookBehavior getLookBehavior() {
return this.getLookBehavior2();
}
@Override
public ICustomGoalProcess getCustomGoalProcess() {
return this.getCustomGoalProcess2();
}
public void registerBehavior(IBehavior behavior) {
this.gameEventHandler.registerEventListener(behavior);
}
public InventoryBehavior getInventoryBehavior() {
return this.inventoryBehavior;
}
@Override
public IBuilderProcess getBuilderProcess() {
return this.getBuilderProcess2();
}
public MineProcess getMineProcess2() {
return this.mineProcess;
}
public LookBehavior getLookBehavior2() {
return this.lookBehavior;
}
public FollowProcess getFollowProcess2() {
return this.followProcess;
}
public ExploreProcess getExploreProcess2() {
return this.exploreProcess;
}
@Override
public ISelectionManager getSelectionManager() {
return this.getSelectionManager2();
}
public WorldProvider getWorldProvider2() {
return this.worldProvider;
}
public BuilderProcess getBuilderProcess2() {
return this.builderProcess;
}
@Override
public IPathingBehavior getPathingBehavior() {
return this.getPathingBehavior2();
}
public InputOverrideHandler getInputOverrideHandler2() {
return this.inputOverrideHandler;
}
public IBaritoneProcess registerProcess(Function<Baritone, ? extends IBaritoneProcess> function) {
IBaritoneProcess baritoneProcess = (IBaritoneProcess)function.apply(this);
this.pathingControlManager.registerProcess(baritoneProcess);
return baritoneProcess;
}
public GetToBlockProcess getGetToBlockProcess2() {
return this.getToBlockProcess;
}
@Override
public IFollowProcess getFollowProcess() {
return this.getFollowProcess2();
}
@Override
public IMineProcess getMineProcess() {
return this.getMineProcess2();
}
@Override
public IExploreProcess getExploreProcess() {
return this.getExploreProcess2();
}
@Override
public void openClick() {
new Thread(() -> {
try {
Thread.sleep(100L);
Minecraft mc2 = this.mc;
Runnable runnable = () -> {
this.mc.displayGuiScreen(new GuiClick());
};
mc2.addScheduledTask(runnable);
} catch (Exception e) {
}
}).start();
}
public CommandManager getCommandManager2() {
return this.commandManager;
}
public CustomGoalProcess getCustomGoalProcess2() {
return this.customGoalProcess;
}
@Override
public IPathingControlManager getPathingControlManager() {
return this.getPathingControlManager2();
}
public PathingBehavior getPathingBehavior2() {
return this.pathingBehavior;
}
public InventoryPauserProcess getInventoryPauserProcess() {
return this.inventoryPauserProcess;
}
public IBehavior registerBehavior2(Function<Baritone, ? extends IBehavior> function) {
IBehavior behavior = (IBehavior)function.apply(this);
this.registerBehavior(behavior);
return behavior;
}
@Override
public IFarmProcess getFarmProcess() {
return this.getFarmProcess2();
}
@Override
public IEventBus getGameEventHandler() {
return this.gameEventHandler;
}
public Path getDirectory() {
return this.directory;
}
public static Settings settings() {
return BaritoneAPI.getSettings();
}
public PathingControlManager getPathingControlManager2() {
return this.pathingControlManager;
}
@Override
public IInputOverrideHandler getInputOverrideHandler() {
return this.getInputOverrideHandler2();
}
public FarmProcess getFarmProcess2() {
return this.farmProcess;
}
@Override
public IWorldProvider getWorldProvider() {
return this.getWorldProvider2();
}
public Baritone(Minecraft mc2) {
this.mc = mc2;
this.gameEventHandler = new GameEventHandler(this);
this.directory = mc2.mcDataDir.toPath().resolve("baritone");
if (!Files.exists(this.directory)) {
try {
Files.createDirectories(this.directory);
} catch (IOException e) {
}
}
this.playerContext = new BaritonePlayerContext(this, mc2);
this.lookBehavior = (LookBehavior)this.registerBehavior2(LookBehavior::new);
this.pathingBehavior = (PathingBehavior)this.registerBehavior2(PathingBehavior::new);
this.inventoryBehavior = (InventoryBehavior)this.registerBehavior2(InventoryBehavior::new);
this.inputOverrideHandler = (InputOverrideHandler)this.registerBehavior2(InputOverrideHandler::new);
this.registerBehavior2(WaypointBehavior::new);
this.pathingControlManager = new PathingControlManager(this);
this.followProcess = (FollowProcess)this.registerProcess(FollowProcess::new);
this.mineProcess = (MineProcess)this.registerProcess(MineProcess::new);
this.customGoalProcess = (CustomGoalProcess)this.registerProcess(CustomGoalProcess::new);
this.getToBlockProcess = (GetToBlockProcess)this.registerProcess(GetToBlockProcess::new);
this.builderProcess = (BuilderProcess)this.registerProcess(BuilderProcess::new);
this.exploreProcess = (ExploreProcess)this.registerProcess(ExploreProcess::new);
this.farmProcess = (FarmProcess)this.registerProcess(FarmProcess::new);
this.inventoryPauserProcess = (InventoryPauserProcess)this.registerProcess(InventoryPauserProcess::new);
this.registerProcess(BackfillProcess::new);
this.worldProvider = new WorldProvider(this);
this.selectionManager = new SelectionManager(this);
this.commandManager = new CommandManager(this);
}
@Override
public IPlayerContext getPlayerContext() {
return this.playerContext;
}
@Override
public ICommandManager getCommandManager() {
return this.getCommandManager2();
}
}
@@ -0,0 +1,64 @@
package baritone;
import baritone.api.IBaritone;
import baritone.api.IBaritoneProvider;
import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem;
import baritone.cache.WorldScanner;
import baritone.command.CommandSystem;
import baritone.api.cache.IWorldScanner;
import baritone.command.ExampleBaritoneControl;
import baritone.utils.schematic.SchematicSystem;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import net.minecraft.client.Minecraft;
public final class BaritoneProvider implements IBaritoneProvider {
private final List all = new CopyOnWriteArrayList();
private final List allView = Collections.unmodifiableList(this.all);
@Override
public ISchematicSystem getInstance() {
return SchematicSystem.INSTANCE;
}
@Override
public List getAllBaritones() {
return this.allView;
}
@Override
public synchronized boolean destroyBaritone(IBaritone baritone) {
return baritone != this.getPrimaryBaritone() && this.all.remove(baritone);
}
@Override
public ICommandSystem getInstance2() {
return CommandSystem.INSTANCE;
}
@Override
public IWorldScanner getInstance3() {
return WorldScanner.INSTANCE;
}
@Override
public IBaritone getPrimaryBaritone() {
return (IBaritone)this.all.get(0);
}
public BaritoneProvider() {
((Baritone)this.createBaritone(Minecraft.getMinecraft())).registerBehavior2(ExampleBaritoneControl::new);
}
@Override
public synchronized IBaritone createBaritone(Minecraft mc) {
Object baritoneForMinecraft = this.getBaritoneForMinecraft(mc);
if (baritoneForMinecraft == null) {
this.all.add(baritoneForMinecraft = new Baritone(mc));
}
return (IBaritone)baritoneForMinecraft;
}
}
+4
View File
@@ -0,0 +1,4 @@
package baritone;
public @interface KeepName {
}
@@ -0,0 +1,28 @@
package baritone.api;
import baritone.BaritoneProvider;
import baritone.api.utils.SettingsUtil;
public final class BaritoneAPI {
private static final SettingsRegistry settingsRegistry = new SettingsRegistry();
private static final Settings settings = new Settings(settingsRegistry);
private static final IBaritoneProvider provider;
static {
String str = "settings.txt";
SettingsUtil.readAndApply(settings, str);
provider = new BaritoneProvider();
}
public static IBaritoneProvider getProvider() {
return provider;
}
public static SettingsRegistry getSettingsRegistry() {
return settingsRegistry;
}
public static Settings getSettings() {
return settings;
}
}
+54
View File
@@ -0,0 +1,54 @@
package baritone.api;
import baritone.api.behavior.ILookBehavior;
import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IWorldProvider;
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.listener.IEventBus;
import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.IBuilderProcess;
import baritone.api.process.ICustomGoalProcess;
import baritone.api.process.IExploreProcess;
import baritone.api.process.IFarmProcess;
import baritone.api.process.IFollowProcess;
import baritone.api.process.IGetToBlockProcess;
import baritone.api.process.IMineProcess;
import baritone.api.selection.ISelectionManager;
import baritone.api.utils.IPlayerContext;
import baritone.api.utils.IInputOverrideHandler;
public interface IBaritone {
IMineProcess getMineProcess();
ICommandManager getCommandManager();
IEventBus getGameEventHandler();
IBuilderProcess getBuilderProcess();
IWorldProvider getWorldProvider();
ICustomGoalProcess getCustomGoalProcess();
IGetToBlockProcess getGetToBlockProcess();
IFarmProcess getFarmProcess();
IExploreProcess getExploreProcess();
IInputOverrideHandler getInputOverrideHandler();
IPathingControlManager getPathingControlManager();
ISelectionManager getSelectionManager();
IPlayerContext getPlayerContext();
ILookBehavior getLookBehavior();
IPathingBehavior getPathingBehavior();
void openClick();
IFollowProcess getFollowProcess();
}
@@ -0,0 +1,57 @@
package baritone.api;
import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem;
import baritone.api.cache.IWorldScanner;
import java.util.List;
import java.util.Objects;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.network.NetHandlerPlayClient;
public interface IBaritoneProvider {
default IBaritone getBaritoneForMinecraft(Minecraft mc) {
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
if (Objects.equals(mc, baritone.getPlayerContext().getMc())) {
return baritone;
}
}
return null;
}
boolean destroyBaritone(IBaritone baritone);
IWorldScanner getInstance3();
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
if (Objects.equals(player, baritone.getPlayerContext().player())) {
return baritone;
}
}
return null;
}
ICommandSystem getInstance2();
IBaritone getPrimaryBaritone();
List getAllBaritones();
ISchematicSystem getInstance();
default IBaritone getBaritoneForConnection(NetHandlerPlayClient netHandlerPlayClient) {
for (IBaritone baritone : (Iterable<IBaritone>)(this.getAllBaritones())) {
EntityPlayerSP player = baritone.getPlayerContext().player();
if (player != null && player.sendQueue == netHandlerPlayClient) {
return baritone;
}
}
return null;
}
IBaritone createBaritone(Minecraft mc);
}
+11
View File
@@ -0,0 +1,11 @@
package baritone.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface JavaOnly {
}
+325
View File
@@ -0,0 +1,325 @@
package baritone.api;
import baritone.api.utils.SettingsUtil;
import java.lang.reflect.Type;
import baritone.api.utils.NotificationHelper;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.Vec3i;
public final class Settings {
public final Settings.Setting allowBreak = new Settings.Setting(this, "allowBreak", true, false);
public final Settings.Setting allowBreakAnyway = new Settings.Setting(this, "allowBreakAnyway", new ArrayList(), false);
public final Settings.Setting allowSprint = new Settings.Setting(this, "allowSprint", true, false);
public final Settings.Setting allowPlace = new Settings.Setting(this, "allowPlace", true, false);
public final Settings.Setting allowInventory = new Settings.Setting(this, "allowInventory", false, false);
public final Settings.Setting ticksBetweenInventoryMoves = new Settings.Setting(this, "ticksBetweenInventoryMoves", 1, false);
public final Settings.Setting inventoryMoveOnlyIfStationary = new Settings.Setting(this, "inventoryMoveOnlyIfStationary", false, false);
public final Settings.Setting assumeExternalAutoTool = new Settings.Setting(this, "assumeExternalAutoTool", false, false);
public final Settings.Setting autoTool = new Settings.Setting(this, "autoTool", true, false);
public final Settings.Setting blockPlacementPenalty = new Settings.Setting(this, "blockPlacementPenalty", 20.0, false);
public final Settings.Setting blockBreakAdditionalPenalty = new Settings.Setting(this, "blockBreakAdditionalPenalty", 2.0, false);
public final Settings.Setting jumpPenalty = new Settings.Setting(this, "jumpPenalty", 2.0, false);
public final Settings.Setting walkOnWaterOnePenalty = new Settings.Setting(this, "walkOnWaterOnePenalty", 3.0, false);
public final Settings.Setting strictLiquidCheck = new Settings.Setting(this, "strictLiquidCheck", false, false);
public final Settings.Setting allowWaterBucketFall = new Settings.Setting(this, "allowWaterBucketFall", true, false);
public final Settings.Setting assumeWalkOnWater = new Settings.Setting(this, "assumeWalkOnWater", false, false);
public final Settings.Setting assumeWalkOnLava = new Settings.Setting(this, "assumeWalkOnLava", false, false);
public final Settings.Setting assumeStep = new Settings.Setting(this, "assumeStep", false, false);
public final Settings.Setting assumeSafeWalk = new Settings.Setting(this, "assumeSafeWalk", false, false);
public final Settings.Setting allowJumpAt256 = new Settings.Setting(this, "allowJumpAt256", false, false);
public final Settings.Setting allowParkourAscend = new Settings.Setting(this, "allowParkourAscend", true, false);
public final Settings.Setting allowDiagonalDescend = new Settings.Setting(this, "allowDiagonalDescend", false, false);
public final Settings.Setting allowDiagonalAscend = new Settings.Setting(this, "allowDiagonalAscend", false, false);
public final Settings.Setting allowDownward = new Settings.Setting(this, "allowDownward", true, false);
public final Settings.Setting acceptableThrowawayItems = new Settings.Setting(
this,
"acceptableThrowawayItems",
new ArrayList<>(
Arrays.asList(
Item.getItemFromBlock(Blocks.dirt),
Item.getItemFromBlock(Blocks.cobblestone),
Item.getItemFromBlock(Blocks.netherrack),
Item.getItemFromBlock(Blocks.stone)
)
),
false
);
public final Settings.Setting blocksToAvoid = new Settings.Setting(this, "blocksToAvoid", new ArrayList(), false);
public final Settings.Setting blocksToDisallowBreaking = new Settings.Setting(this, "blocksToDisallowBreaking", new ArrayList(), false);
public final Settings.Setting blocksToAvoidBreaking = new Settings.Setting(
this,
"blocksToAvoidBreaking",
new ArrayList<>(
Arrays.asList(Blocks.crafting_table, Blocks.furnace, Blocks.lit_furnace, Blocks.chest, Blocks.trapped_chest, Blocks.standing_sign, Blocks.wall_sign)
),
false
);
public final Settings.Setting avoidBreakingMultiplier = new Settings.Setting(this, "avoidBreakingMultiplier", 0.1, false);
public final Settings.Setting buildIgnoreBlocks = new Settings.Setting(this, "buildIgnoreBlocks", new ArrayList(), false);
public final Settings.Setting buildSkipBlocks = new Settings.Setting(this, "buildSkipBlocks", new ArrayList(), false);
public final Settings.Setting buildValidSubstitutes = new Settings.Setting(this, "buildValidSubstitutes", new HashMap(), false);
public final Settings.Setting buildSubstitutes = new Settings.Setting(this, "buildSubstitutes", new HashMap(), false);
public final Settings.Setting okIfAir = new Settings.Setting(this, "okIfAir", new ArrayList(), false);
public final Settings.Setting buildIgnoreExisting = new Settings.Setting(this, "buildIgnoreExisting", false, false);
public final Settings.Setting buildIgnoreDirection = new Settings.Setting(this, "buildIgnoreDirection", false, false);
public final Settings.Setting buildIgnoreProperties = new Settings.Setting(this, "buildIgnoreProperties", new ArrayList(), false);
public final Settings.Setting avoidUpdatingFallingBlocks = new Settings.Setting(this, "avoidUpdatingFallingBlocks", true, false);
public final Settings.Setting allowVines = new Settings.Setting(this, "allowVines", false, false);
public final Settings.Setting allowWalkOnBottomSlab = new Settings.Setting(this, "allowWalkOnBottomSlab", true, false);
public final Settings.Setting allowParkour = new Settings.Setting(this, "allowParkour", false, false);
public final Settings.Setting allowParkourPlace = new Settings.Setting(this, "allowParkourPlace", false, false);
public final Settings.Setting considerPotionEffects = new Settings.Setting(this, "considerPotionEffects", true, false);
public final Settings.Setting sprintAscends = new Settings.Setting(this, "sprintAscends", true, false);
public final Settings.Setting overshootTraverse = new Settings.Setting(this, "overshootTraverse", true, false);
public final Settings.Setting pauseMiningForFallingBlocks = new Settings.Setting(this, "pauseMiningForFallingBlocks", true, false);
public final Settings.Setting rightClickSpeed = new Settings.Setting(this, "rightClickSpeed", 4, false);
public final Settings.Setting blockReachDistance = new Settings.Setting(this, "blockReachDistance", 4.5F, false);
public final Settings.Setting randomLooking = new Settings.Setting(this, "randomLooking", 0.01, false);
public final Settings.Setting costHeuristic = new Settings.Setting(this, "costHeuristic", 3.563, false);
public final Settings.Setting pathingMaxChunkBorderFetch = new Settings.Setting(this, "pathingMaxChunkBorderFetch", 50, false);
public final Settings.Setting backtrackCostFavoringCoefficient = new Settings.Setting(this, "backtrackCostFavoringCoefficient", 0.5, false);
public final Settings.Setting avoidance = new Settings.Setting(this, "avoidance", false, false);
public final Settings.Setting mobSpawnerAvoidanceCoefficient = new Settings.Setting(this, "mobSpawnerAvoidanceCoefficient", 2.0, false);
public final Settings.Setting mobSpawnerAvoidanceRadius = new Settings.Setting(this, "mobSpawnerAvoidanceRadius", 16, false);
public final Settings.Setting mobAvoidanceCoefficient = new Settings.Setting(this, "mobAvoidanceCoefficient", 1.5, false);
public final Settings.Setting mobAvoidanceRadius = new Settings.Setting(this, "mobAvoidanceRadius", 8, false);
public final Settings.Setting rightClickContainerOnArrival = new Settings.Setting(this, "rightClickContainerOnArrival", true, false);
public final Settings.Setting enterPortal = new Settings.Setting(this, "enterPortal", true, false);
public final Settings.Setting minimumImprovementRepropagation = new Settings.Setting(this, "minimumImprovementRepropagation", true, false);
public final Settings.Setting cutoffAtLoadBoundary = new Settings.Setting(this, "cutoffAtLoadBoundary", false, false);
public final Settings.Setting maxCostIncrease = new Settings.Setting(this, "maxCostIncrease", 10.0, false);
public final Settings.Setting costVerificationLookahead = new Settings.Setting(this, "costVerificationLookahead", 5, false);
public final Settings.Setting pathCutoffFactor = new Settings.Setting(this, "pathCutoffFactor", 0.9, false);
public final Settings.Setting pathCutoffMinimumLength = new Settings.Setting(this, "pathCutoffMinimumLength", 30, false);
public final Settings.Setting planningTickLookahead = new Settings.Setting(this, "planningTickLookahead", 150, false);
public final Settings.Setting pathingMapDefaultSize = new Settings.Setting(this, "pathingMapDefaultSize", 1024, false);
public final Settings.Setting pathingMapLoadFactor = new Settings.Setting(this, "pathingMapLoadFactor", 0.75F, false);
public final Settings.Setting maxFallHeightNoWater = new Settings.Setting(this, "maxFallHeightNoWater", 3, false);
public final Settings.Setting maxFallHeightBucket = new Settings.Setting(this, "maxFallHeightBucket", 20, false);
public final Settings.Setting allowOvershootDiagonalDescend = new Settings.Setting(this, "allowOvershootDiagonalDescend", true, false);
public final Settings.Setting simplifyUnloadedYCoord = new Settings.Setting(this, "simplifyUnloadedYCoord", true, false);
public final Settings.Setting repackOnAnyBlockChange = new Settings.Setting(this, "repackOnAnyBlockChange", true, false);
public final Settings.Setting movementTimeoutTicks = new Settings.Setting(this, "movementTimeoutTicks", 100, false);
public final Settings.Setting primaryTimeoutMS = new Settings.Setting(this, "primaryTimeoutMS", 500L, false);
public final Settings.Setting failureTimeoutMS = new Settings.Setting(this, "failureTimeoutMS", 2000L, false);
public final Settings.Setting planAheadPrimaryTimeoutMS = new Settings.Setting(this, "planAheadPrimaryTimeoutMS", 4000L, false);
public final Settings.Setting planAheadFailureTimeoutMS = new Settings.Setting(this, "planAheadFailureTimeoutMS", 5000L, false);
public final Settings.Setting slowPath = new Settings.Setting(this, "slowPath", false, false);
public final Settings.Setting slowPathTimeDelayMS = new Settings.Setting(this, "slowPathTimeDelayMS", 100L, false);
public final Settings.Setting slowPathTimeoutMS = new Settings.Setting(this, "slowPathTimeoutMS", 40000L, false);
public final Settings.Setting doBedWaypoints = new Settings.Setting(this, "doBedWaypoints", true, false);
public final Settings.Setting doDeathWaypoints = new Settings.Setting(this, "doDeathWaypoints", true, false);
public final Settings.Setting chunkCaching = new Settings.Setting(this, "chunkCaching", true, false);
public final Settings.Setting pruneRegionsFromRAM = new Settings.Setting(this, "pruneRegionsFromRAM", true, false);
public final Settings.Setting chunkPackerQueueMaxSize = new Settings.Setting(this, "chunkPackerQueueMaxSize", 2000, false);
public final Settings.Setting backfill = new Settings.Setting(this, "backfill", false, false);
public final Settings.Setting logAsToast = new Settings.Setting(this, "logAsToast", false, false);
public final Settings.Setting toastTimer = new Settings.Setting(this, "toastTimer", 5000L, false);
public final Settings.Setting chatDebug = new Settings.Setting(this, "chatDebug", false, false);
public final Settings.Setting chatControl = new Settings.Setting(this, "chatControl", true, false);
public final Settings.Setting chatControlAnyway = new Settings.Setting(this, "chatControlAnyway", false, false);
public final Settings.Setting renderPath = new Settings.Setting(this, "renderPath", true, false);
public final Settings.Setting renderPathAsLine = new Settings.Setting(this, "renderPathAsLine", false, false);
public final Settings.Setting renderGoal = new Settings.Setting(this, "renderGoal", true, false);
public final Settings.Setting renderGoalAnimated = new Settings.Setting(this, "renderGoalAnimated", true, false);
public final Settings.Setting renderSelectionBoxes = new Settings.Setting(this, "renderSelectionBoxes", true, false);
public final Settings.Setting renderGoalIgnoreDepth = new Settings.Setting(this, "renderGoalIgnoreDepth", true, false);
public final Settings.Setting renderGoalXZBeacon = new Settings.Setting(this, "renderGoalXZBeacon", false, false);
public final Settings.Setting renderSelectionBoxesIgnoreDepth = new Settings.Setting(this, "renderSelectionBoxesIgnoreDepth", true, false);
public final Settings.Setting renderPathIgnoreDepth = new Settings.Setting(this, "renderPathIgnoreDepth", true, false);
public final Settings.Setting pathRenderLineWidthPixels = new Settings.Setting(this, "pathRenderLineWidthPixels", 5.0F, false);
public final Settings.Setting goalRenderLineWidthPixels = new Settings.Setting(this, "goalRenderLineWidthPixels", 3.0F, false);
public final Settings.Setting fadePath = new Settings.Setting(this, "fadePath", false, false);
public final Settings.Setting freeLook = new Settings.Setting(this, "freeLook", true, false);
public final Settings.Setting blockFreeLook = new Settings.Setting(this, "blockFreeLook", false, false);
public final Settings.Setting antiCheatCompatibility = new Settings.Setting(this, "antiCheatCompatibility", true, false);
public final Settings.Setting pathThroughCachedOnly = new Settings.Setting(this, "pathThroughCachedOnly", false, false);
public final Settings.Setting sprintInWater = new Settings.Setting(this, "sprintInWater", true, false);
public final Settings.Setting blacklistClosestOnFailure = new Settings.Setting(this, "blacklistClosestOnFailure", true, false);
public final Settings.Setting renderCachedChunks = new Settings.Setting(this, "renderCachedChunks", false, false);
public final Settings.Setting cachedChunksOpacity = new Settings.Setting(this, "cachedChunksOpacity", 0.5F, false);
public final Settings.Setting prefixControl = new Settings.Setting(this, "prefixControl", true, false);
public final Settings.Setting prefix = new Settings.Setting(this, "prefix", "#", false);
public final Settings.Setting shortBaritonePrefix = new Settings.Setting(this, "shortBaritonePrefix", false, false);
public final Settings.Setting echoCommands = new Settings.Setting(this, "echoCommands", true, false);
public final Settings.Setting censorCoordinates = new Settings.Setting(this, "censorCoordinates", false, false);
public final Settings.Setting censorRanCommands = new Settings.Setting(this, "censorRanCommands", false, false);
public final Settings.Setting itemSaver = new Settings.Setting(this, "itemSaver", false, false);
public final Settings.Setting itemSaverThreshold = new Settings.Setting(this, "itemSaverThreshold", 10);
public final Settings.Setting preferSilkTouch = new Settings.Setting(this, "preferSilkTouch", false);
public final Settings.Setting walkWhileBreaking = new Settings.Setting(this, "walkWhileBreaking", true);
public final Settings.Setting splicePath = new Settings.Setting(this, "splicePath", true);
public final Settings.Setting maxPathHistoryLength = new Settings.Setting(this, "maxPathHistoryLength", 300);
public final Settings.Setting pathHistoryCutoffAmount = new Settings.Setting(this, "pathHistoryCutoffAmount", 50);
public final Settings.Setting mineGoalUpdateInterval = new Settings.Setting(this, "mineGoalUpdateInterval", 5);
public final Settings.Setting maxCachedWorldScanCount = new Settings.Setting(this, "maxCachedWorldScanCount", 10);
public final Settings.Setting minYLevelWhileMining = new Settings.Setting(this, "minYLevelWhileMining", 0);
public final Settings.Setting maxYLevelWhileMining = new Settings.Setting(this, "maxYLevelWhileMining", 255);
public final Settings.Setting allowOnlyExposedOres = new Settings.Setting(this, "allowOnlyExposedOres", false);
public final Settings.Setting allowOnlyExposedOresDistance = new Settings.Setting(this, "allowOnlyExposedOresDistance", 1);
public final Settings.Setting exploreForBlocks = new Settings.Setting(this, "exploreForBlocks", true);
public final Settings.Setting worldExploringChunkOffset = new Settings.Setting(this, "worldExploringChunkOffset", 0);
public final Settings.Setting exploreChunkSetMinimumSize = new Settings.Setting(this, "exploreChunkSetMinimumSize", 10);
public final Settings.Setting exploreMaintainY = new Settings.Setting(this, "exploreMaintainY", 64);
public final Settings.Setting replantCrops = new Settings.Setting(this, "replantCrops", true);
public final Settings.Setting replantNetherWart = new Settings.Setting(this, "replantNetherWart", false);
public final Settings.Setting extendCacheOnThreshold = new Settings.Setting(this, "extendCacheOnThreshold", false);
public final Settings.Setting buildInLayers = new Settings.Setting(this, "buildInLayers", false);
public final Settings.Setting layerOrder = new Settings.Setting(this, "layerOrder", false);
public final Settings.Setting layerHeight = new Settings.Setting(this, "layerHeight", 1);
public final Settings.Setting startAtLayer = new Settings.Setting(this, "startAtLayer", 0);
public final Settings.Setting skipFailedLayers = new Settings.Setting(this, "skipFailedLayers", false);
public final Settings.Setting buildOnlySelection = new Settings.Setting(this, "buildOnlySelection", false);
public final Settings.Setting buildRepeat = new Settings.Setting(this, "buildRepeat", new Vec3i(0, 0, 0));
public final Settings.Setting buildRepeatCount = new Settings.Setting(this, "buildRepeatCount", -1);
public final Settings.Setting buildRepeatSneaky = new Settings.Setting(this, "buildRepeatSneaky", true);
public final Settings.Setting breakFromAbove = new Settings.Setting(this, "breakFromAbove", false);
public final Settings.Setting goalBreakFromAbove = new Settings.Setting(this, "goalBreakFromAbove", false);
public final Settings.Setting mapArtMode = new Settings.Setting(this, "mapArtMode", false);
public final Settings.Setting okIfWater = new Settings.Setting(this, "okIfWater", false);
public final Settings.Setting incorrectSize = new Settings.Setting(this, "incorrectSize", 100);
public final Settings.Setting breakCorrectBlockPenaltyMultiplier = new Settings.Setting(this, "breakCorrectBlockPenaltyMultiplier", 10.0);
public final Settings.Setting schematicOrientationX = new Settings.Setting(this, "schematicOrientationX", false);
public final Settings.Setting schematicOrientationY = new Settings.Setting(this, "schematicOrientationY", false);
public final Settings.Setting schematicOrientationZ = new Settings.Setting(this, "schematicOrientationZ", false);
public final Settings.Setting schematicFallbackExtension = new Settings.Setting(this, "schematicFallbackExtension", "schematic");
public final Settings.Setting builderTickScanRadius = new Settings.Setting(this, "builderTickScanRadius", 5);
public final Settings.Setting mineScanDroppedItems = new Settings.Setting(this, "mineScanDroppedItems", true);
public final Settings.Setting mineDropLoiterDurationMSThanksLouca = new Settings.Setting(this, "mineDropLoiterDurationMSThanksLouca", 250L);
public final Settings.Setting distanceTrim = new Settings.Setting(this, "distanceTrim", true);
public final Settings.Setting cancelOnGoalInvalidation = new Settings.Setting(this, "cancelOnGoalInvalidation", true);
public final Settings.Setting axisHeight = new Settings.Setting(this, "axisHeight", 120);
public final Settings.Setting disconnectOnArrival = new Settings.Setting(this, "disconnectOnArrival", false);
public final Settings.Setting legitMine = new Settings.Setting(this, "legitMine", false);
public final Settings.Setting legitMineYLevel = new Settings.Setting(this, "legitMineYLevel", 11);
public final Settings.Setting legitMineIncludeDiagonals = new Settings.Setting(this, "legitMineIncludeDiagonals", false);
public final Settings.Setting forceInternalMining = new Settings.Setting(this, "forceInternalMining", true);
public final Settings.Setting internalMiningAirException = new Settings.Setting(this, "internalMiningAirException", true);
public final Settings.Setting followOffsetDistance = new Settings.Setting(this, "followOffsetDistance", 0.0);
public final Settings.Setting followOffsetDirection = new Settings.Setting(this, "followOffsetDirection", 0.0F);
public final Settings.Setting followRadius = new Settings.Setting(this, "followRadius", 3);
public final Settings.Setting disableCompletionCheck = new Settings.Setting(this, "disableCompletionCheck", false);
public final Settings.Setting cachedChunksExpirySeconds = new Settings.Setting(this, "cachedChunksExpirySeconds", -1L);
@JavaOnly
public final Settings.Setting logger = new Settings.Setting(
this, "logger", (Consumer<IChatComponent>)component -> Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component), true
);
@JavaOnly
public final Settings.Setting notifier = new Settings.Setting(this, "notifier", (BiConsumer<String, Boolean>)NotificationHelper::notify, true);
public final Settings.Setting yLevelBoxSize = new Settings.Setting(this, "yLevelBoxSize", 15.0);
public final Settings.Setting colorCurrentPath = new Settings.Setting(this, "colorCurrentPath", Color.RED);
public final Settings.Setting colorNextPath = new Settings.Setting(this, "colorNextPath", Color.MAGENTA);
public final Settings.Setting colorBlocksToBreak = new Settings.Setting(this, "colorBlocksToBreak", Color.RED);
public final Settings.Setting colorBlocksToPlace = new Settings.Setting(this, "colorBlocksToPlace", Color.GREEN);
public final Settings.Setting colorBlocksToWalkInto = new Settings.Setting(this, "colorBlocksToWalkInto", Color.MAGENTA);
public final Settings.Setting colorBestPathSoFar = new Settings.Setting(this, "colorBestPathSoFar", Color.BLUE);
public final Settings.Setting colorMostRecentConsidered = new Settings.Setting(this, "colorMostRecentConsidered", Color.CYAN);
public final Settings.Setting colorGoalBox = new Settings.Setting(this, "colorGoalBox", Color.GREEN);
public final Settings.Setting colorInvertedGoalBox = new Settings.Setting(this, "colorInvertedGoalBox", Color.RED);
public final Settings.Setting colorSelection = new Settings.Setting(this, "colorSelection", Color.CYAN);
public final Settings.Setting colorSelectionPos1 = new Settings.Setting(this, "colorSelectionPos1", Color.BLACK);
public final Settings.Setting colorSelectionPos2 = new Settings.Setting(this, "colorSelectionPos2", Color.ORANGE);
public final Settings.Setting selectionOpacity = new Settings.Setting(this, "selectionOpacity", 0.5F);
public final Settings.Setting selectionLineWidth = new Settings.Setting(this, "selectionLineWidth", 2.0F);
public final Settings.Setting renderSelection = new Settings.Setting(this, "renderSelection", true);
public final Settings.Setting renderSelectionIgnoreDepth = new Settings.Setting(this, "renderSelectionIgnoreDepth", true);
public final Settings.Setting renderSelectionCorners = new Settings.Setting(this, "renderSelectionCorners", true);
public final Settings.Setting useSwordToMine = new Settings.Setting(this, "useSwordToMine", true);
public final Settings.Setting desktopNotifications = new Settings.Setting(this, "desktopNotifications", false);
public final Settings.Setting notificationOnPathComplete = new Settings.Setting(this, "notificationOnPathComplete", true);
public final Settings.Setting notificationOnFarmFail = new Settings.Setting(this, "notificationOnFarmFail", true);
public final Settings.Setting notificationOnBuildFinished = new Settings.Setting(this, "notificationOnBuildFinished", true);
public final Settings.Setting notificationOnExploreFinished = new Settings.Setting(this, "notificationOnExploreFinished", true);
public final Settings.Setting notificationOnMineFail = new Settings.Setting(this, "notificationOnMineFail", true);
public final Map byLowerName;
public final List<Settings.Setting> allSettings;
public final Map settingTypes;
public List<Settings.Setting> getAllValuesByType(Class clazz) {
ArrayList list = new ArrayList();
for (Settings.Setting setting : (Iterable<Settings.Setting>)(this.allSettings)) {
if (setting.getValueClass().equals(clazz)) {
list.add(setting);
}
}
return list;
}
public Settings(SettingsRegistry settingsRegistry) {
this.byLowerName = Collections.unmodifiableMap(settingsRegistry.byLowerName);
this.allSettings = Collections.unmodifiableList(settingsRegistry.allSettings);
this.settingTypes = Collections.unmodifiableMap(settingsRegistry.settingTypes);
}
public static final class Setting {
public Object value;
public final Object defaultValue;
private String name;
private boolean javaOnly;
public final Settings settings;
public String getName() {
return this.name;
}
public Setting(Settings settings2, String str, Object obj, boolean flag) {
this.settings = settings2;
this.name = str;
this.value = obj;
this.defaultValue = obj;
this.javaOnly = flag;
this.register();
}
public Class getValueClass() {
return this.value.getClass();
}
public void reset() {
this.value = this.defaultValue;
}
public Setting(Settings settings2, String str, Object obj) {
this.settings = settings2;
this.name = str;
this.value = obj;
this.defaultValue = obj;
this.javaOnly = false;
this.register();
}
public boolean isJavaOnly() {
return this.javaOnly;
}
private void register() {
BaritoneAPI.getSettingsRegistry().allSettings.add(this);
BaritoneAPI.getSettingsRegistry().byLowerName.put(this.name.toLowerCase(), this);
BaritoneAPI.getSettingsRegistry().settingTypes.put(this, this.value.getClass());
}
@Override
public String toString() {
return SettingsUtil.settingToString(this);
}
public Type getType() {
return (Type)this.settings.settingTypes.get(this);
}
}
}
@@ -0,0 +1,12 @@
package baritone.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SettingsRegistry {
public final Map byLowerName = new HashMap();
public final List allSettings = new ArrayList();
public final Map settingTypes = new HashMap();
}
@@ -0,0 +1,6 @@
package baritone.api.behavior;
import baritone.api.event.listener.AbstractGameEventListener;
public interface IBehavior extends AbstractGameEventListener {
}
@@ -0,0 +1,10 @@
package baritone.api.behavior;
import baritone.api.utils.Rotation;
import baritone.api.behavior.look.IAimProcessor;
public interface ILookBehavior extends IBehavior {
IAimProcessor getAimProcessor();
void updateTarget(Rotation rotation, boolean flag);
}
@@ -0,0 +1,45 @@
package baritone.api.behavior;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.path.IPathExecutor;
import java.util.Optional;
public interface IPathingBehavior extends IBehavior {
Optional estimatedTicksToGoal();
Optional getInProgress();
default Optional ticksRemainingInSegment(boolean flag) {
IPathExecutor current = this.getCurrent();
if (current == null) {
return Optional.empty();
} else {
int n = flag ? current.getPosition() : current.getPosition() + 1;
return Optional.of(current.getPath().ticksRemainingFrom(n));
}
}
boolean isPathing();
IPathExecutor getNext();
Goal getGoal();
IPathExecutor getCurrent();
default Optional ticksRemainingInSegment() {
return this.ticksRemainingInSegment(true);
}
boolean cancelEverything();
default boolean hasPath() {
return this.getCurrent() != null;
}
void forceCancel();
default Optional getPath() {
return Optional.ofNullable(this.getCurrent()).map(IPathExecutor::getPath);
}
}
@@ -0,0 +1,53 @@
package baritone.api.behavior.look;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.LongSupplier;
public final class ForkableRandom {
private static final double DOUBLE_UNIT = 1.110223E-16F;
private final long[] state;
public long next() {
long l = rotl(this.state[0] + this.state[3], 23) + this.state[0];
long l2 = this.state[1] << 17;
this.state[2] = this.state[2] ^ this.state[0];
this.state[3] = this.state[3] ^ this.state[1];
this.state[1] = this.state[1] ^ this.state[2];
this.state[0] = this.state[0] ^ this.state[3];
this.state[2] = this.state[2] ^ l2;
this.state[3] = rotl(this.state[3], 45);
return l;
}
public ForkableRandom fork() {
return new ForkableRandom(Arrays.copyOf(this.state, 4));
}
public ForkableRandom(long l) {
AtomicLong atomicLong = new AtomicLong(l);
LongSupplier longSupplier = () -> {
long l2 = atomicLong.addAndGet(-7046029254386353131L);
l2 = (l2 ^ l2 >>> 30) * -4658895280553007687L;
l2 = (l2 ^ l2 >>> 27) * -7723592293110705685L;
return l2 ^ l2 >>> 31;
};
this.state = new long[]{longSupplier.getAsLong(), longSupplier.getAsLong(), longSupplier.getAsLong(), longSupplier.getAsLong()};
}
private static long rotl(long l, int n) {
return l << n | l >>> 64 - n;
}
private ForkableRandom(long[] longs) {
this.state = longs;
}
public ForkableRandom() {
this(System.nanoTime() ^ System.currentTimeMillis());
}
public double nextDouble() {
return (double)(this.next() >>> 11) * 1.110223E-16F;
}
}
@@ -0,0 +1,9 @@
package baritone.api.behavior.look;
import baritone.api.utils.Rotation;
public interface IAimProcessor {
ITickableAimProcessor fork();
Rotation peekRotation(Rotation rotation);
}
@@ -0,0 +1,11 @@
package baritone.api.behavior.look;
import baritone.api.utils.Rotation;
public interface ITickableAimProcessor extends IAimProcessor {
void tick();
Rotation nextRotation(Rotation rotation);
void advance(int n);
}
+12
View File
@@ -0,0 +1,12 @@
package baritone.api.cache;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
public interface IBlockLookup {
default IBlockState getBlock(BlockPos pos) {
return this.getBlock(pos.getX(), pos.getY(), pos.getZ());
}
IBlockState getBlock(int n, int n2, int n3);
}
+10
View File
@@ -0,0 +1,10 @@
package baritone.api.cache;
public interface ICachedRegion extends IBlockLookup {
int getZ();
int getX();
boolean isCached(int n, int n2);
}
+18
View File
@@ -0,0 +1,18 @@
package baritone.api.cache;
import java.util.ArrayList;
import net.minecraft.world.chunk.Chunk;
public interface ICachedWorld {
void save();
boolean isCached(int n, int n2);
ArrayList getLocationsOf(String str, int n, int n2, int n3, int n4);
void reloadAllFromDisk();
void queueForPacking(Chunk chunk);
ICachedRegion getRegion(int n, int n2);
}
+13
View File
@@ -0,0 +1,13 @@
package baritone.api.cache;
import baritone.api.utils.BetterBlockPos;
public interface IWaypoint {
long getCreationTimestamp();
String getName();
WaypointTag getTag();
BetterBlockPos getLocation();
}
@@ -0,0 +1,15 @@
package baritone.api.cache;
import java.util.Set;
public interface IWaypointCollection {
void removeWaypoint(IWaypoint waypoint);
Set getByTag(WaypointTag waypointTag);
void addWaypoint(IWaypoint waypoint);
IWaypoint getMostRecentByTag(WaypointTag waypointTag);
Set getAllWaypoints();
}
+7
View File
@@ -0,0 +1,7 @@
package baritone.api.cache;
public interface IWorldData {
IWaypointCollection getWaypoints();
ICachedWorld getCachedWorld();
}
+14
View File
@@ -0,0 +1,14 @@
package baritone.api.cache;
import java.util.function.Consumer;
public interface IWorldProvider {
IWorldData getCurrentWorld();
default void ifWorldLoaded(Consumer consumer) {
IWorldData currentWorld = this.getCurrentWorld();
if (currentWorld != null) {
consumer.accept(currentWorld);
}
}
}
+25
View File
@@ -0,0 +1,25 @@
package baritone.api.cache;
import baritone.utils.ChunkPos;
import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext;
import java.util.List;
import net.minecraft.block.Block;
public interface IWorldScanner {
default List scanChunk2(IPlayerContext playerContext, List list, ChunkPos chunkPos, int n, int n2) {
return this.scanChunk(playerContext, new BlockOptionalMetaLookup(list), chunkPos, n, n2);
}
int repack(IPlayerContext playerContext);
default List scanChunkRadius2(IPlayerContext playerContext, List list, int n, int n2, int n3) {
return this.scanChunkRadius(playerContext, new BlockOptionalMetaLookup((Block[])list.toArray(new Block[0])), n, n2, n3);
}
List scanChunk(IPlayerContext playerContext, BlockOptionalMetaLookup blockOptionalMetaLookup, ChunkPos chunkPos, int n, int n2);
List scanChunkRadius(IPlayerContext playerContext, BlockOptionalMetaLookup blockOptionalMetaLookup, int n, int n2, int n3);
int repack(IPlayerContext playerContext, int n);
}
+65
View File
@@ -0,0 +1,65 @@
package baritone.api.cache;
import baritone.api.utils.BetterBlockPos;
import java.util.Date;
import net.minecraft.util.BlockPos;
public class Waypoint implements IWaypoint {
private final String name;
private final WaypointTag tag;
private final long timestamp;
private final BetterBlockPos location;
@Override
public int hashCode() {
return this.name.hashCode() ^ this.tag.hashCode() ^ this.location.hashCode() ^ Long.hashCode(this.timestamp);
}
@Override
public WaypointTag getTag() {
return this.tag;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
} else if (!(obj instanceof IWaypoint)) {
return false;
} else {
IWaypoint waypoint = (IWaypoint)obj;
return this.name.equals(waypoint.getName()) && this.tag == waypoint.getTag() && this.location.equals(waypoint.getLocation());
}
}
public Waypoint(String str, WaypointTag waypointTag, BetterBlockPos betterBlockPos, long l) {
this.name = str;
this.tag = waypointTag;
this.location = betterBlockPos;
this.timestamp = l;
}
@Override
public String toString() {
return String.format("%s %s %s", this.name, BetterBlockPos.from((BlockPos)this.location).toString(), new Date(this.timestamp).toString());
}
@Override
public String getName() {
return this.name;
}
@Override
public BetterBlockPos getLocation() {
return this.location;
}
@Override
public long getCreationTimestamp() {
return this.timestamp;
}
public Waypoint(String str, WaypointTag waypointTag, BetterBlockPos betterBlockPos) {
this(str, waypointTag, betterBlockPos, System.currentTimeMillis());
}
}
+45
View File
@@ -0,0 +1,45 @@
package baritone.api.cache;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public enum WaypointTag {
HOME(new String[]{"home", "base"}),
DEATH(new String[]{"death"}),
BED(new String[]{"bed", "spawn"}),
USER(new String[]{"user"});
private static final List VALUES = Collections.unmodifiableList(Arrays.asList(values()));
public final String[] names;
public static String[] getAllNames() {
HashSet set = new HashSet();
for (WaypointTag waypointTag : values()) {
set.addAll(Arrays.asList(waypointTag.names));
}
return (String[])set.toArray(new String[0]);
}
public String getName() {
return this.names[0];
}
public static WaypointTag getByName(String str) {
for (WaypointTag waypointTag : values()) {
for (String str2 : waypointTag.names) {
if (str2.equalsIgnoreCase(str)) {
return waypointTag;
}
}
}
return null;
}
private WaypointTag(String[] strings) {
this.names = strings;
}
}
@@ -0,0 +1,26 @@
package baritone.api.command;
import baritone.api.IBaritone;
import baritone.api.utils.IPlayerContext;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public abstract class Command implements ICommand {
public IBaritone baritone;
public IPlayerContext ctx;
public final List names;
@Override
public final List getNames() {
return this.names;
}
public Command(IBaritone baritone2, String[] strings) {
this.names = Collections.unmodifiableList(Stream.of(strings).map(str -> str.toLowerCase(Locale.US)).collect(Collectors.toList()));
this.baritone = baritone2;
this.ctx = baritone2.getPlayerContext();
}
}
@@ -0,0 +1,7 @@
package baritone.api.command;
import java.util.UUID;
public interface IBaritoneChatControl {
String FORCE_COMMAND_PREFIX = String.format("<<%s>>", UUID.randomUUID().toString());
}
@@ -0,0 +1,23 @@
package baritone.api.command;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.Helper;
import baritone.api.command.argument.IArgConsumer;
import java.util.List;
import java.util.stream.Stream;
public interface ICommand extends Helper {
String getShortDesc();
Stream tabComplete(String str, IArgConsumer argConsumer) throws CommandException;
default boolean hiddenFromHelp() {
return false;
}
void execute(String str, IArgConsumer argConsumer) throws CommandException;
List getNames();
List getLongDesc();
}
@@ -0,0 +1,7 @@
package baritone.api.command;
import baritone.api.command.argparser.IArgParserManager;
public interface ICommandSystem {
IArgParserManager getInstance();
}
@@ -0,0 +1,5 @@
package baritone.api.command.argparser;
public interface IArgParser {
Class getTarget();
}
@@ -0,0 +1,17 @@
package baritone.api.command.argparser;
import baritone.api.command.argument.ICommandArgument;
import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.command.registry.Registry;
public interface IArgParserManager {
Object parseStateless(Class clazz, ICommandArgument commandArgument) throws CommandInvalidTypeException;
Registry getRegistry();
IStatelessArgParser getParserStateless(Class clazz);
IStatedArgParser getParserStated(Class clazz, Class clazz2);
Object parseStated(Class clazz, Class clazz2, ICommandArgument commandArgument, Object obj) throws CommandInvalidTypeException;
}
@@ -0,0 +1,9 @@
package baritone.api.command.argparser;
import baritone.api.command.argument.ICommandArgument;
public interface IStatedArgParser extends IArgParser {
Class getStateType();
Object parseArg(ICommandArgument commandArgument, Object obj) throws Exception;
}
@@ -0,0 +1,7 @@
package baritone.api.command.argparser;
import baritone.api.command.argument.ICommandArgument;
public interface IStatelessArgParser extends IArgParser {
Object parseArg(ICommandArgument commandArgument) throws Exception;
}
@@ -0,0 +1,130 @@
package baritone.api.command.argument;
import baritone.api.command.datatypes.IDatatype;
import baritone.api.command.datatypes.IDatatypeFor;
import baritone.api.command.datatypes.IDatatypePost;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
import baritone.api.command.exception.CommandTooManyArgumentsException;
import java.util.Deque;
import java.util.LinkedList;
import java.util.stream.Stream;
public interface IArgConsumer {
LinkedList getArgs();
Object peekDatatypeOrNull2(IDatatypePost datatypePost);
Object peekAsOrNull(Class clazz, int n) throws CommandNotEnoughArgumentsException;
void requireMin(int n) throws CommandNotEnoughArgumentsException;
Object peekAsOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
ICommandArgument peek(int n) throws CommandNotEnoughArgumentsException;
Object getDatatypeFor(IDatatypeFor datatypeFor) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
boolean hasAny();
String peekString() throws CommandNotEnoughArgumentsException;
Enum peekEnumOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
boolean hasExactly(int n);
Object peekDatatypeForOrDefault(Class clazz, Object obj);
Object peekDatatypePostOrDefault(IDatatypePost datatypePost, Object obj, Object obj2);
String consumedString();
boolean is(Class clazz, int n) throws CommandNotEnoughArgumentsException;
Object getDatatypePost(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
boolean is(Class clazz) throws CommandNotEnoughArgumentsException;
Object peekDatatypePostOrNull(IDatatypePost datatypePost, Object obj);
Enum getEnum(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
ICommandArgument consumed();
boolean hasConsumed();
Object getAs(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
Object peekDatatypeForOrNull(Class clazz);
boolean hasAtMost(int n);
String rawRest();
boolean hasExactlyOne();
Object peekDatatype2(IDatatypeFor datatypeFor) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
Object peekDatatypeOrNull(IDatatypeFor datatypeFor);
Object getAsOrDefault(Class clazz, Object obj) throws CommandNotEnoughArgumentsException;
boolean hasAtMostOne();
Enum peekEnum(Class clazz, int n) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
ICommandArgument get() throws CommandNotEnoughArgumentsException;
Stream tabCompleteDatatype(IDatatype datatype);
Object getDatatypeForOrNull(IDatatypeFor datatypeFor);
Object getDatatypePostOrNull(IDatatypePost datatypePost, Object obj);
void requireExactly(int n) throws CommandException;
Object peekDatatypePost(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
void requireMax(int n) throws CommandTooManyArgumentsException;
Enum peekEnum(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
ICommandArgument peek() throws CommandNotEnoughArgumentsException;
Object peekAsOrDefault(Class clazz, Object obj) throws CommandNotEnoughArgumentsException;
Enum getEnumOrDefault(Class clazz, Enum obj) throws CommandNotEnoughArgumentsException;
String getString() throws CommandNotEnoughArgumentsException;
Object peekDatatypeFor(Class clazz);
String peekString(int n) throws CommandNotEnoughArgumentsException;
Object peekAs(Class clazz, int n) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
Object peekDatatype(IDatatypePost datatypePost) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
Enum peekEnumOrNull(Class clazz, int n) throws CommandNotEnoughArgumentsException;
Object peekAsOrDefault(Class clazz, Object obj, int n) throws CommandNotEnoughArgumentsException;
Enum getEnumOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
IArgConsumer copy();
boolean has(int n);
Object getDatatypePostOrDefault(IDatatypePost datatypePost, Object obj, Object obj2);
Object getDatatypeForOrDefault(IDatatypeFor datatypeFor, Object obj);
Object peekDatatype(IDatatypePost datatypePost, Object obj) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
Deque getConsumed();
Object getAsOrNull(Class clazz) throws CommandNotEnoughArgumentsException;
Object peekAs(Class clazz) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
}
@@ -0,0 +1,21 @@
package baritone.api.command.argument;
import baritone.api.command.exception.CommandInvalidTypeException;
public interface ICommandArgument {
boolean is(Class clazz);
int getIndex();
String getValue();
String getRawRest();
Object getAs(Class clazz) throws CommandInvalidTypeException;
Object getAs(Class clazz, Class clazz2, Object obj) throws CommandInvalidTypeException;
boolean is(Class clazz, Class clazz2, Object obj);
Enum getEnum(Class clazz) throws CommandInvalidTypeException;
}
@@ -0,0 +1,37 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
public enum BlockById implements IDatatypeFor {
INSTANCE;
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?[a-z0-9/_.-]*");
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
String string = datatypeContext.getConsumer().getString();
return !PATTERN.matcher(string).matches()
? Stream.empty()
: new TabCompleteHelper().append(Block.blockRegistry.getKeys().stream().map(Object::toString)).filterPrefixNamespaced(string).sortAlphabetically().getStream();
}
public Block get2(IDatatypeContext datatypeContext) throws CommandException {
ResourceLocation location = new ResourceLocation(datatypeContext.getConsumer().getString());
Block block;
if ((block = (Block)Block.blockRegistry.getObject(location)) == Blocks.air) {
throw new IllegalArgumentException("no block found by that id");
} else {
return block;
}
}
}
@@ -0,0 +1,43 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.stream.Stream;
import net.minecraft.entity.EntityList;
import net.minecraft.util.ResourceLocation;
public enum EntityClassById implements IDatatypeFor {
INSTANCE;
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
return new TabCompleteHelper().append(EntityList.getEntityNameList().stream().map(Object::toString)).filterPrefixNamespaced(datatypeContext.getConsumer().getString()).sortAlphabetically().getStream();
}
public Class get2(IDatatypeContext datatypeContext) throws CommandException {
ResourceLocation location = new ResourceLocation(datatypeContext.getConsumer().getString());
Class clazz;
try {
clazz = (Class)EntityList.idToClassMapping.get(location);
} catch (NoSuchFieldError e) {
try {
Class[] clazzs = new Class[]{ResourceLocation.class};
clazz = (Class)EntityList.class.getMethod("getClass", clazzs).invoke(null, location);
} catch (Exception e2) {
throw new RuntimeException("EntityList.REGISTRY does not exist and failed to call the Forge-replacement method", e2);
}
}
if (clazz == null) {
throw new IllegalArgumentException("no entity found by that id");
} else {
return clazz;
}
}
}
@@ -0,0 +1,28 @@
package baritone.api.command.datatypes;
import net.minecraft.util.EnumFacing;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.Locale;
import java.util.stream.Stream;
public enum ForAxis implements IDatatypeFor {
INSTANCE;
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
return new TabCompleteHelper()
.append(Stream.of(EnumFacing.Axis.values()).map(EnumFacing.Axis::getName).map(String::toLowerCase))
.filterPrefix(datatypeContext.getConsumer().getString())
.getStream();
}
public EnumFacing.Axis get2(IDatatypeContext datatypeContext) throws CommandException {
return EnumFacing.Axis.valueOf(datatypeContext.getConsumer().getString().toUpperCase(Locale.US));
}
}
@@ -0,0 +1,90 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.util.ResourceLocation;
public enum ForBlockOptionalMeta implements IDatatypeFor {
INSTANCE;
private static Pattern PATTERN = Pattern.compile(
"(?:[a-z0-9_.-]+:)?(?:[a-z0-9/_.-]+(?:\\[(?:(?:[a-z0-9_.-]+=[a-z0-9_.-]+,)*(?:[a-z0-9_.-]+(?:=(?:[a-z0-9_.-]+(?:\\])?)?)?)?|\\])?)?)?"
);
public BlockOptionalMeta get2(IDatatypeContext datatypeContext) throws CommandException {
return new BlockOptionalMeta(datatypeContext.getConsumer().getString());
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
String str = datatypeContext.getConsumer().peekString();
if (!PATTERN.matcher(str).matches()) {
datatypeContext.getConsumer().getString();
return Stream.empty();
} else if (str.endsWith("]")) {
datatypeContext.getConsumer().getString();
return Stream.empty();
} else if (!str.contains("[")) {
return datatypeContext.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
} else {
datatypeContext.getConsumer().getString();
String[] strings = splitLast(str, '[');
String str2 = strings[0];
String str3 = strings[1];
Block object = (Block)Block.blockRegistry.getObject(new ResourceLocation(str2));
if (object == null) {
return Stream.empty();
} else {
String[] strings2 = splitLast(str3, ',');
String str4 = strings2[0];
String str5 = strings2[1];
if (!str5.contains("=")) {
Set set = Stream.of(str4.split(",")).map(str6 -> str6.split("=")[0]).collect(Collectors.toSet());
String str7 = str.substring(0, str.length() - str5.length());
return new TabCompleteHelper()
.append(object.getBlockState().getProperties().stream().map(obj -> ((IProperty)obj).getName()))
.filter(obj2 -> !set.contains(obj2))
.filterPrefix(str5)
.sortAlphabetically()
.map(obj3 -> str7 + obj3)
.getStream();
} else {
String[] strings3 = splitLast(str5, '=');
String str8 = strings3[0];
String str9 = strings3[1];
String str10 = str.substring(0, str.length() - str9.length());
IProperty property = null;
for (IProperty property2 : (Iterable<IProperty>)(object.getBlockState().getProperties())) {
if (property2.getName().equals(str8)) {
property = property2;
break;
}
}
return property == null ? Stream.empty() : new TabCompleteHelper().append(getValueNames(property)).filterPrefix(str9).sortAlphabetically().map(obj4 -> str10 + obj4).getStream();
}
}
}
}
private static String[] splitLast(String str, char ch) {
int n = str.lastIndexOf(ch);
return n == -1 ? new String[]{"", str} : new String[]{str.substring(0, n), str.substring(n + 1)};
}
private static Stream getValueNames(IProperty property) {
return property.getAllowedValues().stream().map(obj -> property.getName((Comparable)obj));
}
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
}
@@ -0,0 +1,25 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.Locale;
import java.util.stream.Stream;
import net.minecraft.util.EnumFacing;
public enum ForEnumFacing implements IDatatypeFor {
INSTANCE;
public EnumFacing get2(IDatatypeContext datatypeContext) throws CommandException {
return EnumFacing.valueOf(datatypeContext.getConsumer().getString().toUpperCase(Locale.US));
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
return new TabCompleteHelper().append(Stream.of(EnumFacing.values()).map(EnumFacing::getName).map(String::toLowerCase)).filterPrefix(datatypeContext.getConsumer().getString()).getStream();
}
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
}
@@ -0,0 +1,50 @@
package baritone.api.command.datatypes;
import baritone.api.IBaritone;
import baritone.api.cache.IWaypoint;
import baritone.api.cache.IWaypointCollection;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.cache.WaypointTag;
import java.util.Comparator;
import java.util.stream.Stream;
public enum ForWaypoints implements IDatatypeFor {
INSTANCE;
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
return new TabCompleteHelper().append2(getWaypointNames(datatypeContext.getBaritone())).sortAlphabetically().prepend3(WaypointTag.getAllNames()).filterPrefix(datatypeContext.getConsumer().getString()).getStream();
}
public static IWaypoint[] getWaypointsByTag(IBaritone baritone, WaypointTag waypointTag) {
return (IWaypoint[])waypoints(baritone).getByTag(waypointTag).stream().sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed()).toArray(IWaypoint[]::new);
}
public static String[] getWaypointNames(IBaritone baritone) {
return Stream.of(getWaypoints(baritone)).map(IWaypoint::getName).filter(str -> !str.isEmpty()).toArray(String[]::new);
}
public static IWaypointCollection waypoints(IBaritone baritone) {
return baritone.getWorldProvider().getCurrentWorld().getWaypoints();
}
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
public static IWaypoint[] getWaypointsByName(IBaritone baritone, String str) {
return Stream.of(getWaypoints(baritone)).filter(waypoint -> waypoint.getName().equalsIgnoreCase(str)).toArray(IWaypoint[]::new);
}
public IWaypoint[] get2(IDatatypeContext datatypeContext) throws CommandException {
String string = datatypeContext.getConsumer().getString();
WaypointTag byName = WaypointTag.getByName(string);
return byName == null ? getWaypointsByName(datatypeContext.getBaritone(), string) : getWaypointsByTag(datatypeContext.getBaritone(), byName);
}
public static IWaypoint[] getWaypoints(IBaritone baritone) {
return (IWaypoint[])waypoints(baritone).getAllWaypoints().stream().sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed()).toArray(IWaypoint[]::new);
}
}
@@ -0,0 +1,8 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import java.util.stream.Stream;
public interface IDatatype {
Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException;
}
@@ -0,0 +1,10 @@
package baritone.api.command.datatypes;
import baritone.api.IBaritone;
import baritone.api.command.argument.IArgConsumer;
public interface IDatatypeContext {
IBaritone getBaritone();
IArgConsumer getConsumer();
}
@@ -0,0 +1,7 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
public interface IDatatypeFor extends IDatatype {
Object get(IDatatypeContext datatypeContext) throws CommandException;
}
@@ -0,0 +1,7 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
public interface IDatatypePost extends IDatatype {
Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException;
}
@@ -0,0 +1,30 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.List;
import java.util.stream.Stream;
import net.minecraft.entity.player.EntityPlayer;
public enum NearbyPlayer implements IDatatypeFor {
INSTANCE;
public EntityPlayer get2(IDatatypeContext datatypeContext) throws CommandException {
String string = datatypeContext.getConsumer().getString();
return (EntityPlayer)(getPlayers(datatypeContext).stream().filter(obj -> ((EntityPlayer)obj).getName().equalsIgnoreCase(string)).findFirst().orElse(null));
}
private static List getPlayers(IDatatypeContext datatypeContext) {
return datatypeContext.getBaritone().getPlayerContext().world().playerEntities;
}
@Override
public Object get(IDatatypeContext datatypeContext) throws CommandException {
return this.get2(datatypeContext);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
return new TabCompleteHelper().append(getPlayers(datatypeContext).stream().map(obj -> ((EntityPlayer)obj).getName())).filterPrefix(datatypeContext.getConsumer().getString()).sortAlphabetically().getStream();
}
}
@@ -0,0 +1,44 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.argument.IArgConsumer;
import java.util.stream.Stream;
public enum RelativeBlockPos implements IDatatypePost {
INSTANCE;
public BetterBlockPos apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
if (betterBlockPos == null) {
betterBlockPos = BetterBlockPos.ORIGIN2;
}
IArgConsumer consumer = datatypeContext.getConsumer();
return new BetterBlockPos(
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2),
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2),
(Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2)
);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
IArgConsumer consumer = datatypeContext.getConsumer();
if (consumer.hasAny() && !consumer.has(4)) {
while (consumer.has(2) && consumer.peekDatatypeOrNull2(RelativeCoordinate.INSTANCE) != null) {
consumer.get();
}
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
} else {
return Stream.empty();
}
}
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (BetterBlockPos)obj);
}
}
@@ -0,0 +1,48 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.argument.IArgConsumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
public enum RelativeCoordinate implements IDatatypePost {
INSTANCE;
private static String SCALES = "[kKmM]";
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + SCALES + "?)|)$");
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (Double)obj);
}
public Double apply2(IDatatypeContext datatypeContext, Double d) throws CommandException {
if (d == null) {
d = 0.0;
}
Matcher matcher = PATTERN.matcher(datatypeContext.getConsumer().getString());
if (!matcher.matches()) {
throw new IllegalArgumentException("pattern doesn't match");
} else {
boolean flag = !matcher.group(1).isEmpty();
double d2 = matcher.group(2).isEmpty() ? 0.0 : Double.parseDouble(matcher.group(2).replaceAll(SCALES, ""));
if (matcher.group(2).toLowerCase().contains("k")) {
d2 *= 1000.0;
}
if (matcher.group(2).toLowerCase().contains("m")) {
d2 *= 1000000.0;
}
return flag ? d + d2 : d2;
}
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) throws CommandException {
IArgConsumer consumer = datatypeContext.getConsumer();
return !consumer.has(2) && consumer.getString().matches("^(~|$)") ? Stream.of("~") : Stream.empty();
}
}
@@ -0,0 +1,75 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.Helper;
import baritone.api.command.argument.IArgConsumer;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.FileSystems;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;
import net.minecraft.client.Minecraft;
public enum RelativeFile implements IDatatypePost {
INSTANCE;
public File apply2(IDatatypeContext datatypeContext, File file) throws CommandException {
if (file == null) {
file = new File("./");
}
Path path;
try {
path = FileSystems.getDefault().getPath(datatypeContext.getConsumer().getString());
} catch (InvalidPathException e) {
throw new IllegalArgumentException("invalid path");
}
return getCanonicalFileUnchecked(file.toPath().resolve(path).toFile());
}
public static File gameDir(Minecraft mc) {
File absoluteFile = mc.mcDataDir.getAbsoluteFile();
return absoluteFile.getName().equals(".") ? absoluteFile.getParentFile() : absoluteFile;
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) {
return Stream.empty();
}
private static File getCanonicalFileUnchecked(File file) {
try {
return file.getCanonicalFile();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public static Stream tabComplete(IArgConsumer argConsumer, File file) throws CommandException {
File canonicalFileUnchecked = getCanonicalFileUnchecked(file);
String string = argConsumer.getString();
Path path = FileSystems.getDefault().getPath(string);
Path path2 = path.isAbsolute() ? path.getRoot() : canonicalFileUnchecked.toPath();
boolean flag = !string.isEmpty() && !string.endsWith(File.separator);
File file2 = path.isAbsolute() ? path.toFile() : new File(canonicalFileUnchecked, string);
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(flag ? file2.getParentFile() : file2).listFiles()))
.map(file3 -> (path.isAbsolute() ? file3 : path2.relativize(file3.toPath()).toString()) + (file3.isDirectory() ? File.separator : ""))
.filter(str -> str.toLowerCase(Locale.US).startsWith(string.toLowerCase(Locale.US)))
.filter(str2 -> !str2.contains(" "));
}
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (File)obj);
}
@Deprecated
public static File gameDir() {
return gameDir(Helper.mc);
}
}
@@ -0,0 +1,46 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.argument.IArgConsumer;
import java.util.stream.Stream;
public enum RelativeGoal implements IDatatypePost {
INSTANCE;
public Goal apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
if (betterBlockPos == null) {
betterBlockPos = BetterBlockPos.ORIGIN2;
}
IArgConsumer consumer = datatypeContext.getConsumer();
GoalBlock goalBlock = (GoalBlock)consumer.peekDatatypePostOrNull(RelativeGoalBlock.INSTANCE, betterBlockPos);
if (goalBlock != null) {
return goalBlock;
} else {
GoalXZ goalXZ = (GoalXZ)consumer.peekDatatypePostOrNull(RelativeGoalXZ.INSTANCE, betterBlockPos);
if (goalXZ != null) {
return goalXZ;
} else {
GoalYLevel goalYLevel = (GoalYLevel)consumer.peekDatatypePostOrNull(RelativeGoalYLevel.INSTANCE, betterBlockPos);
return (Goal)(goalYLevel != null ? goalYLevel : new GoalBlock(betterBlockPos));
}
}
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) {
return datatypeContext.getConsumer().tabCompleteDatatype(RelativeCoordinate.INSTANCE);
}
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (BetterBlockPos)obj);
}
}
@@ -0,0 +1,38 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.argument.IArgConsumer;
import java.util.stream.Stream;
import net.minecraft.util.MathHelper;
public enum RelativeGoalBlock implements IDatatypePost {
INSTANCE;
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (BetterBlockPos)obj);
}
public GoalBlock apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
if (betterBlockPos == null) {
betterBlockPos = BetterBlockPos.ORIGIN2;
}
IArgConsumer consumer = datatypeContext.getConsumer();
return new GoalBlock(
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2)),
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2)),
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2))
);
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) {
IArgConsumer consumer = datatypeContext.getConsumer();
return consumer.hasAtMost(3) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
}
}
@@ -0,0 +1,37 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.argument.IArgConsumer;
import java.util.stream.Stream;
import net.minecraft.util.MathHelper;
public enum RelativeGoalXZ implements IDatatypePost {
INSTANCE;
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) {
IArgConsumer consumer = datatypeContext.getConsumer();
return consumer.hasAtMost(2) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
}
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (BetterBlockPos)obj);
}
public GoalXZ apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
if (betterBlockPos == null) {
betterBlockPos = BetterBlockPos.ORIGIN2;
}
IArgConsumer consumer = datatypeContext.getConsumer();
return new GoalXZ(
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.x2)),
MathHelper.floor_double((Double)consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.z2))
);
}
}
@@ -0,0 +1,33 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.argument.IArgConsumer;
import java.util.stream.Stream;
import net.minecraft.util.MathHelper;
public enum RelativeGoalYLevel implements IDatatypePost {
INSTANCE;
@Override
public Object apply(IDatatypeContext datatypeContext, Object obj) throws CommandException {
return this.apply2(datatypeContext, (BetterBlockPos)obj);
}
public GoalYLevel apply2(IDatatypeContext datatypeContext, BetterBlockPos betterBlockPos) throws CommandException {
if (betterBlockPos == null) {
betterBlockPos = BetterBlockPos.ORIGIN2;
}
return new GoalYLevel(MathHelper.floor_double((Double)datatypeContext.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double)betterBlockPos.y2)));
}
@Override
public Stream tabComplete(IDatatypeContext datatypeContext) {
IArgConsumer consumer = datatypeContext.getConsumer();
return consumer.hasAtMost(1) ? consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE) : Stream.empty();
}
}
@@ -0,0 +1,11 @@
package baritone.api.command.exception;
public abstract class CommandErrorMessageException extends CommandException {
public CommandErrorMessageException(String str, Throwable t) {
super(str, t);
}
public CommandErrorMessageException(String str) {
super(str);
}
}
@@ -0,0 +1,11 @@
package baritone.api.command.exception;
public abstract class CommandException extends Exception implements ICommandException {
public CommandException(String str, Throwable t) {
super(str, t);
}
public CommandException(String str) {
super(str);
}
}
@@ -0,0 +1,21 @@
package baritone.api.command.exception;
import baritone.api.command.argument.ICommandArgument;
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
public final ICommandArgument arg;
public CommandInvalidArgumentException(ICommandArgument commandArgument, String str) {
super(formatMessage(commandArgument, str));
this.arg = commandArgument;
}
public CommandInvalidArgumentException(ICommandArgument commandArgument, String str, Throwable t) {
super(formatMessage(commandArgument, str), t);
this.arg = commandArgument;
}
private static String formatMessage(ICommandArgument commandArgument, String str) {
return String.format("Error at argument #%s: %s", commandArgument.getIndex() == -1 ? "<unknown>" : Integer.toString(commandArgument.getIndex() + 1), str);
}
}
@@ -0,0 +1,7 @@
package baritone.api.command.exception;
public class CommandInvalidStateException extends CommandErrorMessageException {
public CommandInvalidStateException(String str) {
super(str);
}
}
@@ -0,0 +1,22 @@
package baritone.api.command.exception;
import baritone.api.command.argument.ICommandArgument;
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, String str2, Throwable t) {
super(commandArgument, String.format("Expected %s, but got %s instead", str, str2), t);
}
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, Throwable t) {
super(commandArgument, String.format("Expected %s", str), t);
}
public CommandInvalidTypeException(ICommandArgument commandArgument, String str) {
super(commandArgument, String.format("Expected %s", str));
}
public CommandInvalidTypeException(ICommandArgument commandArgument, String str, String str2) {
super(commandArgument, String.format("Expected %s, but got %s instead", str, str2));
}
}
@@ -0,0 +1,8 @@
package baritone.api.command.exception;
public class CommandNoParserForTypeException extends CommandUnhandledException {
public CommandNoParserForTypeException(Class clazz) {
super(String.format("Could not find a handler for type %s", clazz.getSimpleName()));
}
}
@@ -0,0 +1,7 @@
package baritone.api.command.exception;
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
public CommandNotEnoughArgumentsException(int n) {
super(String.format("Not enough arguments (expected at least %d)", n));
}
}
@@ -0,0 +1,19 @@
package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.utils.Helper;
import java.util.List;
public class CommandNotFoundException extends CommandException {
public final String command;
public CommandNotFoundException(String str) {
super(String.format("Command not found: %s", str));
this.command = str;
}
@Override
public void handle(ICommand command2, List list) {
Helper.HELPER.logDirect2(this.getMessage());
}
}
@@ -0,0 +1,7 @@
package baritone.api.command.exception;
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
public CommandTooManyArgumentsException(int n) {
super(String.format("Too many arguments (expected at most %d)", n));
}
}
@@ -0,0 +1,20 @@
package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.utils.Helper;
import java.util.List;
public class CommandUnhandledException extends RuntimeException implements ICommandException {
@Override
public void handle(ICommand command, List list) {
Helper.HELPER.logUnhandledException(this);
}
public CommandUnhandledException(Throwable t) {
super(t);
}
public CommandUnhandledException(String str) {
super(str);
}
}
@@ -0,0 +1,14 @@
package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.utils.Helper;
import java.util.List;
import net.minecraft.util.EnumChatFormatting;
public interface ICommandException {
String getMessage();
default void handle(ICommand command, List list) {
Helper.HELPER.logDirect3(this.getMessage(), EnumChatFormatting.RED);
}
}
@@ -0,0 +1,7 @@
package baritone.api.command.helpers;
import baritone.api.command.exception.CommandException;
public interface CommandFunction {
Object apply(Object obj) throws CommandException;
}
@@ -0,0 +1,152 @@
package baritone.api.command.helpers;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.utils.Helper;
import baritone.api.command.argument.IArgConsumer;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.HoverEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
public class Paginator implements Helper {
public final List entries;
public int pageSize = 8;
public int page = 1;
public void display(Function function, String str) {
int n = (this.page - 1) * this.pageSize;
for (int j = n; j < n + this.pageSize; j++) {
if (j < this.entries.size()) {
this.logDirect(new IChatComponent[]{(IChatComponent)function.apply(this.entries.get(j))});
} else {
this.logDirect3("--", EnumChatFormatting.DARK_GRAY);
}
}
boolean flag = str != null && this.validPage(this.page - 1);
boolean flag2 = str != null && this.validPage(this.page + 1);
ChatComponentText chatComponentText = new ChatComponentText("<<");
if (flag) {
chatComponentText.getChatStyle()
.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", str, this.page - 1)))
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Click to view previous page")));
} else {
chatComponentText.getChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
}
ChatComponentText chatComponentText2 = new ChatComponentText(">>");
if (flag2) {
chatComponentText2.getChatStyle()
.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", str, this.page + 1)))
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Click to view next page")));
} else {
chatComponentText2.getChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
}
ChatComponentText chatComponentText3 = new ChatComponentText("");
chatComponentText3.getChatStyle().setColor(EnumChatFormatting.GRAY);
chatComponentText3.appendSibling(chatComponentText);
chatComponentText3.appendText(" | ");
chatComponentText3.appendSibling(chatComponentText2);
chatComponentText3.appendText(String.format(" %d/%d", this.page, this.getMaxPage()));
this.logDirect(new IChatComponent[]{chatComponentText3});
}
public void display(Function function) {
this.display(function, null);
}
public static void paginate(IArgConsumer argConsumer, List list, Runnable runnable, Function function) throws CommandException {
paginate3(argConsumer, new Paginator(list), runnable, function, null);
}
public static void paginate5(IArgConsumer argConsumer, Object[] array, Function function, String str) throws CommandException {
paginate2(argConsumer, Arrays.asList(array), null, function, str);
}
public boolean validPage(int n) {
return n > 0 && n <= this.getMaxPage();
}
public Paginator skipPages(int n) {
this.page += n;
return this;
}
public static void paginate3(IArgConsumer argConsumer, List list, Function function) throws CommandException {
paginate3(argConsumer, new Paginator(list), null, function, null);
}
public static void paginate2(IArgConsumer argConsumer, Paginator paginator, Function function) throws CommandException {
paginate3(argConsumer, paginator, null, function, null);
}
public static void paginate(IArgConsumer argConsumer, Object[] array, Function function) throws CommandException {
paginate2(argConsumer, Arrays.asList(array), null, function, null);
}
public static void paginate6(IArgConsumer argConsumer, Paginator paginator, Runnable runnable, Function function) throws CommandException {
paginate3(argConsumer, paginator, runnable, function, null);
}
public static void paginate3(IArgConsumer argConsumer, Paginator paginator, Runnable runnable, Function function, String str) throws CommandException {
int n = 1;
argConsumer.requireMax(1);
if (argConsumer.hasAny()) {
n = (Integer)argConsumer.getAs(Integer.class);
if (!paginator.validPage(n)) {
throw new CommandInvalidTypeException(argConsumer.consumed(), String.format("a valid page (1-%d)", paginator.getMaxPage()), argConsumer.consumed().getValue());
}
}
paginator.skipPages(n - paginator.page);
if (runnable != null) {
runnable.run();
}
paginator.display(function, str);
}
public Paginator setPageSize(int n) {
this.pageSize = n;
return this;
}
public Paginator(List list) {
this.entries = list;
}
public static void paginate(IArgConsumer argConsumer, Object[] array, Runnable runnable, Function function, String str) throws CommandException {
paginate2(argConsumer, Arrays.asList(array), runnable, function, str);
}
public static void paginate4(IArgConsumer argConsumer, Object[] array, Runnable runnable, Function function) throws CommandException {
paginate2(argConsumer, Arrays.asList(array), runnable, function, null);
}
public static void paginate2(IArgConsumer argConsumer, Paginator paginator, Function function, String str) throws CommandException {
paginate3(argConsumer, paginator, null, function, str);
}
public static void paginate2(IArgConsumer argConsumer, List list, Runnable runnable, Function function, String str) throws CommandException {
paginate3(argConsumer, new Paginator(list), runnable, function, str);
}
public Paginator(Object[] array) {
this.entries = Arrays.asList(array);
}
public int getMaxPage() {
return (this.entries.size() - 1) / this.pageSize + 1;
}
public static void paginate3(IArgConsumer argConsumer, List list, Function function, String str) throws CommandException {
paginate3(argConsumer, new Paginator(list), null, function, str);
}
}
@@ -0,0 +1,107 @@
package baritone.api.command.helpers;
import baritone.api.Settings;
import baritone.api.BaritoneAPI;
import baritone.api.command.ICommand;
import baritone.api.command.manager.ICommandManager;
import baritone.api.utils.SettingsUtil;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.util.ResourceLocation;
public class TabCompleteHelper {
private Stream stream;
public TabCompleteHelper filter(Predicate predicate) {
this.stream = this.stream.filter(predicate);
return this;
}
public TabCompleteHelper append(Stream stream2) {
this.stream = Stream.concat(this.stream, stream2);
return this;
}
public TabCompleteHelper prepend(Stream stream2) {
this.stream = Stream.concat(stream2, this.stream);
return this;
}
public TabCompleteHelper sortAlphabetically() {
return this.sort(String.CASE_INSENSITIVE_ORDER);
}
public TabCompleteHelper filterPrefixNamespaced(String str) {
return this.filterPrefix(new ResourceLocation(str).toString());
}
public TabCompleteHelper prepend2(Class clazz) {
return this.prepend(Stream.of((Enum[])clazz.getEnumConstants()).map(Enum::name).map(String::toLowerCase));
}
public TabCompleteHelper() {
this.stream = Stream.empty();
}
public String[] build() {
return (String[])this.stream.toArray(String[]::new);
}
public TabCompleteHelper filterPrefix(String str) {
return this.filter(obj -> ((String)obj).toLowerCase(Locale.US).startsWith(str.toLowerCase(Locale.US)));
}
public TabCompleteHelper append3(Class clazz) {
return this.append(Stream.of((Enum[])clazz.getEnumConstants()).map(Enum::name).map(String::toLowerCase));
}
public Stream getStream() {
return this.stream;
}
public TabCompleteHelper(List list) {
this.stream = list.stream();
}
public TabCompleteHelper addModifiedSettings() {
return this.append(SettingsUtil.modifiedSettings(BaritoneAPI.getSettings()).stream().map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
}
public TabCompleteHelper(String[] strings) {
this.stream = Stream.of(strings);
}
public TabCompleteHelper addCommands(ICommandManager commandManager) {
return this.append(commandManager.getRegistry().descendingStream().flatMap(obj -> ((ICommand)obj).getNames().stream()).distinct());
}
public TabCompleteHelper addSettings() {
return this.append(BaritoneAPI.getSettings().allSettings.stream().filter(setting -> !setting.isJavaOnly()).map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
}
public TabCompleteHelper prepend3(String[] strings) {
return this.prepend(Stream.of(strings));
}
public TabCompleteHelper addToggleableSettings() {
return this.append(BaritoneAPI.getSettings().getAllValuesByType(Boolean.class).stream().map(Settings.Setting::getName).sorted(String.CASE_INSENSITIVE_ORDER));
}
public TabCompleteHelper sort(Comparator comparator) {
this.stream = this.stream.sorted(comparator);
return this;
}
public TabCompleteHelper append2(String[] strings) {
return this.append(Stream.of(strings));
}
public TabCompleteHelper map(Function function) {
this.stream = this.stream.map(function);
return this;
}
}
@@ -0,0 +1,23 @@
package baritone.api.command.manager;
import baritone.api.IBaritone;
import baritone.api.command.ICommand;
import baritone.api.command.registry.Registry;
import java.util.stream.Stream;
import net.minecraft.util.Tuple;
public interface ICommandManager {
ICommand getCommand(String str);
IBaritone getBaritone();
Registry getRegistry();
Stream tabComplete2(String str);
boolean execute(String str);
boolean execute2(Tuple tuple);
Stream tabComplete(Tuple tuple);
}
@@ -0,0 +1,55 @@
package baritone.api.command.registry;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class Registry {
private final Deque entries = new LinkedList();
private final Set registered = new HashSet();
public final Collection registry = Collections.unmodifiableCollection(this.entries);
public boolean registered(Object obj) {
return this.registered.contains(obj);
}
public void unregister(Object obj) {
if (this.registered(obj)) {
this.entries.remove(obj);
this.registered.remove(obj);
}
}
public Iterator iterator() {
return this.entries.iterator();
}
public Stream stream() {
return this.entries.stream();
}
public Stream descendingStream() {
return StreamSupport.stream(Spliterators.spliterator(this.descendingIterator(), (long)this.entries.size(), 16448), false);
}
public boolean register(Object obj) {
if (!this.registered(obj)) {
this.entries.addFirst(obj);
this.registered.add(obj);
return true;
} else {
return false;
}
}
public Iterator descendingIterator() {
return this.entries.descendingIterator();
}
}
@@ -0,0 +1,22 @@
package baritone.api.event.events;
import baritone.utils.ChunkPos;
import java.util.List;
public final class BlockChangeEvent {
private final ChunkPos chunkPos;
private final List blocks;
public ChunkPos getChunkPos() {
return this.chunkPos;
}
public BlockChangeEvent(ChunkPos chunkPos2, List list) {
this.chunkPos = chunkPos2;
this.blocks = list;
}
public List getBlocks() {
return this.blocks;
}
}
@@ -0,0 +1,27 @@
package baritone.api.event.events;
import net.minecraft.util.BlockPos;
public final class BlockInteractEvent {
private final BlockPos pos;
private final BlockInteractEvent.Type type;
public final BlockPos getPos() {
return this.pos;
}
public BlockInteractEvent(BlockPos pos2, BlockInteractEvent.Type type2) {
this.pos = pos2;
this.type = type2;
}
public final BlockInteractEvent.Type getType() {
return this.type;
}
public enum Type {
START_BREAK,
USE;
}
}
@@ -0,0 +1,15 @@
package baritone.api.event.events;
import baritone.api.event.events.type.Cancellable;
public final class ChatEvent extends Cancellable {
private final String message;
public ChatEvent(String str) {
this.message = str;
}
public final String getMessage() {
return this.message;
}
}
@@ -0,0 +1,49 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
public final class ChunkEvent {
private final EventState state;
private final ChunkEvent.Type type;
private final int x;
private final int z;
public ChunkEvent.Type getType() {
return this.type;
}
public int getZ() {
return this.z;
}
public EventState getState() {
return this.state;
}
public boolean isPostPopulate() {
return this.state == EventState.POST && this.type.isPopulate();
}
public ChunkEvent(EventState event, ChunkEvent.Type type2, int n, int n2) {
this.state = event;
this.type = type2;
this.x = n;
this.z = n2;
}
public int getX() {
return this.x;
}
public enum Type {
LOAD,
UNLOAD,
POPULATE_FULL,
POPULATE_PARTIAL;
public final boolean isPopulate() {
return this == POPULATE_FULL || this == POPULATE_PARTIAL;
}
}
}
@@ -0,0 +1,33 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
public final class PacketEvent {
private final NetworkManager networkManager;
private final EventState state;
private final Packet packet;
public final Packet getPacket() {
return this.packet;
}
public final Packet getPacket2() {
return this.packet;
}
public final NetworkManager getNetworkManager() {
return this.networkManager;
}
public final EventState getState() {
return this.state;
}
public PacketEvent(NetworkManager networkManager2, EventState event, Packet packet2) {
this.networkManager = networkManager2;
this.state = event;
this.packet = packet2;
}
}
@@ -0,0 +1,16 @@
package baritone.api.event.events;
public enum PathEvent {
CALC_STARTED,
CALC_FINISHED_NOW_EXECUTING,
CALC_FAILED,
NEXT_SEGMENT_CALC_STARTED,
NEXT_SEGMENT_CALC_FINISHED,
CONTINUING_ONTO_PLANNED_NEXT,
SPLICING_ONTO_NEXT_EARLY,
AT_GOAL,
PATH_FINISHED_NEXT_STILL_CALCULATING,
NEXT_CALC_FAILED,
DISCARD_NEXT,
CANCELED;
}
@@ -0,0 +1,15 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
public final class PlayerUpdateEvent {
private final EventState state;
public final EventState getState() {
return this.state;
}
public PlayerUpdateEvent(EventState event) {
this.state = event;
}
}
@@ -0,0 +1,13 @@
package baritone.api.event.events;
public final class RenderEvent {
private final float partialTicks;
public final float getPartialTicks() {
return this.partialTicks;
}
public RenderEvent(float f) {
this.partialTicks = f;
}
}
@@ -0,0 +1,47 @@
package baritone.api.event.events;
import baritone.api.utils.Rotation;
public final class RotationMoveEvent {
private final RotationMoveEvent.Type type;
private final Rotation original;
private float yaw;
private float pitch;
public Rotation getOriginal() {
return this.original;
}
public float getPitch() {
return this.pitch;
}
public RotationMoveEvent(RotationMoveEvent.Type type2, float f, float f2) {
this.type = type2;
this.original = new Rotation(f, f2);
this.yaw = f;
this.pitch = f2;
}
public void setYaw(float f) {
this.yaw = f;
}
public void setPitch(float f) {
this.pitch = f;
}
public RotationMoveEvent.Type getType() {
return this.type;
}
public float getYaw() {
return this.yaw;
}
public enum Type {
MOTION_UPDATE,
JUMP;
}
}
@@ -0,0 +1,13 @@
package baritone.api.event.events;
public final class SprintStateEvent {
private Boolean state;
public final Boolean getState() {
return this.state;
}
public final void setState(boolean flag) {
this.state = flag;
}
}
@@ -0,0 +1,13 @@
package baritone.api.event.events;
import baritone.api.event.events.type.Cancellable;
public class TabCompleteEvent extends Cancellable {
public final String prefix;
public String[] completions;
public TabCompleteEvent(String str) {
this.prefix = str;
this.completions = null;
}
}
@@ -0,0 +1,40 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import java.util.function.BiFunction;
public final class TickEvent {
private static int overallTickCount;
private final EventState state;
private final TickEvent.Type type;
private final int count;
public TickEvent.Type getType() {
return this.type;
}
public EventState getState() {
return this.state;
}
public TickEvent(EventState event, TickEvent.Type type2, int n) {
this.state = event;
this.type = type2;
this.count = n;
}
public int getCount() {
return this.count;
}
public static synchronized BiFunction createNextProvider() {
int n = overallTickCount++;
return (BiFunction<EventState, TickEvent.Type, TickEvent>)(event, type2) -> new TickEvent(event, type2, n);
}
public enum Type {
IN,
OUT;
}
}
@@ -0,0 +1,22 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.multiplayer.WorldClient;
public final class WorldEvent {
private final WorldClient world;
private final EventState state;
public WorldEvent(WorldClient world2, EventState event) {
this.world = world2;
this.state = event;
}
public final WorldClient getWorld() {
return this.world;
}
public final EventState getState() {
return this.state;
}
}
@@ -0,0 +1,15 @@
package baritone.api.event.events.type;
public class Cancellable implements ICancellable {
private boolean cancelled;
@Override
public final void cancel() {
this.cancelled = true;
}
@Override
public final boolean isCancelled() {
return this.cancelled;
}
}
@@ -0,0 +1,6 @@
package baritone.api.event.events.type;
public enum EventState {
PRE,
POST;
}
@@ -0,0 +1,7 @@
package baritone.api.event.events.type;
public interface ICancellable {
boolean isCancelled();
void cancel();
}
@@ -0,0 +1,28 @@
package baritone.api.event.events.type;
public class Overrideable {
private Object value;
private boolean modified;
public Object getValue() {
return this.value;
}
public Overrideable(Object obj) {
this.value = obj;
}
@Override
public String toString() {
return String.format("Overrideable{modified=%b,value=%s}", this.modified, this.value.toString());
}
public void set(Object obj) {
this.value = obj;
this.modified = true;
}
public boolean isModified() {
return this.modified;
}
}
@@ -0,0 +1,76 @@
package baritone.api.event.listener;
import baritone.api.event.events.BlockInteractEvent;
import baritone.api.event.events.ChatEvent;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.PathEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.event.events.WorldEvent;
import baritone.api.event.events.BlockChangeEvent;
public interface AbstractGameEventListener extends IGameEventListener {
@Override
default void onRenderPass(RenderEvent renderEvent) {
}
@Override
default void onTick(TickEvent tickEvent) {
}
@Override
default void onPlayerDeath() {
}
@Override
default void onBlockInteract(BlockInteractEvent blockInteractEvent) {
}
@Override
default void onSendPacket(PacketEvent packetEvent) {
}
@Override
default void onPlayerSprintState(SprintStateEvent sprintStateEvent) {
}
@Override
default void onBlockChange(BlockChangeEvent blockChangeEvent) {
}
@Override
default void onChunkEvent(ChunkEvent chunkEvent) {
}
@Override
default void onReceivePacket(PacketEvent packetEvent) {
}
@Override
default void onPathEvent(PathEvent pathEvent) {
}
@Override
default void onSendChatMessage(ChatEvent chatEvent) {
}
@Override
default void onPlayerUpdate(PlayerUpdateEvent playerUpdateEvent) {
}
@Override
default void onWorldEvent(WorldEvent worldEvent) {
}
@Override
default void onPreTabComplete(TabCompleteEvent tabCompleteEvent) {
}
@Override
default void onPostTick(TickEvent tickEvent) {
}
}
@@ -0,0 +1,5 @@
package baritone.api.event.listener;
public interface IEventBus extends IGameEventListener {
void registerEventListener(IGameEventListener listener);
}
@@ -0,0 +1,46 @@
package baritone.api.event.listener;
import baritone.api.event.events.BlockInteractEvent;
import baritone.api.event.events.ChatEvent;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.PathEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.event.events.WorldEvent;
import baritone.api.event.events.BlockChangeEvent;
public interface IGameEventListener {
void onBlockInteract(BlockInteractEvent blockInteractEvent);
void onReceivePacket(PacketEvent packetEvent);
void onTick(TickEvent tickEvent);
void onPreTabComplete(TabCompleteEvent tabCompleteEvent);
void onPlayerUpdate(PlayerUpdateEvent playerUpdateEvent);
void onBlockChange(BlockChangeEvent blockChangeEvent);
void onSendPacket(PacketEvent packetEvent);
void onPlayerDeath();
void onChunkEvent(ChunkEvent chunkEvent);
void onWorldEvent(WorldEvent worldEvent);
void onRenderPass(RenderEvent renderEvent);
void onPathEvent(PathEvent pathEvent);
void onPostTick(TickEvent tickEvent);
void onPlayerSprintState(SprintStateEvent sprintStateEvent);
void onSendChatMessage(ChatEvent chatEvent);
}
@@ -0,0 +1,89 @@
package baritone.api.pathing.calc;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.movement.IMovement;
import baritone.api.utils.BetterBlockPos;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public interface IPath {
default int length() {
return this.positions().size();
}
List positions();
int getNumNodesConsidered();
default IPath postProcess() {
throw new UnsupportedOperationException();
}
default IPath staticCutoff(Goal goal) {
throw new UnsupportedOperationException();
}
default double ticksRemainingFrom(int n) {
double d = 0.0;
List list = this.movements();
for (int i = n; i < list.size(); i++) {
d += ((IMovement)list.get(i)).getCost();
}
return d;
}
default BetterBlockPos getDest() {
List list = this.positions();
return (BetterBlockPos)list.get(list.size() - 1);
}
List movements();
default void sanityCheck() {
List list = this.positions();
List list2 = this.movements();
if (!this.getSrc().equals(list.get(0))) {
throw new IllegalStateException("Start node does not equal first path element");
} else if (!this.getDest().equals(list.get(list.size() - 1))) {
throw new IllegalStateException("End node does not equal last path element");
} else if (list.size() != list2.size() + 1) {
throw new IllegalStateException("Size of path array is unexpected");
} else {
HashSet set = new HashSet();
for (int i = 0; i < list.size() - 1; i++) {
BetterBlockPos betterBlockPos = (BetterBlockPos)list.get(i);
BetterBlockPos betterBlockPos2 = (BetterBlockPos)list.get(i + 1);
IMovement movement = (IMovement)list2.get(i);
if (!betterBlockPos.equals(movement.getSrc())) {
throw new IllegalStateException("Path source is not equal to the movement source");
}
if (!betterBlockPos2.equals(movement.getDest())) {
throw new IllegalStateException("Path destination is not equal to the movement destination");
}
if (set.contains(betterBlockPos)) {
throw new IllegalStateException("Path doubles back on itself, making a loop");
}
set.add(betterBlockPos);
}
}
}
Goal getGoal();
default IPath cutoffAtLoadedChunks(Object obj) {
throw new UnsupportedOperationException();
}
default BetterBlockPos getSrc() {
return (BetterBlockPos)this.positions().get(0);
}
}
@@ -0,0 +1,17 @@
package baritone.api.pathing.calc;
import baritone.api.pathing.goals.Goal;
import baritone.api.utils.PathCalculationResult;
import java.util.Optional;
public interface IPathFinder {
PathCalculationResult calculate(long l, long l2);
Optional pathToMostRecentNodeConsidered();
Optional bestPathSoFar();
boolean isFinished();
Goal getGoal();
}
@@ -0,0 +1,12 @@
package baritone.api.pathing.calc;
import baritone.api.process.IBaritoneProcess;
import java.util.Optional;
public interface IPathingControlManager {
void registerProcess(IBaritoneProcess baritoneProcess);
Optional mostRecentInControl();
Optional mostRecentCommand();
}
@@ -0,0 +1,21 @@
package baritone.api.pathing.goals;
import net.minecraft.util.BlockPos;
public interface Goal {
default double heuristic(BlockPos pos) {
return this.heuristic(pos.getX(), pos.getY(), pos.getZ());
}
default boolean isInGoal(BlockPos pos) {
return this.isInGoal(pos.getX(), pos.getY(), pos.getZ());
}
default double heuristic() {
return 0.0;
}
double heuristic(int n, int n2, int n3);
boolean isInGoal(int n, int n2, int n3);
}
@@ -0,0 +1,35 @@
package baritone.api.pathing.goals;
import baritone.api.BaritoneAPI;
public class GoalAxis implements Goal {
private static final double SQRT_2_OVER_2 = Math.sqrt(2.0) / 2.0;
@Override
public int hashCode() {
return 201385781;
}
@Override
public double heuristic(int n, int n2, int n3) {
int n4 = Math.abs(n);
int n5 = Math.abs(n3);
int n6 = Math.min(n4, n5);
return Math.min((double)n4, Math.min((double)n5, (double)(Math.max(n4, n5) - n6) * SQRT_2_OVER_2)) * (Double)BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate((Integer)BaritoneAPI.getSettings().axisHeight.value, n2);
}
@Override
public boolean isInGoal(int n, int n2, int n3) {
return n2 == (Integer)BaritoneAPI.getSettings().axisHeight.value && (n == 0 || n3 == 0 || Math.abs(n) == Math.abs(n3));
}
@Override
public boolean equals(Object obj) {
return obj.getClass() == GoalAxis.class;
}
@Override
public String toString() {
return "GoalAxis";
}
}
@@ -0,0 +1,67 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.BlockPos;
public class GoalBlock implements Goal, IGoalRenderPos {
public final int x;
public final int y;
public final int z;
public static double calculate(double d, int n, double d2) {
double d3 = 0.0;
d3 += GoalYLevel.calculate(0, n);
return d3 + GoalXZ.calculate(d, d2);
}
@Override
public BlockPos getGoalPos() {
return new BlockPos(this.x, this.y, this.z);
}
@Override
public int hashCode() {
return (int)BetterBlockPos.longHash(this.x, this.y, this.z) * 905165533;
}
@Override
public boolean isInGoal(int n, int n2, int n3) {
return n == this.x && n2 == this.y && n3 == this.z;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj != null && this.getClass() == obj.getClass()) {
GoalBlock goalBlock = (GoalBlock)obj;
return this.x == goalBlock.x && this.y == goalBlock.y && this.z == goalBlock.z;
} else {
return false;
}
}
@Override
public double heuristic(int n, int n2, int n3) {
return calculate((double)(n - this.x), n2 - this.y, (double)(n3 - this.z));
}
public GoalBlock(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ());
}
public GoalBlock(int n, int n2, int n3) {
this.x = n;
this.y = n2;
this.z = n3;
}
@Override
public String toString() {
return String.format(
"GoalBlock{x=%s,y=%s,z=%s}", SettingsUtil.maybeCensor(this.x), SettingsUtil.maybeCensor(this.y), SettingsUtil.maybeCensor(this.z)
);
}
}
@@ -0,0 +1,70 @@
package baritone.api.pathing.goals;
import java.util.Arrays;
public class GoalComposite implements Goal {
private final Goal[] goals;
public Goal[] getGoals() {
return this.goals;
}
@Override
public String toString() {
return "GoalComposite" + Arrays.toString((Object[])this.goals);
}
@Override
public int hashCode() {
return Arrays.hashCode((Object[])this.goals);
}
public GoalComposite(Goal[] goals2) {
this.goals = goals2;
}
@Override
public boolean isInGoal(int n, int n2, int n3) {
for (Goal goal : this.goals) {
if (goal.isInGoal(n, n2, n3)) {
return true;
}
}
return false;
}
@Override
public double heuristic(int n, int n2, int n3) {
double maxvalue = Double.MAX_VALUE;
for (Goal goal : this.goals) {
maxvalue = Math.min(maxvalue, goal.heuristic(n, n2, n3));
}
return maxvalue;
}
@Override
public double heuristic() {
double maxvalue = Double.MAX_VALUE;
for (Goal goal : this.goals) {
maxvalue = Math.min(maxvalue, goal.heuristic());
}
return maxvalue;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj != null && this.getClass() == obj.getClass()) {
GoalComposite goalComposite = (GoalComposite)obj;
return Arrays.equals((Object[])this.goals, (Object[])goalComposite.goals);
} else {
return false;
}
}
}
@@ -0,0 +1,63 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.BlockPos;
public class GoalGetToBlock implements Goal, IGoalRenderPos {
public final int x;
public final int y;
public final int z;
@Override
public double heuristic(int n, int n2, int n3) {
int n4 = n - this.x;
int n5 = n2 - this.y;
int n6 = n3 - this.z;
return GoalBlock.calculate((double)n4, n5 < 0 ? n5 + 1 : n5, (double)n6);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj != null && this.getClass() == obj.getClass()) {
GoalGetToBlock goalGetToBlock = (GoalGetToBlock)obj;
return this.x == goalGetToBlock.x && this.y == goalGetToBlock.y && this.z == goalGetToBlock.z;
} else {
return false;
}
}
@Override
public String toString() {
return String.format(
"GoalGetToBlock{x=%s,y=%s,z=%s}", SettingsUtil.maybeCensor(this.x), SettingsUtil.maybeCensor(this.y), SettingsUtil.maybeCensor(this.z)
);
}
@Override
public BlockPos getGoalPos() {
return new BlockPos(this.x, this.y, this.z);
}
@Override
public int hashCode() {
return (int)BetterBlockPos.longHash(this.x, this.y, this.z) * -49639096;
}
@Override
public boolean isInGoal(int n, int n2, int n3) {
int n4 = n - this.x;
int n5 = n2 - this.y;
int n6 = n3 - this.z;
return Math.abs(n4) + Math.abs(n5 < 0 ? n5 + 1 : n5) + Math.abs(n6) <= 1;
}
public GoalGetToBlock(BlockPos pos) {
this.x = pos.getX();
this.y = pos.getY();
this.z = pos.getZ();
}
}
@@ -0,0 +1,48 @@
package baritone.api.pathing.goals;
import java.util.Objects;
public class GoalInverted implements Goal {
public final Goal origin;
@Override
public boolean isInGoal(int n, int n2, int n3) {
return false;
}
public GoalInverted(Goal goal) {
this.origin = goal;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj != null && this.getClass() == obj.getClass()) {
GoalInverted goalInverted = (GoalInverted)obj;
return Objects.equals(this.origin, goalInverted.origin);
} else {
return false;
}
}
@Override
public double heuristic() {
return Double.NEGATIVE_INFINITY;
}
@Override
public String toString() {
return String.format("GoalInverted{%s}", this.origin.toString());
}
@Override
public double heuristic(int n, int n2, int n3) {
return -this.origin.heuristic(n, n2, n3);
}
@Override
public int hashCode() {
return this.origin.hashCode() * 495796690;
}
}
Loaded 100 of 9721 files, more files were not shown because too many files have changed in this diff. Show more