don't allocate for up(0)
This commit is contained in:
parent
86f1f472f5
commit
3a68009194
@ -19,16 +19,12 @@ package baritone.bot.behavior.impl;
|
||||
|
||||
import baritone.bot.Baritone;
|
||||
import baritone.bot.behavior.Behavior;
|
||||
import baritone.bot.event.events.ChatEvent;
|
||||
import baritone.bot.event.events.RenderEvent;
|
||||
import baritone.bot.event.events.TickEvent;
|
||||
import baritone.bot.pathing.calc.AStarPathFinder;
|
||||
import baritone.bot.pathing.calc.AbstractNodeCostSearch;
|
||||
import baritone.bot.pathing.calc.IPathFinder;
|
||||
import baritone.bot.pathing.goals.Goal;
|
||||
import baritone.bot.pathing.goals.GoalBlock;
|
||||
import baritone.bot.pathing.goals.GoalXZ;
|
||||
import baritone.bot.pathing.goals.GoalYLevel;
|
||||
import baritone.bot.pathing.path.IPath;
|
||||
import baritone.bot.pathing.path.PathExecutor;
|
||||
import baritone.bot.utils.PathRenderer;
|
||||
|
@ -18,7 +18,6 @@
|
||||
package baritone.bot.event.events;
|
||||
|
||||
import baritone.bot.event.events.type.EventState;
|
||||
import javafx.event.EventType;
|
||||
|
||||
public final class TickEvent {
|
||||
|
||||
|
@ -88,7 +88,6 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
*
|
||||
* @param n A node
|
||||
* @return The distance, squared
|
||||
* @see AbstractNodeCostSearch#getDistFromStart(PathNode)
|
||||
*/
|
||||
protected double getDistFromStartSq(PathNode n) {
|
||||
int xDiff = n.pos.getX() - start.getX();
|
||||
@ -97,16 +96,6 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
|
||||
return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the distance from the specified node to this the node.
|
||||
*
|
||||
* @param n A node
|
||||
* @return The distance
|
||||
*/
|
||||
protected double getDistFromStart(PathNode n) {
|
||||
return Math.sqrt(getDistFromStartSq(n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to search the {@link BlockPos} to {@link PathNode} map
|
||||
* for the node mapped to the specified pos. If no node is found,
|
||||
|
@ -211,8 +211,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
static MovementState moveTowards(MovementState state, BlockPos pos) {
|
||||
return state.setTarget(new MovementTarget(new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||
static void moveTowards(MovementState state, BlockPos pos) {
|
||||
state.setTarget(new MovementTarget(new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||
Utils.getBlockPosCenter(pos),
|
||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getFirst(), mc.player.rotationPitch))
|
||||
).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||
|
@ -114,17 +114,17 @@ public class MovementAscend extends Movement {
|
||||
}
|
||||
|
||||
if (!MovementHelper.canWalkOn(positionsToPlace[0])) {
|
||||
for (int i = 0; i < against.length; i++) {
|
||||
if (BlockStateInterface.get(against[i]).isBlockNormalCube()) {
|
||||
for (BlockPos anAgainst : against) {
|
||||
if (BlockStateInterface.get(anAgainst).isBlockNormalCube()) {
|
||||
if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block
|
||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||
}
|
||||
double faceX = (dest.getX() + against[i].getX() + 1.0D) * 0.5D;
|
||||
double faceY = (dest.getY() + against[i].getY()) * 0.5D;
|
||||
double faceZ = (dest.getZ() + against[i].getZ() + 1.0D) * 0.5D;
|
||||
double faceX = (dest.getX() + anAgainst.getX() + 1.0D) * 0.5D;
|
||||
double faceY = (dest.getY() + anAgainst.getY()) * 0.5D;
|
||||
double faceZ = (dest.getZ() + anAgainst.getZ() + 1.0D) * 0.5D;
|
||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations())));
|
||||
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against[i]) && LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
|
||||
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), anAgainst) && LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
|
||||
ticksWithoutPlacement++;
|
||||
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
||||
if (player().isSneaking()) {
|
||||
@ -134,7 +134,7 @@ public class MovementAscend extends Movement {
|
||||
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);//we might be standing in the way, move back
|
||||
}
|
||||
}
|
||||
System.out.println("Trying to look at " + against[i] + ", actually looking at" + LookBehaviorUtils.getSelectedBlock());
|
||||
System.out.println("Trying to look at " + anAgainst + ", actually looking at" + LookBehaviorUtils.getSelectedBlock());
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiNewChat;
|
||||
import net.minecraft.client.gui.GuiUtilRenderComponents;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -50,11 +49,10 @@ public interface Helper {
|
||||
|
||||
default BlockPos playerFeet() {
|
||||
// TODO find a better way to deal with soul sand!!!!!
|
||||
BlockPos feet = new BlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
return new BlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
/*if (BlockStateInterface.get(feet).getBlock().equals(Blocks.SOUL_SAND) && player().posY > feet.getY() + 0.874999) {
|
||||
return feet.up();
|
||||
}*/
|
||||
return feet;
|
||||
}
|
||||
|
||||
default Vec3d playerFeetAsVec() {
|
||||
|
@ -21,7 +21,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAir;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -125,7 +124,7 @@ public class ToolSet implements Helper {
|
||||
* Using the best tool on the hotbar, how long would it take to mine this block
|
||||
*
|
||||
* @param state the blockstate to be mined
|
||||
* @param pos the blockpos to be mined
|
||||
* @param pos the blockpos to be mined
|
||||
* @return how long it would take in ticks
|
||||
*/
|
||||
public double getStrVsBlock(IBlockState state, BlockPos pos) {
|
||||
|
@ -92,7 +92,7 @@ public class BetterBlockPos extends BlockPos {
|
||||
@Override
|
||||
public BlockPos up(int amt) {
|
||||
// see comment in up()
|
||||
return new BetterBlockPos(x, y + amt, z);
|
||||
return amt == 0 ? this : new BetterBlockPos(x, y + amt, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user