it builds

This commit is contained in:
Leijurv 2018-08-01 12:48:12 -04:00
parent f83adb7d81
commit 9201b99853
No known key found for this signature in database
GPG Key ID: 0936202430AE187C
7 changed files with 90 additions and 145 deletions

View File

@ -5,7 +5,6 @@
*/ */
package baritone; package baritone;
import baritone.movement.Combat;
import baritone.movement.MovementManager; import baritone.movement.MovementManager;
import baritone.pathfinding.Path; import baritone.pathfinding.Path;
import baritone.pathfinding.PathFinder; import baritone.pathfinding.PathFinder;
@ -42,7 +41,6 @@ public class Baritone {
public static BlockPos playerFeet = null; public static BlockPos playerFeet = null;
public static World world = null; public static World world = null;
public static boolean allowDiagonal = true; public static boolean allowDiagonal = true;
public static boolean farf5 = false; public static boolean farf5 = false;
public static boolean slowPath = false; public static boolean slowPath = false;
@ -151,7 +149,6 @@ public class Baritone {
hasThrowaway = ActionPlaceOrBreak.hasthrowaway(); hasThrowaway = ActionPlaceOrBreak.hasthrowaway();
ManagerTick.tickPath = true; ManagerTick.tickPath = true;
Manager.tick(LookManager.class); Manager.tick(LookManager.class);
BlockPos ts = whatAreYouLookingAt(); BlockPos ts = whatAreYouLookingAt();
if (ts != null) { if (ts != null) {
Memory.scanBlock(ts); Memory.scanBlock(ts);
@ -277,7 +274,6 @@ public class Baritone {
*/ */
public static void cancelPath() { public static void cancelPath() {
nextPath = null; nextPath = null;
Combat.target = null;
currentBuilder = null; currentBuilder = null;
clearPath(); clearPath();
} }
@ -397,18 +393,18 @@ public class Baritone {
if (pos == null) { if (pos == null) {
return; return;
} }
Block block = Baritone.get(pos).getBlock(); IBlockState state = Baritone.get(pos);
if (block.equals(Block.getBlockById(0))) { if (state.getBlock().equals(Block.getBlockById(0))) {
return; return;
} }
switchtotool(block); switchtotool(state);
} }
public static void switchtotool(Block b) { public static void switchtotool(IBlockState b) {
Baritone.switchtotool(b, new ToolSet()); Baritone.switchtotool(b, new ToolSet());
} }
public static void switchtotool(Block b, ToolSet ts) { public static void switchtotool(IBlockState b, ToolSet ts) {
Minecraft.getMinecraft().player.inventory.currentItem = ts.getBestSlot(b); Minecraft.getMinecraft().player.inventory.currentItem = ts.getBestSlot(b);
} }
@ -429,7 +425,6 @@ public class Baritone {
list.add("§5[§dBaritone§5]§f"); list.add("§5[§dBaritone§5]§f");
Class<LookManager> c = LookManager.class; Class<LookManager> c = LookManager.class;
list.add("§r[§" + (Manager.enabled(c) ? "a" : "c") + c.getSimpleName() + "§r]"); list.add("§r[§" + (Manager.enabled(c) ? "a" : "c") + c.getSimpleName() + "§r]");
list.add(""); list.add("");
list.add("Current goal: " + goal); list.add("Current goal: " + goal);
list.add(""); list.add("");

View File

@ -130,7 +130,7 @@ public abstract class ActionPlaceOrBreak extends Action {
return false; return false;
}*/ }*/
if (Baritone.whatAreYouLookingAt() != null) { if (Baritone.whatAreYouLookingAt() != null) {
Baritone.switchtotool(Baritone.get(Baritone.whatAreYouLookingAt()).getBlock()); Baritone.switchtotool(Baritone.get(Baritone.whatAreYouLookingAt()));
} }
MovementManager.isLeftClick = true;//hold down left click MovementManager.isLeftClick = true;//hold down left click
if (canWalkThrough(positionsToBreak[i])) { if (canWalkThrough(positionsToBreak[i])) {

View File

@ -9,24 +9,27 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
/** /**
* *
* @author galdara * @author galdara
*/ */
public class Schematic { public class Schematic {
private final HashMap<BlockPos, Block> schematicBlocks; private final HashMap<BlockPos, Block> schematicBlocks;
private final int width; private final int width;
private final int height; private final int height;
private final int length; private final int length;
public Schematic(HashMap<BlockPos, Block> blocks, int width, int height, int length) { public Schematic(HashMap<BlockPos, Block> blocks, int width, int height, int length) {
schematicBlocks = blocks; schematicBlocks = blocks;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.length = length; this.length = length;
} }
public Schematic(Block type, int desiredWidth) { public Schematic(Block type, int desiredWidth) {
if (type == null) { if (type == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -41,32 +44,7 @@ public class Schematic {
schematicBlocks.put(new BlockPos(desiredWidth / 2, i, 0), type); schematicBlocks.put(new BlockPos(desiredWidth / 2, i, 0), type);
} }
} }
public Schematic(Block type, int desiredWidth, boolean rightFacing, boolean dots) {
if (type == null) {
throw new IllegalArgumentException();
}
int size = (desiredWidth - 1) / 2;
width = size * 2 + 1;
height = 1;
length = width;
schematicBlocks = new HashMap();
for (int x = 0; x < width; x++) {
schematicBlocks.put(new BlockPos(x, 0, size), type);
schematicBlocks.put(new BlockPos(size, 0, x), type);
}
for (int x = 0; x < size; x++) {
schematicBlocks.put(new BlockPos(rightFacing ? x + size + 1 : x, 0, 0), type);
schematicBlocks.put(new BlockPos(0, 0, rightFacing ? x : x + size + 1), type);
schematicBlocks.put(new BlockPos(width - 1, 0, rightFacing ? x + size + 1 : x), type);
schematicBlocks.put(new BlockPos(rightFacing ? x : x + size + 1, 0, width - 1), type);
}
if (dots) {
schematicBlocks.put(new BlockPos(size / 2, 0, size / 2), type);
schematicBlocks.put(new BlockPos(size / 2 + size + 1, 0, size / 2), type);
schematicBlocks.put(new BlockPos(size / 2 + size + 1, 0, size / 2 + size + 1), type);
schematicBlocks.put(new BlockPos(size / 2, 0, size / 2 + size + 1), type);
}
}
/** /**
* Tuple links the BlockPos and Block to one another. * Tuple links the BlockPos and Block to one another.
* *
@ -75,10 +53,11 @@ public class Schematic {
*/ */
public Tuple<BlockPos, Block> getTupleFromBlockPos(BlockPos blockPos) { public Tuple<BlockPos, Block> getTupleFromBlockPos(BlockPos blockPos) {
if (schematicBlocks.containsKey(blockPos)) { if (schematicBlocks.containsKey(blockPos)) {
return new Tuple<BlockPos, Block>(blockPos, schematicBlocks.get(blockPos)); return new Tuple<>(blockPos, schematicBlocks.get(blockPos));
} }
return null; return null;
} }
/** /**
* Gets given block type in schematic from a BlockPos * Gets given block type in schematic from a BlockPos
* *
@ -88,6 +67,7 @@ public class Schematic {
public Block getBlockFromBlockPos(BlockPos blockPos) { public Block getBlockFromBlockPos(BlockPos blockPos) {
return schematicBlocks.get(blockPos); return schematicBlocks.get(blockPos);
} }
/** /**
* Gives the length along the X axis * Gives the length along the X axis
* *
@ -96,6 +76,7 @@ public class Schematic {
public int getWidth() { public int getWidth() {
return width; return width;
} }
/** /**
* Gives the height along the y axis * Gives the height along the y axis
* *
@ -104,6 +85,7 @@ public class Schematic {
public int getHeight() { public int getHeight() {
return height; return height;
} }
/** /**
* Gives the length along the z axis * Gives the length along the z axis
* *
@ -112,6 +94,7 @@ public class Schematic {
public int getLength() { public int getLength() {
return length; return length;
} }
public ArrayList<Entry<BlockPos, Block>> getEntries() { public ArrayList<Entry<BlockPos, Block>> getEntries() {
return new ArrayList(schematicBlocks.entrySet()); return new ArrayList(schematicBlocks.entrySet());
} }

View File

@ -5,24 +5,25 @@
*/ */
package baritone.schematic; package baritone.schematic;
import baritone.Baritone;
import baritone.pathfinding.goals.GoalComposite;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import baritone.Baritone;
import baritone.pathfinding.goals.GoalComposite;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
/** /**
* *
* @author leijurv * @author leijurv
*/ */
public class SchematicBuilder { public class SchematicBuilder {
ArrayList<Tuple<BlockPos, Block>> plan = new ArrayList(); ArrayList<Tuple<BlockPos, Block>> plan = new ArrayList();
BlockPos offset; BlockPos offset;
Schematic schematic; Schematic schematic;
public SchematicBuilder(Schematic schematic, BlockPos offset) { public SchematicBuilder(Schematic schematic, BlockPos offset) {
this.schematic = schematic; this.schematic = schematic;
this.offset = offset; this.offset = offset;
@ -30,6 +31,7 @@ public class SchematicBuilder {
plan.add(new Tuple(offset(entry.getKey()), entry.getValue())); plan.add(new Tuple(offset(entry.getKey()), entry.getValue()));
} }
} }
public void tick() { public void tick() {
HashSet<BlockPos> goal = getAllBlocksToPlaceShiftedUp(); HashSet<BlockPos> goal = getAllBlocksToPlaceShiftedUp();
//Out.log("Ticking " + goal); //Out.log("Ticking " + goal);
@ -42,8 +44,9 @@ public class SchematicBuilder {
//Out.gui("done building", Out.Mode.Standard); //Out.gui("done building", Out.Mode.Standard);
} }
} }
public HashSet<BlockPos> getAllBlocksToPlaceShiftedUp() { public HashSet<BlockPos> getAllBlocksToPlaceShiftedUp() {
HashSet<BlockPos> toPlace = new HashSet<BlockPos>(); HashSet<BlockPos> toPlace = new HashSet<>();
Block air = Block.getBlockById(0); Block air = Block.getBlockById(0);
for (int y = 0; y < schematic.getHeight(); y++) { for (int y = 0; y < schematic.getHeight(); y++) {
for (int x = 0; x < schematic.getWidth(); x++) { for (int x = 0; x < schematic.getWidth(); x++) {
@ -63,6 +66,7 @@ public class SchematicBuilder {
} }
return toPlace.isEmpty() ? null : toPlace; return toPlace.isEmpty() ? null : toPlace;
} }
private BlockPos offset(BlockPos original) { private BlockPos offset(BlockPos original) {
return new BlockPos(original.getX() + offset.getX(), original.getY() + offset.getY(), original.getZ() + offset.getZ()); return new BlockPos(original.getX() + offset.getX(), original.getY() + offset.getY(), original.getZ() + offset.getZ());
} }

View File

@ -5,6 +5,7 @@
*/ */
package baritone.schematic; package baritone.schematic;
import baritone.util.Out;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -13,7 +14,6 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import baritone.util.Out;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
@ -25,8 +25,10 @@ import net.minecraft.util.math.BlockPos;
* @author galdara * @author galdara
*/ */
public class SchematicLoader { public class SchematicLoader {
public static File schematicDir; public static File schematicDir;
private static final HashMap<File, Schematic> cachedSchematics = new HashMap<File, Schematic>(); private static final HashMap<File, Schematic> cachedSchematics = new HashMap<>();
private SchematicLoader() { private SchematicLoader() {
schematicDir = new File(Minecraft.getMinecraft().mcDataDir, "schematics"); schematicDir = new File(Minecraft.getMinecraft().mcDataDir, "schematics");
schematicDir.mkdir(); schematicDir.mkdir();
@ -43,9 +45,11 @@ public class SchematicLoader {
} }
} }
} }
public static SchematicLoader getLoader() { public static SchematicLoader getLoader() {
return new SchematicLoader(); return new SchematicLoader();
} }
public final Schematic loadFromFile(File nbtFile) throws FileNotFoundException, IOException { public final Schematic loadFromFile(File nbtFile) throws FileNotFoundException, IOException {
if (cachedSchematics.containsKey(nbtFile)) { if (cachedSchematics.containsKey(nbtFile)) {
return cachedSchematics.get(nbtFile); return cachedSchematics.get(nbtFile);
@ -59,7 +63,7 @@ public class SchematicLoader {
length = compound.getInteger("Length"); length = compound.getInteger("Length");
byte[][][] blocks = new byte[width][height][length], data = new byte[width][height][length]; byte[][][] blocks = new byte[width][height][length], data = new byte[width][height][length];
byte[] rawBlocks = compound.getByteArray("Blocks"); byte[] rawBlocks = compound.getByteArray("Blocks");
HashMap<BlockPos, Block> blocksMap = new HashMap<BlockPos, Block>(); HashMap<BlockPos, Block> blocksMap = new HashMap<>();
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) { for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++) { for (int x = 0; x < width; x++) {

View File

@ -5,12 +5,16 @@
*/ */
package baritone.util; package baritone.util;
import baritone.inventory.AnotherStealer; import baritone.Baritone;
import baritone.schematic.SchematicBuilder; import baritone.mining.MickeyMine;
import baritone.pathfinding.goals.GoalBlock;
import baritone.pathfinding.goals.GoalGetToBlock;
import baritone.pathfinding.goals.GoalXZ;
import baritone.pathfinding.goals.GoalYLevel;
import baritone.schematic.Schematic; import baritone.schematic.Schematic;
import baritone.schematic.SchematicBuilder;
import baritone.schematic.SchematicLoader; import baritone.schematic.SchematicLoader;
import baritone.inventory.SmeltingTask; import baritone.ui.LookManager;
import baritone.inventory.CraftingTask;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -19,24 +23,10 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import baritone.movement.Combat;
import baritone.strategy.EarlyGameStrategy;
import baritone.ui.LookManager;
import baritone.Baritone;
import baritone.movement.Parkour;
import baritone.mining.MickeyMine;
import baritone.pathfinding.goals.GoalBlock;
import baritone.pathfinding.goals.GoalGetToBlock;
import baritone.pathfinding.goals.GoalXZ;
import baritone.pathfinding.goals.GoalYLevel;
import baritone.ui.AimBow;
import baritone.ui.Screenshot;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
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.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
/** /**
@ -44,15 +34,18 @@ import net.minecraft.util.math.BlockPos;
* @author avecowa * @author avecowa
*/ */
public class ChatCommand { public class ChatCommand {
private static WorldClient theWorld() { private static WorldClient theWorld() {
return Minecraft.getMinecraft().world; return Minecraft.getMinecraft().world;
} }
private static EntityPlayerSP thePlayer() { private static EntityPlayerSP thePlayer() {
return Minecraft.getMinecraft().player; return Minecraft.getMinecraft().player;
} }
private static ArrayList<Field> fields; private static ArrayList<Field> fields;
private static ArrayList<Method> methods; private static ArrayList<Method> methods;
private static Method DONTYOUDARE; private static Method DONTYOUDARE;
static { static {
DONTYOUDARE = null; DONTYOUDARE = null;
// try { // try {
@ -67,10 +60,9 @@ public class ChatCommand {
addMethods(ChatCommand.class); addMethods(ChatCommand.class);
addMethods(MCEdit.class); addMethods(MCEdit.class);
addFields(Baritone.class); addFields(Baritone.class);
addFields(Combat.class);
addFields(SmeltingTask.class);
addFields(LookManager.class); addFields(LookManager.class);
} }
public static void addFields(Class<?> c) { public static void addFields(Class<?> c) {
Field[] temp = c.getFields(); Field[] temp = c.getFields();
for (Field f : temp) { for (Field f : temp) {
@ -79,6 +71,7 @@ public class ChatCommand {
} }
} }
} }
public static void addMethods(Class<?> c) { public static void addMethods(Class<?> c) {
Method[] temp = c.getDeclaredMethods(); Method[] temp = c.getDeclaredMethods();
for (Method m : temp) { for (Method m : temp) {
@ -87,6 +80,7 @@ public class ChatCommand {
} }
} }
} }
public static boolean message(String message) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { public static boolean message(String message) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Out.log("MSG: " + message); Out.log("MSG: " + message);
String text = (message.charAt(0) == '/' ? message.substring(1) : message).trim(); String text = (message.charAt(0) == '/' ? message.substring(1) : message).trim();
@ -109,6 +103,7 @@ public class ChatCommand {
} }
return false; return false;
} }
public static String set(String message) throws IllegalArgumentException, IllegalAccessException { public static String set(String message) throws IllegalArgumentException, IllegalAccessException {
int argc = message.split(" ").length; int argc = message.split(" ").length;
if (argc <= 1) { if (argc <= 1) {
@ -129,6 +124,7 @@ public class ChatCommand {
} }
return "THATS NOT A THING"; return "THATS NOT A THING";
} }
public static String importfrom(String message) throws ClassNotFoundException { public static String importfrom(String message) throws ClassNotFoundException {
String[] args = message.split(" "); String[] args = message.split(" ");
if (args.length != 3 || (!"m".equals(args[1]) && !"f".equals(args[1]))) { if (args.length != 3 || (!"m".equals(args[1]) && !"f".equals(args[1]))) {
@ -142,77 +138,38 @@ public class ChatCommand {
} }
return "Added from " + c; return "Added from " + c;
} }
public static String death(String message) { public static String death(String message) {
Baritone.goal = new GoalBlock(Baritone.death); Baritone.goal = new GoalBlock(Baritone.death);
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
public static String craft(String message) {
String spec = message.substring(5).trim();
if (spec.length() > 0) {
String item = spec.split(" ")[0];
String amt = spec.split(" ")[1];
ItemStack stack = new ItemStack(Item.getByNameOrId(item), Integer.parseInt(amt));
Out.log(CraftingTask.findOrCreateCraftingTask(stack));
}
return "k";
}
public static String smelt(String message) {
String spec = message.substring(5).trim();
if (spec.length() > 0) {
String item = spec.split(" ")[0];
String amt = spec.split(" ")[1];
ItemStack stack = new ItemStack(Item.getByNameOrId(item), Integer.parseInt(amt));
new SmeltingTask(stack).begin();
} else {
new SmeltingTask(Minecraft.getMinecraft().player.getCurrentEquippedItem()).begin();
}
return "k";
}
public static String containeritem(String message) {
CraftingTask.getRecipeFromItem(thePlayer().getCurrentEquippedItem().getItem());
return "k";
}
public static String ore(String message) { public static String ore(String message) {
MickeyMine.toggleOre(message.substring(3).trim()); MickeyMine.toggleOre(message.substring(3).trim());
return ""; return "";
} }
public static String parkour(String message) {
return "Parkour: " + Manager.toggle(Parkour.class);
}
public static String mine(String message) { public static String mine(String message) {
return "Mreow mine: " + Manager.toggle(MickeyMine.class); return "Mreow mine: " + Manager.toggle(MickeyMine.class);
} }
public static String fullauto(String message) {
return "Full Auto: " + Manager.toggle(EarlyGameStrategy.class);
}
public static String record(String message) {
return "Record: " + Manager.toggle(Screenshot.class);
}
public static String wizard(String message) { public static String wizard(String message) {
return "YOURE A LIZARD HARRY " + (Baritone.isThereAnythingInProgress ^= true); return "YOURE A LIZARD HARRY " + (Baritone.isThereAnythingInProgress ^= true);
} }
public static String actuallyTalk(String message) { public static String actuallyTalk(String message) {
Baritone.actuallyPutMessagesInChat ^= true; Baritone.actuallyPutMessagesInChat ^= true;
return "toggled to " + Baritone.actuallyPutMessagesInChat; return "toggled to " + Baritone.actuallyPutMessagesInChat;
} }
public static String allowPlaceOrBreak(String message) { public static String allowPlaceOrBreak(String message) {
return adventure(message); return adventure(message);
} }
public static String arrowPearl(String message) {
if (AimBow.lastBlock != null) {
Baritone.goal = new GoalXZ(AimBow.lastBlock.getX(), AimBow.lastBlock.getZ());
Baritone.findPathInNewThread(false);
return "Aiming: Pathing to X" + AimBow.lastBlock.getX() + ", Z" + AimBow.lastBlock.getZ();
} else {
return "Aiming: You need to be holding a bow!";
}
}
public static String adventure(String message) { public static String adventure(String message) {
return "allowBreakOrPlace: " + (Baritone.allowBreakOrPlace ^= true); return "allowBreakOrPlace: " + (Baritone.allowBreakOrPlace ^= true);
} }
public static String steal(String message) {
return stealer(message);
}
public static String save(String message) { public static String save(String message) {
String t = message.substring(4).trim(); String t = message.substring(4).trim();
if (Baritone.goal == null) { if (Baritone.goal == null) {
@ -224,9 +181,11 @@ public class ChatCommand {
Memory.goalMemory.put(t, ((GoalBlock) Baritone.goal).pos()); Memory.goalMemory.put(t, ((GoalBlock) Baritone.goal).pos());
return "Saved " + Baritone.goal + " under " + t; return "Saved " + Baritone.goal + " under " + t;
} }
public static String load(String message) { public static String load(String message) {
return "Set goal to " + (Baritone.goal = new GoalBlock(Memory.goalMemory.get(message.substring(4).trim()))); return "Set goal to " + (Baritone.goal = new GoalBlock(Memory.goalMemory.get(message.substring(4).trim())));
} }
public static String random(String message) { public static String random(String message) {
double dist = Double.parseDouble(message.substring("random direction".length()).trim()); double dist = Double.parseDouble(message.substring("random direction".length()).trim());
double ang = new Random().nextDouble() * Math.PI * 2; double ang = new Random().nextDouble() * Math.PI * 2;
@ -237,30 +196,27 @@ public class ChatCommand {
Baritone.goal = new GoalXZ(x, z); Baritone.goal = new GoalXZ(x, z);
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
public static String findgo(String message) { public static String findgo(String message) {
return Memory.findGoCommand(message.substring(6).trim()); return Memory.findGoCommand(message.substring(6).trim());
} }
public static String find(String message) { public static String find(String message) {
return Memory.findCommand(message.substring(4).trim()); return Memory.findCommand(message.substring(4).trim());
} }
public static String look(String message) { public static String look(String message) {
LookManager.lookAtBlock(new BlockPos(0, 0, 0), true); LookManager.lookAtBlock(new BlockPos(0, 0, 0), true);
return ""; return "";
} }
public static String cancel(String message) { public static String cancel(String message) {
Baritone.cancelPath(); Baritone.cancelPath();
Combat.mobHunting = false;
Combat.mobKilling = false;
Baritone.plsCancel = true; Baritone.plsCancel = true;
for (Class c : Baritone.managers) { Manager.cancel(LookManager.class);
Manager.cancel(c);
}
return Baritone.isThereAnythingInProgress ? "Cancelled it, but btw I'm pathfinding right now" : "Cancelled it"; return Baritone.isThereAnythingInProgress ? "Cancelled it, but btw I'm pathfinding right now" : "Cancelled it";
} }
public static String cancelfurnace(String message) {
SmeltingTask.clearInProgress();
return "k =)";
}
public static String st(String message) { public static String st(String message) {
WorldClient theWorld = theWorld(); WorldClient theWorld = theWorld();
EntityPlayerSP thePlayer = thePlayer(); EntityPlayerSP thePlayer = thePlayer();
@ -270,14 +226,16 @@ public class ChatCommand {
Out.gui(Baritone.info(playerFeet.up()), Out.Mode.Minimal); Out.gui(Baritone.info(playerFeet.up()), Out.Mode.Minimal);
return ""; return "";
} }
public static String setgoal(String message) { public static String setgoal(String message) {
return goal(message); return goal(message);
} }
public static String goal(String message) { public static String goal(String message) {
Baritone.plsCancel = false; Baritone.plsCancel = false;
int ind = message.indexOf(' ') + 1; int ind = message.indexOf(' ') + 1;
if (ind == 0) { if (ind == 0) {
Baritone.goal = new GoalBlock(thePlayer().playerFeet()); Baritone.goal = new GoalBlock(Baritone.playerFeet);
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
String[] strs = message.substring(ind).split(" "); String[] strs = message.substring(ind).split(" ");
@ -309,42 +267,45 @@ public class ChatCommand {
} }
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
public static String gotoblock(String message) { public static String gotoblock(String message) {
return Memory.gotoCommand(message.substring(4).trim().toLowerCase()); return Memory.gotoCommand(message.substring(4).trim().toLowerCase());
} }
public static String kill(String message) {
return Combat.killCommand(message.substring(4).trim().toLowerCase());
}
public static String player(String message) { public static String player(String message) {
return Memory.playerCommand(message.substring(6).trim()); return Memory.playerCommand(message.substring(6).trim());
} }
public static String thisway(String message) { public static String thisway(String message) {
return "Set goal to " + (Baritone.goal = LookManager.fromAngleAndDirection(Double.parseDouble(message.substring(7).trim()))); return "Set goal to " + (Baritone.goal = LookManager.fromAngleAndDirection(Double.parseDouble(message.substring(7).trim())));
} }
public static String path(String message) { public static String path(String message) {
Baritone.plsCancel = false; Baritone.plsCancel = false;
String[] split = message.split(" "); String[] split = message.split(" ");
Baritone.findPathInNewThread(thePlayer().playerFeet(), split.length > 1 ? Boolean.parseBoolean(split[1]) : true); Baritone.findPathInNewThread(Baritone.playerFeet, split.length > 1 ? Boolean.parseBoolean(split[1]) : true);
return ""; return "";
} }
public static String hardness(String message) { public static String hardness(String message) {
BlockPos bp = Baritone.whatAreYouLookingAt(); BlockPos bp = Baritone.whatAreYouLookingAt();
return bp == null ? "0" : (1 / theWorld().getBlockState(bp).getBlock().getPlayerRelativeBlockHardness(thePlayer(), theWorld(), Baritone.whatAreYouLookingAt())) + ""; return bp == null ? "0" : (1 / theWorld().getBlockState(bp).getBlock().getPlayerRelativeBlockHardness(theWorld().getBlockState(bp), thePlayer(), theWorld(), Baritone.whatAreYouLookingAt())) + "";
} }
public static String info(String message) { public static String info(String message) {
return Baritone.info(Baritone.whatAreYouLookingAt()); return Baritone.info(Baritone.whatAreYouLookingAt());
} }
public static String toggle(String message) throws IllegalArgumentException, IllegalAccessException { public static String toggle(String message) throws IllegalArgumentException, IllegalAccessException {
return set(message); return set(message);
} }
public static String stealer(String message) {
return "stealer: " + Manager.toggle(AnotherStealer.class);
}
public static String printtag(String message) throws IOException { public static String printtag(String message) throws IOException {
Schematic sch = SchematicLoader.getLoader().loadFromFile(new File("/Users/galdara/Downloads/schematics/Bakery.schematic")); Schematic sch = SchematicLoader.getLoader().loadFromFile(new File("/Users/galdara/Downloads/schematics/Bakery.schematic"));
Baritone.currentBuilder = new SchematicBuilder(sch, Baritone.playerFeet); Baritone.currentBuilder = new SchematicBuilder(sch, Baritone.playerFeet);
return "printed schematic to console."; return "printed schematic to console.";
} }
public static String samplebuild(String message) { public static String samplebuild(String message) {
int size = 5; int size = 5;
BlockPos pl = Baritone.playerFeet; BlockPos pl = Baritone.playerFeet;
@ -352,21 +313,12 @@ public class ChatCommand {
Baritone.currentBuilder = new SchematicBuilder(new Schematic(Block.getBlockFromName("dirt"), size), center); Baritone.currentBuilder = new SchematicBuilder(new Schematic(Block.getBlockFromName("dirt"), size), center);
return "ok"; return "ok";
} }
public static String pinwheel(String message) {
if (true) {
return "haha. no.";
}
int size = 5;
BlockPos pl = Baritone.playerFeet;
BlockPos center = new BlockPos(pl.getX() - size, pl.getY(), pl.getZ() - size);
Baritone.currentBuilder = new SchematicBuilder(new Schematic(Block.getBlockFromName("dirt"), size * 2 + 1, false, true), center);
return "ok";
}
public static String getToGoal(String message) { public static String getToGoal(String message) {
Baritone.plsCancel = false; Baritone.plsCancel = false;
int ind = message.indexOf(' ') + 1; int ind = message.indexOf(' ') + 1;
if (ind == 0) { if (ind == 0) {
Baritone.goal = new GoalGetToBlock(thePlayer().playerFeet()); Baritone.goal = new GoalGetToBlock(Baritone.playerFeet);
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
String[] strs = message.substring(ind).split(" "); String[] strs = message.substring(ind).split(" ");
@ -392,10 +344,12 @@ public class ChatCommand {
} }
return "Set goal to " + Baritone.goal; return "Set goal to " + Baritone.goal;
} }
public static String debug(String message) { public static String debug(String message) {
Out.mode = Out.Mode.Debug; Out.mode = Out.Mode.Debug;
return "Set mode to debug"; return "Set mode to debug";
} }
public static String chatMode(String message) { public static String chatMode(String message) {
String[] args = message.split(" "); String[] args = message.split(" ");
if (args.length == 1) { if (args.length == 1) {

View File

@ -6,7 +6,7 @@
package baritone.util; package baritone.util;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.text.TextComponentString;
/** /**
* This class serves the purpose of filtering what messages get send to the chat * This class serves the purpose of filtering what messages get send to the chat
@ -15,6 +15,7 @@ import net.minecraft.util.ChatComponentText;
* @author avecowa * @author avecowa
*/ */
public class Out { public class Out {
/** /**
* Out has an Mode at all times. The Mode determines behavior of of the * Out has an Mode at all times. The Mode determines behavior of of the
* filter. * filter.
@ -53,6 +54,7 @@ public class Out {
Ludicrous Ludicrous
} }
public static Mode mode = Mode.Standard; public static Mode mode = Mode.Standard;
/** /**
* Logs a message to the standard system output. Before writing it runs a * Logs a message to the standard system output. Before writing it runs a
* stacktrace and appends the class and line number of the calling method to * stacktrace and appends the class and line number of the calling method to
@ -69,6 +71,7 @@ public class Out {
chatRaw("§5[§dLog§5|§2" + trace + "§5]§f " + o.toString()); chatRaw("§5[§dLog§5|§2" + trace + "§5]§f " + o.toString());
} }
} }
/** /**
* Prints a message to the client's chat GUI. Messages will not be displayed * Prints a message to the client's chat GUI. Messages will not be displayed
* if their Mode is a lower importance than the set mode. * if their Mode is a lower importance than the set mode.
@ -104,9 +107,11 @@ public class Out {
chatRaw(message); chatRaw(message);
} }
} }
private static void chatRaw(String s) { private static void chatRaw(String s) {
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(s)); Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(s));
} }
private static String trace() { private static String trace() {
StackTraceElement[] stack = Thread.currentThread().getStackTrace(); StackTraceElement[] stack = Thread.currentThread().getStackTrace();
StackTraceElement trace = stack[3]; StackTraceElement trace = stack[3];