fix various toxic clouds

This commit is contained in:
Leijurv 2019-04-17 18:10:47 -07:00
parent fe51220e3c
commit c013d1e0d9
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
36 changed files with 262 additions and 145 deletions

View File

@ -71,6 +71,18 @@ public interface IBaritone {
*/ */
IBuilderProcess getBuilderProcess(); IBuilderProcess getBuilderProcess();
/**
* @return The {@link IExploreProcess} instance
* @see IExploreProcess
*/
IExploreProcess getExploreProcess();
/**
* @return The {@link IFarmProcess} instance
* @see IFarmProcess
*/
IFarmProcess getFarmProcess();
/** /**
* @return The {@link ICustomGoalProcess} instance * @return The {@link ICustomGoalProcess} instance
* @see ICustomGoalProcess * @see ICustomGoalProcess
@ -115,4 +127,6 @@ public interface IBaritone {
* @see IEventBus * @see IEventBus
*/ */
IEventBus getGameEventHandler(); IEventBus getGameEventHandler();
void openClick();
} }

View File

@ -80,6 +80,13 @@ public interface IPathingBehavior extends IBehavior {
*/ */
boolean cancelEverything(); boolean cancelEverything();
/**
* PLEASE never call this
* <p>
* If cancelEverything was like "kill" this is "sudo kill -9". Or shutting off your computer.
*/
void forceCancel();
/** /**
* Returns the current path, from the current path executor, if there is one. * Returns the current path, from the current path executor, if there is one.
* *

View File

@ -81,4 +81,6 @@ public interface ICachedWorld {
* in a new thread by default. * in a new thread by default.
*/ */
void save(); void save();
} }

View File

@ -15,9 +15,8 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.cache; package baritone.api.cache;
import baritone.api.cache.IWaypoint;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.Date; import java.util.Date;
@ -47,7 +46,7 @@ public class Waypoint implements IWaypoint {
* @param location The waypoint location * @param location The waypoint location
* @param creationTimestamp When the waypoint was created * @param creationTimestamp When the waypoint was created
*/ */
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) { public Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
this.name = name; this.name = name;
this.tag = tag; this.tag = tag;
this.location = location; this.location = location;

View File

@ -18,6 +18,8 @@
package baritone.api.process; package baritone.api.process;
import baritone.api.utils.ISchematic; import baritone.api.utils.ISchematic;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
import java.io.File; import java.io.File;
@ -46,4 +48,15 @@ public interface IBuilderProcess extends IBaritoneProcess {
* @return Whether or not the schematic was able to load from file * @return Whether or not the schematic was able to load from file
*/ */
boolean build(String name, File schematic, Vec3i origin); boolean build(String name, File schematic, Vec3i origin);
default boolean build(String schematicFile, BlockPos origin) {
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
return build(schematicFile, file, origin);
}
void pause();
void resume();
void clearArea(BlockPos corner1, BlockPos corner2);
} }

View File

@ -0,0 +1,22 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.process;
public interface IExploreProcess extends IBaritoneProcess {
void explore(int centerX, int centerZ);
}

View File

@ -0,0 +1,22 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.process;
public interface IFarmProcess extends IBaritoneProcess {
void farm();
}

View File

@ -25,4 +25,6 @@ import net.minecraft.block.Block;
public interface IGetToBlockProcess extends IBaritoneProcess { public interface IGetToBlockProcess extends IBaritoneProcess {
void getToBlock(Block block); void getToBlock(Block block);
boolean blacklistClosest();
} }

View File

@ -0,0 +1,63 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class BlockUtils {
private static transient Map<String, Block> resourceCache = new HashMap<>();
public static String blockToString(Block block) {
ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
String name = loc.getPath(); // normally, only write the part after the minecraft:
if (!loc.getNamespace().equals("minecraft")) {
// Baritone is running on top of forge with mods installed, perhaps?
name = loc.toString(); // include the namespace with the colon
}
return name;
}
public static Block stringToBlockRequired(String name) {
Block block = stringToBlockNullable(name);
Objects.requireNonNull(block);
return block;
}
public static Block stringToBlockNullable(String name) {
// do NOT just replace this with a computeWithAbsent, it isn't thread safe
Block block = resourceCache.get(name); // map is never mutated in place so this is safe
if (block != null) {
return block;
}
if (resourceCache.containsKey(name)) {
return null; // cached as null
}
block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block);
resourceCache = copy;
return block;
}
private BlockUtils() {}
}

View File

