replace
This commit is contained in:
parent
f559e45f9c
commit
38a7b72570
@ -152,7 +152,7 @@ public class AnotherStealer extends Manager {
|
||||
return;
|
||||
}
|
||||
public static BlockPos getAjacentChest() {
|
||||
BlockPos[] pos = GoalGetToBlock.ajacentBlocks(Minecraft.getMinecraft().player.getPosition0());
|
||||
BlockPos[] pos = GoalGetToBlock.ajacentBlocks(Baritone.playerFeet);
|
||||
WorldClient w = Minecraft.getMinecraft().world;
|
||||
for (BlockPos p : pos) {
|
||||
if (!alreadyStolenFrom.contains(p) && w.getBlockState(p).getBlock().equals(CHEST)) {
|
||||
|
@ -216,19 +216,19 @@ public class CraftingTask extends ManagerTick {
|
||||
if (placeHeldBlockNearby()) {
|
||||
return true;
|
||||
}
|
||||
BlockPos player = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
if (Baritone.isAir(player.down()) || Baritone.isAir(player.up(2))) {
|
||||
Out.gui("Placing down", Out.Mode.Debug);
|
||||
LookManager.lookAtBlock(Minecraft.getMinecraft().player.getPosition0().down(), true);
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down(), true);
|
||||
MovementManager.jumping = true;
|
||||
MovementManager.sneak = true;
|
||||
if (Minecraft.getMinecraft().player.getPosition0().down().equals(Baritone.whatAreYouLookingAt()) || Minecraft.getMinecraft().player.getPosition0().down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
if (Baritone.playerFeet.down().equals(Baritone.whatAreYouLookingAt()) || Baritone.playerFeet.down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
LookManager.lookAtBlock(Minecraft.getMinecraft().player.getPosition0().down().north(), true);
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down().north(), true);
|
||||
LookManager.beSketchy();
|
||||
Baritone.forward = new Random().nextBoolean();
|
||||
Baritone.backward = new Random().nextBoolean();
|
||||
@ -247,7 +247,7 @@ public class CraftingTask extends ManagerTick {
|
||||
return false;
|
||||
}
|
||||
public static boolean placeHeldBlockNearby() {
|
||||
BlockPos player = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
for (int x = player.getX() - 3; x <= player.getX() + 3; x++) {
|
||||
for (int y = player.getY() - 2; y <= player.getY() + 1; y++) {
|
||||
for (int z = player.getZ() - 3; z <= player.getZ() + 3; z++) {
|
||||
|
@ -241,8 +241,8 @@ public class InventoryManager extends Manager {
|
||||
BlockPos look = Baritone.whatAreYouLookingAt();
|
||||
boolean doThrowAway = true;
|
||||
if (look != null) {
|
||||
int xDiff = look.getX() - Minecraft.getMinecraft().player.getPosition0().getX();
|
||||
int zDiff = look.getZ() - Minecraft.getMinecraft().player.getPosition0().getZ();
|
||||
int xDiff = look.getX() - Baritone.playerFeet.getX();
|
||||
int zDiff = look.getZ() - Baritone.playerFeet.getZ();
|
||||
if (Math.abs(xDiff) + Math.abs(zDiff) <= 2) {
|
||||
doThrowAway = false;//dont throw away if we are looking at a wall and we are close, because we'll probably just pick it right back up again
|
||||
}
|
||||
|
@ -167,12 +167,12 @@ public class SmeltingTask extends ManagerTick {
|
||||
if (placeHeldBlockNearby()) {
|
||||
return true;
|
||||
}
|
||||
BlockPos player = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
if (Baritone.isAir(player.down()) || Baritone.isAir(player.up(2))) {
|
||||
Out.gui("Placing down", Out.Mode.Debug);
|
||||
LookManager.lookAtBlock(Minecraft.getMinecraft().player.getPosition0().down(), true);
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down(), true);
|
||||
MovementManager.jumping = true;
|
||||
if (Minecraft.getMinecraft().player.getPosition0().down().equals(Baritone.whatAreYouLookingAt()) || Minecraft.getMinecraft().player.getPosition0().down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
if (Baritone.playerFeet.down().equals(Baritone.whatAreYouLookingAt()) || Baritone.playerFeet.down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
|
@ -5,10 +5,8 @@
|
||||
*/
|
||||
package baritone.mining;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Memory;
|
||||
import baritone.Baritone;
|
||||
import baritone.inventory.CraftingTask;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.pathfinding.actions.Action;
|
||||
import baritone.pathfinding.goals.Goal;
|
||||
@ -16,19 +14,20 @@ import baritone.pathfinding.goals.GoalBlock;
|
||||
import baritone.pathfinding.goals.GoalComposite;
|
||||
import baritone.pathfinding.goals.GoalTwoBlocks;
|
||||
import baritone.pathfinding.goals.GoalYLevel;
|
||||
import baritone.inventory.CraftingTask;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.ManagerTick;
|
||||
import baritone.util.Memory;
|
||||
import baritone.util.Out;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
/**
|
||||
@ -36,6 +35,7 @@ import net.minecraft.world.chunk.Chunk;
|
||||
* @author galdara
|
||||
*/
|
||||
public class MickeyMine extends ManagerTick {
|
||||
|
||||
public static final int Y_DIAMOND = 13;
|
||||
public static final int Y_IRON = 36;
|
||||
public static int yLevel = Y_DIAMOND;
|
||||
@ -53,6 +53,7 @@ public class MickeyMine extends ManagerTick {
|
||||
static final String[] ores = {"diamond", "iron", "coal", "gold", "emerald"};
|
||||
static final boolean[] enabled = {true, true, false, true, true};
|
||||
static boolean mightNeedToGoBackToPath = false;
|
||||
|
||||
public static void notifyFullness(String item, boolean isFull) {
|
||||
if (item.equals("stone")) {
|
||||
return;
|
||||
@ -71,6 +72,7 @@ public class MickeyMine extends ManagerTick {
|
||||
calculateGoal();
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleOre(String ore) {
|
||||
String lower = ore.toLowerCase();
|
||||
if (lower.trim().length() == 0) {
|
||||
@ -94,6 +96,7 @@ public class MickeyMine extends ManagerTick {
|
||||
calculateGoal();
|
||||
}
|
||||
}
|
||||
|
||||
public static void calculateGoal() {
|
||||
goalBlocks = new ArrayList<Block>();
|
||||
for (int i = 0; i < ores.length; i++) {
|
||||
@ -109,6 +112,7 @@ public class MickeyMine extends ManagerTick {
|
||||
goalBlocks.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
public static void doMine() {
|
||||
if (goalBlocks == null) {
|
||||
calculateGoal();
|
||||
@ -128,6 +132,7 @@ public class MickeyMine extends ManagerTick {
|
||||
Manager.getManager(MickeyMine.class).cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean torch() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
@ -144,17 +149,18 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void doBranchMine() {
|
||||
if (branchPosition == null) {
|
||||
BlockPos player = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
branchPosition = new BlockPos(player.getX(), yLevel, player.getZ());
|
||||
}
|
||||
if (!Memory.blockLoaded(branchPosition)) {//if this starts before chunks load, this thing just goes on forever
|
||||
branchPosition = null;
|
||||
return;
|
||||
}
|
||||
if (!branchPosition.equals(Minecraft.getMinecraft().player.getPosition0())) {
|
||||
Out.gui("Should be at branch position " + branchPosition + " " + Minecraft.getMinecraft().player.getPosition0(), Out.Mode.Debug);
|
||||
if (!branchPosition.equals(Baritone.playerFeet)) {
|
||||
Out.gui("Should be at branch position " + branchPosition + " " + Baritone.playerFeet, Out.Mode.Debug);
|
||||
mightNeedToGoBackToPath = true;
|
||||
} else if (torch()) {
|
||||
if (LookManager.lookAtBlock(branchPosition.down(), true)) {
|
||||
@ -189,6 +195,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
branchPosition = futureBranchPosition;
|
||||
}
|
||||
|
||||
public static void doPriorityMine() {
|
||||
Goal[] toComposite = new Goal[priorityNeedsToBeMined.size()];
|
||||
for (int i = 0; i < toComposite.length; i++) {
|
||||
@ -196,13 +203,14 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
Baritone.goal = new GoalComposite(toComposite);
|
||||
if (Baritone.currentPath == null && !Baritone.isPathFinding()) {
|
||||
Baritone.findPathInNewThread(Minecraft.getMinecraft().player.getPosition0(), false);
|
||||
Baritone.findPathInNewThread(Baritone.playerFeet, false);
|
||||
} else {
|
||||
addNearby();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addNearby() {
|
||||
BlockPos playerFeet = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos playerFeet = Baritone.playerFeet;
|
||||
int searchDist = 4;//why four? idk
|
||||
for (int x = playerFeet.getX() - searchDist; x <= playerFeet.getX() + searchDist; x++) {
|
||||
for (int y = playerFeet.getY() - searchDist; y <= playerFeet.getY() + searchDist; y++) {
|
||||
@ -217,14 +225,15 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void doNormalMine() {
|
||||
if (mightNeedToGoBackToPath) {
|
||||
Baritone.goal = new GoalBlock(branchPosition);
|
||||
if (Baritone.currentPath == null && !Baritone.isPathFinding()) {
|
||||
Baritone.findPathInNewThread(Minecraft.getMinecraft().player.getPosition0(), false);
|
||||
Baritone.findPathInNewThread(Baritone.playerFeet, false);
|
||||
Out.gui("Pathing back to branch", Out.Mode.Standard);
|
||||
}
|
||||
if (Minecraft.getMinecraft().player.getPosition0().equals(branchPosition)) {
|
||||
if (Baritone.playerFeet.equals(branchPosition)) {
|
||||
mightNeedToGoBackToPath = false;
|
||||
Out.gui("I'm back", Out.Mode.Debug);
|
||||
}
|
||||
@ -242,7 +251,7 @@ public class MickeyMine extends ManagerTick {
|
||||
Baritone.switchToBestTool();
|
||||
MovementManager.isLeftClick = true;
|
||||
Out.log("Looking");
|
||||
if (Minecraft.getMinecraft().player.getPosition0().equals(branchPosition)) {
|
||||
if (Baritone.playerFeet.equals(branchPosition)) {
|
||||
Out.log("IN position");
|
||||
if (Baritone.whatAreYouLookingAt() == null) {
|
||||
Out.log("Can't see, going");
|
||||
@ -250,13 +259,13 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
} else {
|
||||
Out.log("Going to position");
|
||||
if (!Action.canWalkOn(Minecraft.getMinecraft().player.getPosition0().offset(Minecraft.getMinecraft().player.getHorizontalFacing()).down())) {
|
||||
if (!Action.canWalkOn(Baritone.playerFeet.offset(Minecraft.getMinecraft().player.getHorizontalFacing()).down())) {
|
||||
Out.gui("About to fall off", Out.Mode.Debug);
|
||||
mightNeedToGoBackToPath = true;
|
||||
return;
|
||||
}
|
||||
MovementManager.moveTowardsBlock(branchPosition, false);
|
||||
if (Minecraft.getMinecraft().player.getPosition0().getY() != branchPosition.getY()) {
|
||||
if (Baritone.playerFeet.getY() != branchPosition.getY()) {
|
||||
Out.gui("wrong Y coordinate", Out.Mode.Debug);
|
||||
mightNeedToGoBackToPath = true;
|
||||
}
|
||||
@ -265,6 +274,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
}
|
||||
static double ticksSinceBlockMined = 0;
|
||||
|
||||
public static void updateBlocksMined() {
|
||||
if (Baritone.currentPath == null) {
|
||||
ticksSinceBlockMined++;
|
||||
@ -274,7 +284,7 @@ public class MickeyMine extends ManagerTick {
|
||||
ArrayList<BlockPos> shouldBeRemoved = new ArrayList<BlockPos>();
|
||||
for (BlockPos isMined : needsToBeMined) {
|
||||
Block block = net.minecraft.client.Minecraft.getMinecraft().world.getBlockState(isMined).getBlock();
|
||||
if (isGoalBlock(isMined) || block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.bedrock)) {
|
||||
if (isGoalBlock(isMined) || block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.BEDROCK)) {
|
||||
hasBeenMined.add(isMined);
|
||||
shouldBeRemoved.add(isMined);
|
||||
updateBlocks(isMined);
|
||||
@ -285,12 +295,13 @@ public class MickeyMine extends ManagerTick {
|
||||
needsToBeMined.remove(needsRemoval);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updatePriorityBlocksMined() {
|
||||
boolean wasEmpty = priorityNeedsToBeMined.isEmpty();
|
||||
ArrayList<BlockPos> shouldBeRemoved = new ArrayList<BlockPos>();
|
||||
for (BlockPos isMined : priorityNeedsToBeMined) {
|
||||
Block block = net.minecraft.client.Minecraft.getMinecraft().world.getBlockState(isMined).getBlock();
|
||||
if (block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.bedrock)) {
|
||||
if (block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.BEDROCK)) {
|
||||
hasBeenMined.add(isMined);
|
||||
shouldBeRemoved.add(isMined);
|
||||
updateBlocks(isMined);
|
||||
@ -312,6 +323,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateBlocks(BlockPos blockPos) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Out.log(blockPos.offset(miningFacing));
|
||||
@ -324,6 +336,7 @@ public class MickeyMine extends ManagerTick {
|
||||
addPriorityBlock(blockPos.up());
|
||||
addPriorityBlock(blockPos.down());
|
||||
}
|
||||
|
||||
public static boolean addNormalBlock(BlockPos blockPos, boolean mainBranch) {
|
||||
if (!needsToBeMined.contains(blockPos)) {
|
||||
if (Action.avoidBreaking(blockPos) && mainBranch) {//who gives a crap if a side branch will hit lava? lol
|
||||
@ -336,6 +349,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean addPriorityBlock(BlockPos blockPos) {
|
||||
if (!priorityNeedsToBeMined.contains(blockPos) && isGoalBlock(blockPos)) {
|
||||
if (Action.avoidBreaking(blockPos)) {
|
||||
@ -360,12 +374,15 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGoalBlock(BlockPos blockPos) {
|
||||
return isGoalBlock(Minecraft.getMinecraft().world.getBlockState(blockPos).getBlock());
|
||||
}
|
||||
|
||||
public static boolean isGoalBlock(Block block) {
|
||||
return goalBlocks.contains(block);
|
||||
}
|
||||
|
||||
public static boolean isNull(Object object) {
|
||||
try {
|
||||
object.toString();
|
||||
@ -374,12 +391,15 @@ public class MickeyMine extends ManagerTick {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static IntegerTuple tupleFromChunk(Chunk chunk) {
|
||||
return new IntegerTuple(chunk.xPosition, chunk.zPosition);
|
||||
}
|
||||
|
||||
public static IntegerTuple tupleFromBlockPos(BlockPos blockPos) {
|
||||
return tupleFromChunk(Minecraft.getMinecraft().world.getChunkFromBlockCoords(blockPos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onTick0() {
|
||||
if (tempDisable) {
|
||||
@ -389,11 +409,11 @@ public class MickeyMine extends ManagerTick {
|
||||
if (!isGoingToMine && !isMining) {
|
||||
Baritone.goal = new GoalYLevel(yLevel);
|
||||
if (Baritone.currentPath == null && !Baritone.isPathFinding()) {
|
||||
Baritone.findPathInNewThread(Minecraft.getMinecraft().player.getPosition0(), true);
|
||||
Baritone.findPathInNewThread(Baritone.playerFeet, true);
|
||||
isGoingToMine = true;
|
||||
}
|
||||
}
|
||||
if (isGoingToMine && Minecraft.getMinecraft().player.getPosition0().getY() == yLevel) {
|
||||
if (isGoingToMine && Baritone.playerFeet.getY() == yLevel) {
|
||||
isGoingToMine = false;
|
||||
isMining = true;
|
||||
}
|
||||
@ -407,10 +427,12 @@ public class MickeyMine extends ManagerTick {
|
||||
Out.log("mickey done");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
onCancel1();
|
||||
}
|
||||
|
||||
private static void onCancel1() {
|
||||
isGoingToMine = false;
|
||||
isMining = false;
|
||||
@ -420,25 +442,31 @@ public class MickeyMine extends ManagerTick {
|
||||
mightNeedToGoBackToPath = false;
|
||||
ticksSinceBlockMined = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickPre() {
|
||||
tempDisable = false;
|
||||
}
|
||||
|
||||
public static class IntegerTuple {//why not use the normal net.minecraft.util.Tuple? Because it doesn't implement equals or hashCode
|
||||
|
||||
private final int a;
|
||||
private final int b;
|
||||
|
||||
public IntegerTuple(int a, int b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return a + "," + b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
@ -446,6 +474,7 @@ public class MickeyMine extends ManagerTick {
|
||||
hash = 73 * hash + this.b;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
|
@ -1,261 +0,0 @@
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package baritone.movement;
|
||||
|
||||
import baritone.ui.LookManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import baritone.Baritone;
|
||||
import static baritone.Baritone.findPathInNewThread;
|
||||
import static baritone.Baritone.goal;
|
||||
import static baritone.Baritone.isAir;
|
||||
import static baritone.Baritone.whatEntityAreYouLookingAt;
|
||||
import baritone.pathfinding.goals.GoalRunAway;
|
||||
import baritone.pathfinding.goals.GoalTwoBlocks;
|
||||
import baritone.util.ManagerTick;
|
||||
import baritone.util.Out;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* this entire class is sketchy i don't even know
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Combat extends ManagerTick {
|
||||
public static boolean mobHunting = false;
|
||||
public static boolean mobKilling = false;
|
||||
public static boolean playerHunt = false;
|
||||
public static Entity target = null;
|
||||
public static boolean wasTargetSetByMobHunt = false;
|
||||
@Override
|
||||
public boolean onTick0() {
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
World theWorld = Minecraft.getMinecraft().world;
|
||||
BlockPos playerFeet = new BlockPos(thePlayer.posX, thePlayer.posY, thePlayer.posZ);
|
||||
boolean healthOkToHunt = Minecraft.getMinecraft().player.getHealth() >= 12 || (target != null && target instanceof EntityPlayer);
|
||||
ArrayList<Entity> killAura = new ArrayList<Entity>();
|
||||
for (Entity entity : theWorld.loadedEntityList) {
|
||||
if (entity.isEntityAlive() && !(entity instanceof EntityEnderman)) {
|
||||
if ((mobKilling && entity instanceof EntityMob) || ((playerHunt && (entity instanceof EntityPlayer) && !(entity.getName().equals(thePlayer.getName())) && !couldBeInCreative((EntityPlayer) entity)))) {
|
||||
if (distFromMe(entity) < 5) {
|
||||
killAura.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
killAura.sort(new Comparator<Entity>() {
|
||||
@Override
|
||||
public int compare(Entity o1, Entity o2) {
|
||||
return new Double(distFromMe(o1)).compareTo(distFromMe(o2));
|
||||
}
|
||||
});
|
||||
if (!killAura.isEmpty()) {
|
||||
Entity entity = killAura.get(0);
|
||||
AxisAlignedBB lol = entity.getEntityBoundingBox();
|
||||
switchtosword();
|
||||
Out.log("looking");
|
||||
LookManager.lookAtCoords((lol.minX + lol.maxX) / 2, (lol.minY + lol.maxY) / 2, (lol.minZ + lol.maxZ) / 2, true);
|
||||
if (entity.equals(Baritone.whatEntityAreYouLookingAt())) {
|
||||
MovementManager.isLeftClick = true;
|
||||
if (Baritone.tickNumber % 10 < 3) {
|
||||
MovementManager.isLeftClick = false;
|
||||
}
|
||||
tickPath = false;
|
||||
Out.log("Doing it");
|
||||
}
|
||||
}
|
||||
ArrayList<Entity> huntMobs = new ArrayList<Entity>();
|
||||
for (Entity entity : theWorld.loadedEntityList) {
|
||||
if (entity.isEntityAlive() && distFromMe(entity) < 30 && !(entity instanceof EntityEnderman)) {
|
||||
if (!playerHunt && (entity instanceof EntityMob) && entity.posY > thePlayer.posY - 6) {
|
||||
huntMobs.add(entity);
|
||||
}
|
||||
if ((playerHunt && (entity instanceof EntityPlayer) && !(entity.getName().equals(thePlayer.getName())) && !couldBeInCreative((EntityPlayer) entity))) {
|
||||
huntMobs.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
huntMobs.sort(new Comparator<Entity>() {
|
||||
@Override
|
||||
public int compare(Entity o1, Entity o2) {
|
||||
return new Double(distFromMe(o1)).compareTo(distFromMe(o2));
|
||||
}
|
||||
});
|
||||
if (mobHunting && (target == null || wasTargetSetByMobHunt)) {
|
||||
if (!huntMobs.isEmpty()) {
|
||||
Entity entity = huntMobs.get(0);
|
||||
if (!entity.equals(target)) {
|
||||
if (!(!(entity instanceof EntityPlayer) && (target instanceof EntityPlayer) && playerHunt)) {//if playerhunt is true, dont overwrite a player target with a non player target
|
||||
Out.gui("Mobhunting=true. Killing " + entity, Out.Mode.Minimal);
|
||||
Baritone.currentPath = null;
|
||||
target = entity;
|
||||
wasTargetSetByMobHunt = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!healthOkToHunt && target != null && wasTargetSetByMobHunt && mobHunting) {
|
||||
if (Baritone.currentPath != null) {
|
||||
if (!(Baritone.currentPath.goal instanceof GoalRunAway)) {
|
||||
Out.gui("Health too low, cancelling hunt", Out.Mode.Minimal);
|
||||
Baritone.currentPath = null;
|
||||
}
|
||||
}
|
||||
MovementManager.clearMovement();
|
||||
BlockPos[] away = new BlockPos[Math.min(5, huntMobs.size())];
|
||||
for (int i = 0; i < away.length; i++) {
|
||||
away[i] = new BlockPos(huntMobs.get(i).posX, huntMobs.get(i).posY, huntMobs.get(i).posZ);
|
||||
}
|
||||
if (away.length != 0) {
|
||||
Baritone.goal = new GoalRunAway(35, away);
|
||||
if (Baritone.currentPath == null || (!Baritone.isThereAnythingInProgress && Baritone.tickNumber % 4 == 0)) {
|
||||
Out.gui("Running away", Out.Mode.Minimal);
|
||||
Baritone.findPathInNewThread(playerFeet, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target != null && target.isDead) {
|
||||
Out.gui(target + " is dead", Out.Mode.Standard);
|
||||
target = null;
|
||||
Baritone.currentPath = null;
|
||||
MovementManager.clearMovement();
|
||||
}
|
||||
if (target != null && healthOkToHunt) {
|
||||
BlockPos targetPos = new BlockPos(target.posX, target.posY, target.posZ);
|
||||
Baritone.goal = new GoalTwoBlocks(targetPos);
|
||||
if (Baritone.currentPath != null) {
|
||||
double movementSince = dist(targetPos, Baritone.currentPath.end);
|
||||
if (movementSince > 4 && !Baritone.isThereAnythingInProgress) {
|
||||
Out.gui("They moved too much, " + movementSince + " blocks. recalculating", Out.Mode.Standard);
|
||||
Baritone.findPathInNewThread(playerFeet, true);//this will overwrite currentPath
|
||||
}
|
||||
}
|
||||
double dist = distFromMe(target);
|
||||
boolean actuallyLookingAt = target.equals(Baritone.whatEntityAreYouLookingAt());
|
||||
//Out.gui(dist + " " + actuallyLookingAt, Out.Mode.Debug);
|
||||
if (dist > 4 && Baritone.currentPath == null) {
|
||||
Baritone.findPathInNewThread(playerFeet, true);
|
||||
}
|
||||
if (dist <= 4) {
|
||||
AxisAlignedBB lol = target.getEntityBoundingBox();
|
||||
switchtosword();
|
||||
boolean direction = LookManager.lookAtCoords((lol.minX + lol.maxX) / 2, (lol.minY + lol.maxY) / 2, (lol.minZ + lol.maxZ) / 2, true);
|
||||
if (direction && !actuallyLookingAt) {
|
||||
Baritone.findPathInNewThread(playerFeet, false);
|
||||
}
|
||||
}
|
||||
if (actuallyLookingAt) {
|
||||
MovementManager.isLeftClick = true;
|
||||
if (Baritone.tickNumber % 10 < 3) {
|
||||
MovementManager.isLeftClick = false;
|
||||
}
|
||||
tickPath = false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static double distFromMe(Entity a) {
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
double diffX = player.posX - a.posX;
|
||||
double diffY = player.posY - a.posY;
|
||||
double diffZ = player.posZ - a.posZ;
|
||||
return Math.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||
}
|
||||
public static boolean couldBeInCreative(EntityPlayer player) {
|
||||
if (player.capabilities.isCreativeMode || player.capabilities.allowFlying || player.capabilities.isFlying) {
|
||||
return true;
|
||||
}
|
||||
BlockPos inFeet = new BlockPos(player.posX, player.posY, player.posZ);
|
||||
BlockPos standingOn = inFeet.down();
|
||||
return isAir(standingOn) && isAir(standingOn.north()) && isAir(standingOn.south()) && isAir(standingOn.east()) && isAir(standingOn.west()) && isAir(standingOn.north().west()) && isAir(standingOn.north().east()) && isAir(standingOn.south().west()) && isAir(standingOn.south().east());
|
||||
}
|
||||
public static double dist(BlockPos a, BlockPos b) {
|
||||
int diffX = a.getX() - b.getX();
|
||||
int diffY = a.getY() - b.getY();
|
||||
int diffZ = a.getZ() - b.getZ();
|
||||
return Math.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||
}
|
||||
public static void switchtosword() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
float bestDamage = 0;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
item = new ItemStack(Item.getByNameOrId("minecraft:apple"));
|
||||
}
|
||||
if (item.getItem() instanceof ItemSword) {
|
||||
float damage = ((ItemSword) (item.getItem())).getDamageVsEntity();
|
||||
if (damage > bestDamage) {
|
||||
p.inventory.currentItem = i;
|
||||
bestDamage = damage;
|
||||
}
|
||||
}
|
||||
if (item.getItem() instanceof ItemAxe) {
|
||||
if (bestDamage == 0) {
|
||||
p.inventory.currentItem = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String killCommand(String name) {//TODO make this use Memory.playerLocationMemory
|
||||
BlockPos playerFeet = Minecraft.getMinecraft().player.getPosition0();
|
||||
if (name.length() > 2) {
|
||||
for (EntityPlayer pl : Minecraft.getMinecraft().world.playerEntities) {
|
||||
String blah = pl.getName().trim().toLowerCase();
|
||||
if (!blah.equals(Minecraft.getMinecraft().player.getName().trim().toLowerCase())) {
|
||||
Out.gui("Considering " + blah, Out.Mode.Debug);
|
||||
if (Combat.couldBeInCreative(pl)) {
|
||||
Out.gui("No, creative", Out.Mode.Minimal);
|
||||
continue;
|
||||
}
|
||||
if (blah.contains(name) || name.contains(blah)) {
|
||||
Combat.target = pl;
|
||||
Combat.wasTargetSetByMobHunt = false;
|
||||
BlockPos pos = new BlockPos(Combat.target.posX, Combat.target.posY, Combat.target.posZ);
|
||||
goal = new GoalTwoBlocks(pos);
|
||||
findPathInNewThread(playerFeet, false);
|
||||
return "Killing " + pl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Entity w = whatEntityAreYouLookingAt();
|
||||
if (w != null) {
|
||||
Combat.target = w;
|
||||
BlockPos pos = new BlockPos(Combat.target.posX, Combat.target.posY, Combat.target.posZ);
|
||||
goal = new GoalTwoBlocks(pos);
|
||||
Combat.wasTargetSetByMobHunt = false;
|
||||
findPathInNewThread(playerFeet, false);
|
||||
return "Killing " + w;
|
||||
}
|
||||
return "Couldn't find " + name;
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
target = null;
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
@Override
|
||||
protected boolean onEnabled(boolean enabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package baritone.movement;
|
||||
|
||||
import baritone.pathfinding.actions.Action;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.Out;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Parkour extends Manager {
|
||||
public static boolean preemptivejump() {
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
BlockPos playerFeet = thePlayer.getPosition0();
|
||||
EnumFacing dir = thePlayer.getHorizontalFacing();
|
||||
for (int height = 0; height < 3; height++) {
|
||||
BlockPos bp = playerFeet.offset(dir, 1).up(height);
|
||||
if (!Minecraft.getMinecraft().world.getBlockState(bp).getBlock().equals(Block.getBlockById(0))) {
|
||||
return Action.canWalkOn(playerFeet.offset(dir, 1));
|
||||
}
|
||||
}
|
||||
for (int height = 0; height < 3; height++) {
|
||||
BlockPos bp = playerFeet.offset(dir, 2).up(height);
|
||||
if (!Minecraft.getMinecraft().world.getBlockState(bp).getBlock().equals(Block.getBlockById(0))) {
|
||||
return Action.canWalkOn(playerFeet.offset(dir, 2));
|
||||
}
|
||||
}
|
||||
return Action.canWalkOn(playerFeet.offset(dir, 3));
|
||||
}
|
||||
public static void parkour() {
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
BlockPos playerFeet = thePlayer.getPosition0();
|
||||
BlockPos down = playerFeet.down();
|
||||
BlockPos prev = down.offset(thePlayer.getHorizontalFacing().getOpposite());
|
||||
boolean onAir = Minecraft.getMinecraft().world.getBlockState(down).getBlock().equals(Block.getBlockById(0));
|
||||
boolean jumpAnyway = preemptivejump();
|
||||
if (onAir || jumpAnyway) {
|
||||
if ((thePlayer.isSprinting() && !Minecraft.getMinecraft().world.getBlockState(prev).getBlock().equals(Block.getBlockById(0))) || !Minecraft.getMinecraft().world.getBlockState(playerFeet.offset(thePlayer.getHorizontalFacing())).getBlock().equals(Block.getBlockById(0))) {
|
||||
double distX = Math.abs(thePlayer.posX - (prev.getX() + 0.5));
|
||||
distX *= Math.abs(prev.getX() - down.getX());
|
||||
double distZ = Math.abs(thePlayer.posZ - (prev.getZ() + 0.5));
|
||||
distZ *= Math.abs(prev.getZ() - down.getZ());
|
||||
double dist = distX + distZ;
|
||||
thePlayer.rotationYaw = Math.round(thePlayer.rotationYaw / 90) * 90;
|
||||
if (dist > 0.7) {
|
||||
MovementManager.jumping = true;
|
||||
Out.gui("Parkour jumping!!!", Out.Mode.Standard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onTick() {
|
||||
parkour();
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
}
|
@ -112,7 +112,7 @@ public class Path {
|
||||
return best;
|
||||
}
|
||||
public void calculatePathPosition() {
|
||||
BlockPos playerFeet = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos playerFeet = Baritone.playerFeet;
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
if (playerFeet.equals(path.get(i))) {
|
||||
pathPosition = i;
|
||||
|
@ -102,6 +102,6 @@ public class ActionClimb extends ActionPlaceOrBreak {
|
||||
//once we are pointing the right way and moving, start jumping
|
||||
//this is slightly more efficient because otherwise we might start jumping before moving, and fall down without moving onto the block we want to jump onto
|
||||
//also wait until we are close enough, because we might jump and hit our head on an adjacent block
|
||||
return Minecraft.getMinecraft().player.getPosition0().equals(to);
|
||||
return Baritone.playerFeet.equals(to);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ public class ActionDescend extends ActionPlaceOrBreak {
|
||||
@Override
|
||||
protected boolean tick0() {//basically just hold down W until we are where we want to be
|
||||
MovementManager.moveTowardsBlock(to);
|
||||
return Minecraft.getMinecraft().player.getPosition0().equals(to);
|
||||
return Baritone.playerFeet.equals(to);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,6 @@ public class ActionDescendThree extends ActionPlaceOrBreak {
|
||||
@Override
|
||||
protected boolean tick0() {//basically just hold down W until we are where we want to be
|
||||
MovementManager.moveTowardsBlock(to);
|
||||
return Minecraft.getMinecraft().player.getPosition0().equals(to);
|
||||
return Baritone.playerFeet.equals(to);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,6 @@ public class ActionDescendTwo extends ActionPlaceOrBreak {
|
||||
@Override
|
||||
protected boolean tick0() {//basically just hold down W until we are where we want to be
|
||||
MovementManager.moveTowardsBlock(to);
|
||||
return Minecraft.getMinecraft().player.getPosition0().equals(to);
|
||||
return Baritone.playerFeet.equals(to);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ActionFall extends ActionPlaceOrBreak {
|
||||
if (numTicks > 10) {
|
||||
MovementManager.moveTowardsBlock(to);
|
||||
}
|
||||
return Minecraft.getMinecraft().player.getPosition0().equals(to);
|
||||
return Baritone.playerFeet.equals(to);
|
||||
}
|
||||
@Override
|
||||
protected double calculateCost(ToolSet ts) {
|
||||
|
@ -43,7 +43,7 @@ public class ActionWalkDiagonal extends ActionPlaceOrBreak {
|
||||
if (MovementManager.forward && !MovementManager.backward) {
|
||||
Minecraft.getMinecraft().player.setSprinting(true);
|
||||
}
|
||||
return to.equals(Minecraft.getMinecraft().player.getPosition0());
|
||||
return to.equals(Baritone.playerFeet);
|
||||
}
|
||||
@Override
|
||||
protected double calculateCost(ToolSet ts) {
|
||||
|
@ -19,7 +19,7 @@ public class GoalGetToBlock extends GoalComposite{
|
||||
super(ajacentBlocks(goalPos = pos));
|
||||
}
|
||||
public GoalGetToBlock(){
|
||||
this(Minecraft.getMinecraft().player.getPosition0());
|
||||
this(Baritone.playerFeet);
|
||||
}
|
||||
public static BlockPos[] ajacentBlocks(BlockPos pos){
|
||||
BlockPos[] sides = new BlockPos[6];
|
||||
|
@ -342,12 +342,12 @@ public class ChatCommand {
|
||||
}
|
||||
public static String printtag(String message) throws IOException {
|
||||
Schematic sch = SchematicLoader.getLoader().loadFromFile(new File("/Users/galdara/Downloads/schematics/Bakery.schematic"));
|
||||
Baritone.currentBuilder = new SchematicBuilder(sch, Minecraft.getMinecraft().player.getPosition0());
|
||||
Baritone.currentBuilder = new SchematicBuilder(sch, Baritone.playerFeet);
|
||||
return "printed schematic to console.";
|
||||
}
|
||||
public static String samplebuild(String message) {
|
||||
int size = 5;
|
||||
BlockPos pl = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos pl = Baritone.playerFeet;
|
||||
BlockPos center = new BlockPos(pl.getX() - size / 2, pl.getY(), pl.getZ());
|
||||
Baritone.currentBuilder = new SchematicBuilder(new Schematic(Block.getBlockFromName("dirt"), size), center);
|
||||
return "ok";
|
||||
@ -357,7 +357,7 @@ public class ChatCommand {
|
||||
return "haha. no.";
|
||||
}
|
||||
int size = 5;
|
||||
BlockPos pl = Minecraft.getMinecraft().player.getPosition0();
|
||||
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";
|
||||
|
@ -21,10 +21,10 @@ public class MCEdit extends Manager {
|
||||
static BlockPos pos1 = null;
|
||||
static BlockPos pos2 = null;
|
||||
public static String pos1(String s) {
|
||||
return "Pos 1: " + (pos1 = Minecraft.getMinecraft().player.getPosition0());
|
||||
return "Pos 1: " + (pos1 = Baritone.playerFeet);
|
||||
}
|
||||
public static String pos2(String s) {
|
||||
return "Pos 2: " + (pos2 = Minecraft.getMinecraft().player.getPosition0());
|
||||
return "Pos 2: " + (pos2 = Baritone.playerFeet);
|
||||
}
|
||||
public static String delete(String s) {
|
||||
Manager.getManager(MCEdit.class).toggle();
|
||||
|
@ -309,7 +309,7 @@ public class Memory extends Manager {
|
||||
for (Block block : blockMemory.keySet()) {
|
||||
blockMemory.get(block).recalcFurthest();
|
||||
}
|
||||
BlockPos playerFeet = Minecraft.getMinecraft().player.getPosition0();
|
||||
BlockPos playerFeet = Baritone.playerFeet;
|
||||
int X = playerFeet.getX();
|
||||
int Y = playerFeet.getY();
|
||||
int Z = playerFeet.getZ();
|
||||
@ -365,7 +365,7 @@ public class Memory extends Manager {
|
||||
for (String name : playerLocationMemory.keySet()) {
|
||||
if (name.contains(targetName) || targetName.contains(name)) {
|
||||
Baritone.goal = new GoalBlock(playerLocationMemory.get(name));
|
||||
findPathInNewThread(Minecraft.getMinecraft().player.getPosition0(), true);
|
||||
findPathInNewThread(Baritone.playerFeet, true);
|
||||
return "Pathing to " + name + " at " + goal;
|
||||
}
|
||||
}
|
||||
@ -375,7 +375,7 @@ public class Memory extends Manager {
|
||||
if (blah.contains(name) || name.contains(blah)) {
|
||||
BlockPos pos = new BlockPos(pl.posX, pl.posY, pl.posZ);
|
||||
goal = new GoalBlock(pos);
|
||||
findPathInNewThread(Minecraft.getMinecraft().player.getPosition0(), true);
|
||||
findPathInNewThread(Baritone.playerFeet, true);
|
||||
return "Pathing to " + pl.getName() + " at " + goal;
|
||||
}
|
||||
}*/
|
||||
|
Loading…
Reference in New Issue
Block a user