Skip to content

Commit

Permalink
Abstract away the Baritone tab, the settings are now provided by the …
Browse files Browse the repository at this point in the history
…current path manager
  • Loading branch information
MineGame159 committed Oct 21, 2023
1 parent 9ac7936 commit 6f7a2f2
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public static void init() {
add(new MacrosTab());
add(new ProfilesTab());

if (BaritoneUtils.IS_AVAILABLE) {
add(new BaritoneTab());
if (PathManagers.get().getSettings().get().sizeGroups() > 0) {
add(new PathManagerTab());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.gui.tabs.builtin;

import baritone.api.BaritoneAPI;
import baritone.api.utils.SettingsUtil;
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.tabs.Tab;
import meteordevelopment.meteorclient.gui.tabs.TabScreen;
import meteordevelopment.meteorclient.gui.tabs.WindowTabScreen;
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import meteordevelopment.meteorclient.pathing.PathManagers;
import net.minecraft.client.gui.screen.Screen;

public class PathManagerTab extends Tab {
public PathManagerTab() {
super(PathManagers.get().getName());
}

@Override
public TabScreen createScreen(GuiTheme theme) {
return new PathManagerScreen(theme, this);
}

@Override
public boolean isScreen(Screen screen) {
return screen instanceof PathManagerScreen;
}

private static class PathManagerScreen extends WindowTabScreen {
public PathManagerScreen(GuiTheme theme, Tab tab) {
super(theme, tab);

PathManagers.get().getSettings().get().onActivated();
}

@Override
public void initWidgets() {
WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget();
filter.setFocused(true);
filter.action = () -> {
clear();

add(filter);
add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX();
};

add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX();
}

@Override
protected void onClosed() {
SettingsUtil.save(BaritoneAPI.getSettings());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class BaritonePathManager implements IPathManager {
private final VarHandle rotationField;
private final Settings settings;
private final BaritoneSettings settings;

private GoalDirection directionGoal;
private boolean pathingPaused;
Expand All @@ -60,12 +60,17 @@ public BaritonePathManager() {
this.rotationField = rotationField;

// Create settings
settings = new Settings();
settings = new BaritoneSettings();

// Baritone pathing control
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new BaritoneProcess());
}

@Override
public String getName() {
return "Baritone";
}

@Override
public boolean isPathing() {
return BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing();
Expand Down Expand Up @@ -141,48 +146,6 @@ private void onTick(TickEvent.Pre event) {
directionGoal.tick();
}

private static class Settings implements ISettings {
@Override
public boolean getWalkOnWater() {
return BaritoneAPI.getSettings().assumeWalkOnWater.value;
}

@Override
public void setWalkOnWater(boolean value) {
BaritoneAPI.getSettings().assumeWalkOnWater.value = value;
}

@Override
public boolean getWalkOnLava() {
return BaritoneAPI.getSettings().assumeWalkOnLava.value;
}

@Override
public void setWalkOnLava(boolean value) {
BaritoneAPI.getSettings().assumeWalkOnLava.value = value;
}

@Override
public boolean getStep() {
return BaritoneAPI.getSettings().assumeStep.value;
}

@Override
public void setStep(boolean value) {
BaritoneAPI.getSettings().assumeStep.value = value;
}

@Override
public boolean getNoFall() {
return BaritoneAPI.getSettings().maxFallHeightNoWater.value > BaritoneAPI.getSettings().maxFallHeightNoWater.defaultValue;
}

@Override
public void setNoFall(boolean value) {
BaritoneAPI.getSettings().maxFallHeightNoWater.value = value ? 159159 : BaritoneAPI.getSettings().maxFallHeightNoWater.defaultValue;
}
}

private static class GoalDirection implements Goal {
private static final double SQRT_2 = Math.sqrt(2);

Expand Down
Loading

0 comments on commit 6f7a2f2

Please sign in to comment.