@ -15,28 +15,21 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.utils; package baritone.api.utils;
import baritone.Baritone; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IRememberedInventory; import baritone.api.cache.IRememberedInventory;
import baritone.api.cache.IWaypoint; import baritone.api.cache.IWaypoint;
import baritone.api.cache.Waypoint;
import baritone.api.event.events.ChatEvent; import baritone.api.event.events.ChatEvent;
import baritone.api.event.listener.AbstractGameEventListener;
import baritone.api.pathing.goals.*; import baritone.api.pathing.goals.*;
import baritone.api.pathing.movement.ActionCosts;
import baritone.api.process.IBaritoneProcess; import baritone.api.process.IBaritoneProcess;
import baritone.api.utils.BetterBlockPos; import baritone.api.process.ICustomGoalProcess;
import baritone.api.utils.SettingsUtil; import baritone.api.process.IGetToBlockProcess;
import baritone.behavior.Behavior;
import baritone.behavior.PathingBehavior;
import baritone.cache.ChunkPacker;
import baritone.cache.Waypoint;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.Moves;
import baritone.process.CustomGoalProcess;
import baritone.process.GetToBlockProcess;
import baritone.utils.pathing.SegmentedCalculator;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.client.multiplayer.ChunkProviderClient;
@ -47,10 +40,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ExampleBaritoneControl extends Behavior implements Helper { public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
private static final String HELP_MSG = private static final String HELP_MSG =
"baritone - Output settings into chat\n" + "baritone - Output settings into chat\n" +
@ -84,21 +75,26 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
private static final String COMMAND_PREFIX = "#"; private static final String COMMAND_PREFIX = "#";
public ExampleBaritoneControl(Baritone baritone) { public final IBaritone baritone;
super(baritone); public final IPlayerContext ctx;
public ExampleBaritoneControl(IBaritone baritone) {
this.baritone = baritone;
this.ctx = baritone.getPlayerContext();
baritone.getGameEventHandler().registerEventListener(this);
} }
@Override @Override
public void onSendChatMessage(ChatEvent event) { public void onSendChatMessage(ChatEvent event) {
String msg = event.getMessage(); String msg = event.getMessage();
if (Baritone.settings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) { if (BaritoneAPI.getSettings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) {
if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) {
logDirect("Invalid command"); logDirect("Invalid command");
} }
event.cancel(); // always cancel if using prefixControl event.cancel(); // always cancel if using prefixControl
return; return;
} }
if (!Baritone.settings().chatControl.value && !Baritone.settings().removePrefix.value) { if (!BaritoneAPI.getSettings().chatControl.value && !BaritoneAPI.getSettings().removePrefix.value) {
return; return;
} }
if (runCommand(msg)) { if (runCommand(msg)) {
@ -108,20 +104,20 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =) public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =)
String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL
PathingBehavior pathingBehavior = baritone.getPathingBehavior(); IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
CustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
List<Settings.Setting<Boolean>> toggleable = Baritone.settings().getAllValuesByType(Boolean.class); List<Settings.Setting<Boolean>> toggleable = BaritoneAPI.getSettings().getAllValuesByType(Boolean.class);
for (Settings.Setting<Boolean> setting : toggleable) { for (Settings.Setting<Boolean> setting : toggleable) {
if (msg.equalsIgnoreCase(setting.getName())) { if (msg.equalsIgnoreCase(setting.getName())) {
setting.value ^= true; setting.value ^= true;
logDirect("Toggled " + setting.getName() + " to " + setting.value); logDirect("Toggled " + setting.getName() + " to " + setting.value);
SettingsUtil.save(Baritone.settings()); SettingsUtil.save(BaritoneAPI.getSettings());
return true; return true;
} }
} }
if (msg.equals("baritone") || msg.equals("modifiedsettings") || msg.startsWith("settings m") || msg.equals("modified")) { if (msg.equals("baritone") || msg.equals("modifiedsettings") || msg.startsWith("settings m") || msg.equals("modified")) {
logDirect("All settings that have been modified from their default values:"); logDirect("All settings that have been modified from their default values:");
for (Settings.Setting<?> setting : SettingsUtil.modifiedSettings(Baritone.settings())) { for (Settings.Setting<?> setting : SettingsUtil.modifiedSettings(BaritoneAPI.getSettings())) {
logDirect(setting.toString()); logDirect(setting.toString());
} }
return true; return true;
@ -131,15 +127,15 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
try { try {
int page = Integer.parseInt(rest.trim()); int page = Integer.parseInt(rest.trim());
int min = page * 10; int min = page * 10;
int max = Math.min(Baritone.settings().allSettings.size(), (page + 1) * 10); int max = Math.min(BaritoneAPI.getSettings().allSettings.size(), (page + 1) * 10);
logDirect("Settings " + min + " to " + (max - 1) + ":"); logDirect("Settings " + min + " to " + (max - 1) + ":");
for (int i = min; i < max; i++) { for (int i = min; i < max; i++) {
logDirect(Baritone.settings().allSettings.get(i).toString()); logDirect(BaritoneAPI.getSettings().allSettings.get(i).toString());
} }
} catch (Exception ex) { // NumberFormatException | ArrayIndexOutOfBoundsException and probably some others I'm forgetting lol } catch (Exception ex) { // NumberFormatException | ArrayIndexOutOfBoundsException and probably some others I'm forgetting lol
ex.printStackTrace(); ex.printStackTrace();
logDirect("All settings:"); logDirect("All settings:");
for (Settings.Setting<?> setting : Baritone.settings().allSettings) { for (Settings.Setting<?> setting : BaritoneAPI.getSettings().allSettings) {
logDirect(setting.toString()); logDirect(setting.toString());
} }
logDirect("To get one page of ten settings at a time, do settings <num>"); logDirect("To get one page of ten settings at a time, do settings <num>");
@ -155,26 +151,26 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
if (msg.contains(" ")) { if (msg.contains(" ")) {
String settingName = msg.substring(0, msg.indexOf(' ')); String settingName = msg.substring(0, msg.indexOf(' '));
String settingValue = msg.substring(msg.indexOf(' ') + 1); String settingValue = msg.substring(msg.indexOf(' ') + 1);
Settings.Setting setting = Baritone.settings().byLowerName.get(settingName); Settings.Setting setting = BaritoneAPI.getSettings().byLowerName.get(settingName);
if (setting != null) { if (setting != null) {
if (settingValue.equals("reset")) { if (settingValue.equals("reset")) {
logDirect("Resetting setting " + settingName + " to default value."); logDirect("Resetting setting " + settingName + " to default value.");
setting.reset(); setting.reset();
} else { } else {
try { try {
SettingsUtil.parseAndApply(Baritone.settings(), settingName, settingValue); SettingsUtil.parseAndApply(BaritoneAPI.getSettings(), settingName, settingValue);
} catch (Exception ex) { } catch (Exception ex) {
logDirect("Unable to parse setting"); logDirect("Unable to parse setting");
return true; return true;
} }
} }
SettingsUtil.save(Baritone.settings()); SettingsUtil.save(BaritoneAPI.getSettings());
logDirect(setting.toString()); logDirect(setting.toString());
return true; return true;
} }
} }
if (Baritone.settings().byLowerName.containsKey(msg)) { if (BaritoneAPI.getSettings().byLowerName.containsKey(msg)) {
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg); Settings.Setting<?> setting = BaritoneAPI.getSettings().byLowerName.get(msg);
logDirect(setting.toString()); logDirect(setting.toString());
return true; return true;
} }
@ -210,7 +206,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
} }
return true; return true;
} }
if (msg.equals("fullpath")) { /*if (msg.equals("fullpath")) {
if (pathingBehavior.getGoal() == null) { if (pathingBehavior.getGoal() == null) {
logDirect("No goal."); logDirect("No goal.");
} else { } else {
@ -226,7 +222,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
}); });
} }
return true; return true;
} }*/
if (msg.equals("proc")) { if (msg.equals("proc")) {
Optional<IBaritoneProcess> proc = baritone.getPathingControlManager().mostRecentInControl(); Optional<IBaritoneProcess> proc = baritone.getPathingControlManager().mostRecentInControl();
if (!proc.isPresent()) { if (!proc.isPresent()) {
@ -284,7 +280,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("come")) { if (msg.equals("come")) {
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(mc.getRenderViewEntity()))); customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
logDirect("Coming"); logDirect("Coming");
return true; return true;
} }
@ -365,10 +361,10 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("reset")) { if (msg.equals("reset")) {
for (Settings.Setting setting : Baritone.settings().allSettings) { for (Settings.Setting setting : BaritoneAPI.getSettings().allSettings) {
setting.reset(); setting.reset();
} }
SettingsUtil.save(Baritone.settings()); SettingsUtil.save(BaritoneAPI.getSettings());
logDirect("Baritone settings reset"); logDirect("Baritone settings reset");
return true; return true;
} }
@ -384,11 +380,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("farm")) { if (msg.equals("farm")) {
baritone.getFarmProcess().doit(); baritone.getFarmProcess().farm();
logDirect("farming"); logDirect("farming");
return true; return true;
} }
if (msg.equals("echest")) { // this literally doesn't work, memory is disabled lol
/*if (msg.equals("echest")) {
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest(); Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
if (contents.isPresent()) { if (contents.isPresent()) {
logDirect("echest contents:"); logDirect("echest contents:");
@ -397,18 +394,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
logDirect("echest contents unknown"); logDirect("echest contents unknown");
} }
return true; return true;
} }*/
if (msg.equals("chests")) { if (msg.equals("chests")) {
System.out.println(baritone.getWorldProvider());
System.out.println(baritone.getWorldProvider().getCurrentWorld());
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory());
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories());
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet());
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet());
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) { for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
logDirect(entry.getKey() + ""); logDirect(entry.getKey() + "");
log(entry.getValue().getContents()); log(entry.getValue().getContents());
@ -468,7 +455,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("blacklist")) { if (msg.equals("blacklist")) {
GetToBlockProcess proc = baritone.getGetToBlockProcess(); IGetToBlockProcess proc = baritone.getGetToBlockProcess();
if (!proc.isActive()) { if (!proc.isActive()) {
logDirect("GetToBlockProcess is not currently active"); logDirect("GetToBlockProcess is not currently active");
return true; return true;
@ -485,9 +472,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
logDirect("Have " + locs.size() + " locations"); logDirect("Have " + locs.size() + " locations");
for (BlockPos pos : locs) { for (BlockPos pos : locs) {
Block actually = BlockStateInterface.get(ctx, pos).getBlock(); Block actually = ctx.world().getBlockState(pos).getBlock();
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) { if (!BlockUtils.blockToString(actually).equalsIgnoreCase(blockType)) {
System.out.println("Was looking for " + blockType + " but actually found " + actually + " " + ChunkPacker.blockToString(actually)); logDebug("Was looking for " + blockType + " but actually found " + actually + " " + BlockUtils.blockToString(actually));
} }
} }
return true; return true;
@ -496,13 +483,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
String[] blockTypes = msg.substring(4).trim().split(" "); String[] blockTypes = msg.substring(4).trim().split(" ");
try { try {
int quantity = Integer.parseInt(blockTypes[1]); int quantity = Integer.parseInt(blockTypes[1]);
Block block = ChunkPacker.stringToBlockRequired(blockTypes[0]); Block block = BlockUtils.stringToBlockRequired(blockTypes[0]);
baritone.getMineProcess().mine(quantity, block); baritone.getMineProcess().mine(quantity, block);
logDirect("Will mine " + quantity + " " + blockTypes[0]); logDirect("Will mine " + quantity + " " + blockTypes[0]);
return true; return true;
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {} } catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
for (String s : blockTypes) { for (String s : blockTypes) {
if (ChunkPacker.stringToBlockNullable(s) == null) { if (BlockUtils.stringToBlockNullable(s) == null) {
logDirect(s + " isn't a valid block name"); logDirect(s + " isn't a valid block name");
return true; return true;
} }
@ -513,12 +500,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("click")) { if (msg.equals("click")) {
new Thread(() -> { baritone.openClick();
try {
Thread.sleep(100);
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiClick()));
} catch (Exception ignored) {}
}).start();
logDirect("aight dude"); logDirect("aight dude");
return true; return true;
} }
@ -538,9 +520,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
// for example, "show deaths" // for example, "show deaths"
waypointType = waypointType.substring(0, waypointType.length() - 1); waypointType = waypointType.substring(0, waypointType.length() - 1);
} }
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
if (tag == null) { if (tag == null) {
logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); logDirect("Not a valid tag. Tags are: " + Arrays.asList(IWaypoint.Tag.values()).toString().toLowerCase());
return true; return true;
} }
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag); Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag);
@ -571,21 +553,21 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
} }
name = parts[0]; name = parts[0];
} }
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, pos)); baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, IWaypoint.Tag.USER, pos));
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints."); logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
return true; return true;
} }
if (msg.startsWith("goto")) { if (msg.startsWith("goto")) {
String waypointType = msg.substring(4).trim(); String waypointType = msg.substring(4).trim();
if (waypointType.endsWith("s") && Waypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) { if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
// for example, "show deaths" // for example, "show deaths"
waypointType = waypointType.substring(0, waypointType.length() - 1); waypointType = waypointType.substring(0, waypointType.length() - 1);
} }
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
IWaypoint waypoint; IWaypoint waypoint;
if (tag == null) { if (tag == null) {
String mining = waypointType; String mining = waypointType;
Block block = ChunkPacker.stringToBlockNullable(mining); Block block = BlockUtils.stringToBlockNullable(mining);
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); //logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
if (block == null) { if (block == null) {
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null); waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
@ -608,12 +590,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
} }
Goal goal = waypoint.getTag() == Waypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation()); Goal goal = waypoint.getTag() == IWaypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation());
customGoalProcess.setGoalAndPath(goal); customGoalProcess.setGoalAndPath(goal);
return true; return true;
} }
if (msg.equals("spawn") || msg.equals("bed")) { if (msg.equals("spawn") || msg.equals("bed")) {
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.BED); IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.BED);
if (waypoint == null) { if (waypoint == null) {
BlockPos spawnPoint = ctx.player().getBedLocation(); BlockPos spawnPoint = ctx.player().getBedLocation();
// for some reason the default spawnpoint is underground sometimes // for some reason the default spawnpoint is underground sometimes
@ -628,12 +610,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
if (msg.equals("sethome")) { if (msg.equals("sethome")) {
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", Waypoint.Tag.HOME, ctx.playerFeet())); baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", IWaypoint.Tag.HOME, ctx.playerFeet()));
logDirect("Saved. Say home to set goal."); logDirect("Saved. Say home to set goal.");
return true; return true;
} }
if (msg.equals("home")) { if (msg.equals("home")) {
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.HOME); IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.HOME);
if (waypoint == null) { if (waypoint == null) {
logDirect("home not saved"); logDirect("home not saved");
} else { } else {
@ -643,7 +625,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
} }
return true; return true;
} }
if (msg.equals("costs")) { // this is completely impossible from api
/*if (msg.equals("costs")) {
List<Movement> moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new)); List<Movement> moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new));
while (moves.contains(null)) { while (moves.contains(null)) {
moves.remove(null); moves.remove(null);
@ -659,7 +642,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost); logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
} }
return true; return true;
} }*/
if (msg.equals("damn")) { if (msg.equals("damn")) {
logDirect("daniel"); logDirect("daniel");
} }

View File

@ -15,9 +15,9 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.utils; package baritone.api.utils;
import baritone.Baritone; import baritone.api.BaritoneAPI;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
@ -50,7 +50,7 @@ public interface Helper {
* @param message The message to display in chat * @param message The message to display in chat
*/ */
default void logDebug(String message) { default void logDebug(String message) {
if (!Baritone.settings().chatDebug.value) { if (!BaritoneAPI.getSettings().chatDebug.value) {
//System.out.println("Suppressed debug message:"); //System.out.println("Suppressed debug message:");
//System.out.println(message); //System.out.println(message);
return; return;
@ -67,6 +67,6 @@ public interface Helper {
ITextComponent component = MESSAGE_PREFIX.createCopy(); ITextComponent component = MESSAGE_PREFIX.createCopy();
component.getStyle().setColor(TextFormatting.GRAY); component.getStyle().setColor(TextFormatting.GRAY);
component.appendSibling(new TextComponentString(" " + message)); component.appendSibling(new TextComponentString(" " + message));
Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.value.accept(component)); Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
} }
} }

View File

@ -21,6 +21,8 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.event.listener.IEventBus; import baritone.api.event.listener.IEventBus;
import baritone.api.utils.ExampleBaritoneControl;
import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.behavior.*; import baritone.behavior.*;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
@ -33,8 +35,6 @@ import net.minecraft.client.Minecraft;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue; import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
@ -67,7 +67,6 @@ public class Baritone implements IBaritone {
private GameEventHandler gameEventHandler; private GameEventHandler gameEventHandler;
private List<Behavior> behaviors;
private PathingBehavior pathingBehavior; private PathingBehavior pathingBehavior;
private LookBehavior lookBehavior; private LookBehavior lookBehavior;
private MemoryBehavior memoryBehavior; private MemoryBehavior memoryBehavior;
@ -102,7 +101,6 @@ public class Baritone implements IBaritone {
// Define this before behaviors try and get it, or else it will be null and the builds will fail! // Define this before behaviors try and get it, or else it will be null and the builds will fail!
this.playerContext = PrimaryPlayerContext.INSTANCE; this.playerContext = PrimaryPlayerContext.INSTANCE;
this.behaviors = new ArrayList<>();
{ {
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist // the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
pathingBehavior = new PathingBehavior(this); pathingBehavior = new PathingBehavior(this);
@ -138,12 +136,7 @@ public class Baritone implements IBaritone {
return this.pathingControlManager; return this.pathingControlManager;
} }
public List<Behavior> getBehaviors() {
return this.behaviors;
}
public void registerBehavior(Behavior behavior) { public void registerBehavior(Behavior behavior) {
this.behaviors.add(behavior);
this.gameEventHandler.registerEventListener(behavior); this.gameEventHandler.registerEventListener(behavior);
} }
@ -218,6 +211,16 @@ public class Baritone implements IBaritone {
return this.gameEventHandler; return this.gameEventHandler;
} }
@Override
public void openClick() {
new Thread(() -> {
try {
Thread.sleep(100);
Helper.mc.addScheduledTask(() -> Helper.mc.displayGuiScreen(new GuiClick()));
} catch (Exception ignored) {}
}).start();
}
public static Settings settings() { public static Settings settings() {
return BaritoneAPI.getSettings(); return BaritoneAPI.getSettings();
} }

View File

@ -24,7 +24,7 @@ import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.TickEvent; import baritone.api.event.events.TickEvent;
import baritone.api.event.events.type.EventState; import baritone.api.event.events.type.EventState;
import baritone.cache.ContainerMemory; import baritone.cache.ContainerMemory;
import baritone.cache.Waypoint; import baritone.api.cache.Waypoint;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockBed; import net.minecraft.block.BlockBed;

View File

@ -32,7 +32,7 @@ import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.PathExecutor; import baritone.pathing.path.PathExecutor;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import baritone.utils.PathRenderer; import baritone.utils.PathRenderer;
import baritone.utils.PathingCommandContext; import baritone.utils.PathingCommandContext;
import baritone.utils.pathing.Favoring; import baritone.utils.pathing.Favoring;
@ -350,7 +350,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
} }
} }
public void forceCancel() { // NOT exposed on public api @Override
public void forceCancel() { // exposed on public api because :sob:
cancelEverything(); cancelEverything();
secretInternalSegmentCancel(); secretInternalSegmentCancel();
synchronized (pathCalcLock) { synchronized (pathCalcLock) {
@ -358,11 +359,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
} }
} }
public void secretCursedFunctionDoNotCall(IPath path) { /*public void secretCursedFunctionDoNotCall(IPath path) {
synchronized (pathPlanLock) { synchronized (pathPlanLock) {
current = new PathExecutor(this, path); current = new PathExecutor(this, path);
} }
} }*/
public CalculationContext secretInternalGetCalculationContext() { public CalculationContext secretInternalGetCalculationContext() {
return context; return context;

View File

@ -17,6 +17,7 @@
package baritone.cache; package baritone.cache;
import baritone.api.utils.BlockUtils;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -177,7 +178,7 @@ public final class CachedChunk {
if (special != null) { if (special != null) {
String str = special.get(index); String str = special.get(index);
if (str != null) { if (str != null) {
return ChunkPacker.stringToBlockRequired(str).getDefaultState(); return BlockUtils.stringToBlockRequired(str).getDefaultState();
} }
} }

View File

@ -19,6 +19,7 @@ package baritone.cache;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.cache.ICachedRegion; import baritone.api.cache.ICachedRegion;
import baritone.api.utils.BlockUtils;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -149,7 +150,7 @@ public final class CachedRegion implements ICachedRegion {
for (int z = 0; z < 32; z++) { for (int z = 0; z < 32; z++) {
if (chunks[x][z] != null) { if (chunks[x][z] != null) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
out.writeUTF(ChunkPacker.blockToString(chunks[x][z].getOverview()[i].getBlock())); out.writeUTF(BlockUtils.blockToString(chunks[x][z].getOverview()[i].getBlock()));
} }
} }
} }
@ -240,7 +241,7 @@ public final class CachedRegion implements ICachedRegion {
for (int z = 0; z < 32; z++) { for (int z = 0; z < 32; z++) {
if (present[x][z]) { if (present[x][z]) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
overview[x][z][i] = ChunkPacker.stringToBlockRequired(in.readUTF()).getDefaultState(); overview[x][z][i] = BlockUtils.stringToBlockRequired(in.readUTF()).getDefaultState();
} }
} }
} }
@ -255,7 +256,7 @@ public final class CachedRegion implements ICachedRegion {
int numSpecialBlockTypes = in.readShort() & 0xffff; int numSpecialBlockTypes = in.readShort() & 0xffff;
for (int i = 0; i < numSpecialBlockTypes; i++) { for (int i = 0; i < numSpecialBlockTypes; i++) {
String blockName = in.readUTF(); String blockName = in.readUTF();
ChunkPacker.stringToBlockRequired(blockName); BlockUtils.stringToBlockRequired(blockName);
List<BlockPos> locs = new ArrayList<>(); List<BlockPos> locs = new ArrayList<>();
location[x][z].put(blockName, locs); location[x][z].put(blockName, locs);
int numLocations = in.readShort() & 0xffff; int numLocations = in.readShort() & 0xffff;

View File

@ -22,7 +22,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.cache.ICachedWorld; import baritone.api.cache.ICachedWorld;
import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldData;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View File

@ -17,12 +17,12 @@
package baritone.cache; package baritone.cache;
import baritone.api.utils.BlockUtils;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.BlockStateContainer; import net.minecraft.world.chunk.BlockStateContainer;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
@ -36,8 +36,6 @@ import java.util.*;
*/ */
public final class ChunkPacker { public final class ChunkPacker {
private static final Map<String, Block> resourceCache = new HashMap<>();
private ChunkPacker() {} private ChunkPacker() {}
public static CachedChunk pack(Chunk chunk) { public static CachedChunk pack(Chunk chunk) {
@ -75,7 +73,7 @@ public final class ChunkPacker {
bitSet.set(index + 1, bits[1]); bitSet.set(index + 1, bits[1]);
Block block = state.getBlock(); Block block = state.getBlock();
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
String name = blockToString(block); String name = BlockUtils.blockToString(block);
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z)); specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
} }
} }
@ -105,25 +103,6 @@ public final class ChunkPacker {
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis()); return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis());
} }
public static String blockToString(Block block) {
ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
String name = loc.getPath(); // normally, only write the part after the minecraft:
if (!loc.getNamespace().equals("minecraft")) {
// Baritone is running on top of forge with mods installed, perhaps?
name = loc.toString(); // include the namespace with the colon
}
return name;
}
public static Block stringToBlockRequired(String name) {
Block block = stringToBlockNullable(name);
Objects.requireNonNull(block);
return block;
}
public static Block stringToBlockNullable(String name) {
return resourceCache.computeIfAbsent(name, n -> Block.getBlockFromName(n.contains(":") ? n : "minecraft:" + n));
}
private static PathingBlockType getPathingBlockType(IBlockState state, Chunk chunk, int x, int y, int z) { private static PathingBlockType getPathingBlockType(IBlockState state, Chunk chunk, int x, int y, int z) {
Block block = state.getBlock(); Block block = state.getBlock();

View File

@ -19,6 +19,7 @@ package baritone.cache;
import baritone.api.cache.IWaypoint; import baritone.api.cache.IWaypoint;
import baritone.api.cache.IWaypointCollection; import baritone.api.cache.IWaypointCollection;
import baritone.api.cache.Waypoint;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.io.*; import java.io.*;

View File

@ -19,7 +19,7 @@ package baritone.cache;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.cache.IWorldProvider; import baritone.api.cache.IWorldProvider;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IAnvilChunkLoader;
import baritone.utils.accessor.IChunkProviderServer; import baritone.utils.accessor.IChunkProviderServer;
import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.integrated.IntegratedServer;

View File

@ -24,7 +24,7 @@ import baritone.api.event.listener.IEventBus;
import baritone.api.event.listener.IGameEventListener; import baritone.api.event.listener.IGameEventListener;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;

View File

@ -24,7 +24,7 @@ import baritone.api.pathing.goals.Goal;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.PathCalculationResult; import baritone.api.utils.PathCalculationResult;
import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.CalculationContext;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.Optional; import java.util.Optional;

View File

@ -25,7 +25,7 @@ import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement; import baritone.pathing.movement.Movement;
import baritone.pathing.movement.Moves; import baritone.pathing.movement.Moves;
import baritone.pathing.path.CutoffPath; import baritone.pathing.path.CutoffPath;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import baritone.utils.pathing.PathBase; import baritone.utils.pathing.PathBase;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -25,7 +25,7 @@ import baritone.api.utils.*;
import baritone.api.utils.input.Input; import baritone.api.utils.input.Input;
import baritone.pathing.movement.MovementState.MovementTarget; import baritone.pathing.movement.MovementState.MovementTarget;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import baritone.utils.ToolSet; import baritone.utils.ToolSet;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;

View File

@ -35,7 +35,7 @@ import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.movements.*; import baritone.pathing.movement.movements.*;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;

View File

@ -69,12 +69,6 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
super(baritone); super(baritone);
} }
public boolean build(String schematicFile, BlockPos origin) {
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
System.out.println(file + " " + file.exists());
return build(schematicFile, file, origin);
}
@Override @Override
public void build(String name, ISchematic schematic, Vec3i origin) { public void build(String name, ISchematic schematic, Vec3i origin) {
this.name = name; this.name = name;

View File

@ -22,6 +22,7 @@ import baritone.api.cache.ICachedWorld;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalComposite; import baritone.api.pathing.goals.GoalComposite;
import baritone.api.pathing.goals.GoalXZ; import baritone.api.pathing.goals.GoalXZ;
import baritone.api.process.IExploreProcess;
import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType; import baritone.api.process.PathingCommandType;
import baritone.cache.CachedWorld; import baritone.cache.CachedWorld;
@ -31,7 +32,7 @@ import net.minecraft.util.math.BlockPos;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ExploreProcess extends BaritoneProcessHelper { public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
private BlockPos explorationOrigin; private BlockPos explorationOrigin;
@ -44,6 +45,7 @@ public class ExploreProcess extends BaritoneProcessHelper {
return explorationOrigin != null; return explorationOrigin != null;
} }
@Override
public void explore(int centerX, int centerZ) { public void explore(int centerX, int centerZ) {
explorationOrigin = new BlockPos(centerX, 0, centerZ); explorationOrigin = new BlockPos(centerX, 0, centerZ);
} }

View File

@ -21,6 +21,7 @@ import baritone.Baritone;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalBlock;
import baritone.api.pathing.goals.GoalComposite; import baritone.api.pathing.goals.GoalComposite;
import baritone.api.process.IFarmProcess;
import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType; import baritone.api.process.PathingCommandType;
import baritone.api.utils.Rotation; import baritone.api.utils.Rotation;
@ -50,7 +51,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Predicate; import java.util.function.Predicate;
public class FarmProcess extends BaritoneProcessHelper { public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
private boolean active; private boolean active;
@ -90,7 +91,8 @@ public class FarmProcess extends BaritoneProcessHelper {
return active; return active;
} }
public void doit() { @Override
public void farm() {
active = true; active = true;
} }

View File

@ -22,6 +22,7 @@ import baritone.api.pathing.goals.*;
import baritone.api.process.IMineProcess; import baritone.api.process.IMineProcess;
import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType; import baritone.api.process.PathingCommandType;
import baritone.api.utils.BlockUtils;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.api.utils.RotationUtils; import baritone.api.utils.RotationUtils;
import baritone.cache.CachedChunk; import baritone.cache.CachedChunk;
@ -219,7 +220,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
for (Block m : mining) { for (Block m : mining) {
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that // maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(BlockUtils.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2));
} else { } else {
uninteresting.add(m); uninteresting.add(m);
} }
@ -303,7 +304,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
@Override @Override
public void mineByName(int quantity, String... blocks) { public void mineByName(int quantity, String... blocks) {
mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlockRequired).toArray(Block[]::new)); mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(BlockUtils::stringToBlockRequired).toArray(Block[]::new));
} }
@Override @Override

