Clean up some goal constructors

This commit is contained in:
Brady 2018-08-01 21:50:48 -07:00
parent ef938304f0
commit 2e19023357
No known key found for this signature in database
GPG Key ID: 73A788379A197567
8 changed files with 11 additions and 54 deletions

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import baritone.bot.pathing.actions.ActionCosts; import baritone.bot.pathing.actions.ActionCosts;

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -13,7 +8,7 @@ import net.minecraft.util.math.BlockPos;
*/ */
public class GoalBlock implements Goal { public class GoalBlock implements Goal {
final int x, y, z; private final int x, y, z;
public GoalBlock(BlockPos pos) { public GoalBlock(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ()); this(pos.getX(), pos.getY(), pos.getZ());
@ -25,10 +20,6 @@ public class GoalBlock implements Goal {
this.z = z; this.z = z;
} }
public BlockPos pos() {
return new BlockPos(x, y, z);
}
@Override @Override
public boolean isInGoal(BlockPos pos) { public boolean isInGoal(BlockPos pos) {
return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z; return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z;
@ -48,6 +39,11 @@ public class GoalBlock implements Goal {
return calculate(xDiff, yDiff, zDiff); return calculate(xDiff, yDiff, zDiff);
} }
@Override
public String toString() {
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
}
public static double calculate(double xDiff, double yDiff, double zDiff) { public static double calculate(double xDiff, double yDiff, double zDiff) {
double pythaDist = Math.sqrt(xDiff * xDiff + zDiff * zDiff); double pythaDist = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
double heuristic = 0; double heuristic = 0;
@ -70,8 +66,7 @@ public class GoalBlock implements Goal {
return heuristic; return heuristic;
} }
@Override public BlockPos getGoalPos() {
public String toString() { return new BlockPos(x, y, z);
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
} }
} }

View File

@ -24,19 +24,11 @@ public class GoalComposite implements Goal {
} }
public GoalComposite(BlockPos... blocks) { public GoalComposite(BlockPos... blocks) {
goals = new Goal[blocks.length]; this(Arrays.asList(blocks));
for (int i = 0; i < blocks.length; i++) {
goals[i] = new GoalBlock(blocks[i]);
}
} }
public GoalComposite(Collection<BlockPos> blocks) { public GoalComposite(Collection<BlockPos> blocks) {
goals = new Goal[blocks.size()]; this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new));
int i = 0;
for (BlockPos pos : blocks) {
goals[i] = new GoalBlock(pos);
i++;
}
} }
public Goal[] goals() { public Goal[] goals() {

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import java.util.Arrays; import java.util.Arrays;

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View File

@ -1,8 +1,3 @@
/*
* 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.bot.pathing.goals; package baritone.bot.pathing.goals;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;