View File

@ -22,6 +22,7 @@ import baritone.api.event.events.TickEvent;
import baritone.api.event.listener.AbstractGameEventListener; import baritone.api.event.listener.AbstractGameEventListener;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMainMenu;

View File

@ -19,6 +19,7 @@ package baritone.utils;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.process.IBaritoneProcess; import baritone.api.process.IBaritoneProcess;
import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper { public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper {

View File

@ -17,6 +17,7 @@
package baritone.utils; package baritone.utils;
import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;

View File

@ -18,6 +18,7 @@
package baritone.utils; package baritone.utils;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;

View File

@ -23,6 +23,7 @@ import baritone.api.event.events.RenderEvent;
import baritone.api.pathing.calc.IPath; import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.goals.*; import baritone.api.pathing.goals.*;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.Helper;
import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.behavior.PathingBehavior; import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor; import baritone.pathing.path.PathExecutor;

View File

@ -22,7 +22,7 @@ import baritone.api.cache.IWorldData;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.api.utils.IPlayerController; import baritone.api.utils.IPlayerController;
import baritone.api.utils.RayTraceUtils; import baritone.api.utils.RayTraceUtils;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;

View File

@ -18,7 +18,7 @@
package baritone.utils.player; package baritone.utils.player;
import baritone.api.utils.IPlayerController; import baritone.api.utils.IPlayerController;
import baritone.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;