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;
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;
import net.minecraft.util.math.BlockPos;
@ -13,7 +8,7 @@ import net.minecraft.util.math.BlockPos;
*/
public class GoalBlock implements Goal {
final int x, y, z;
private final int x, y, z;
public GoalBlock(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ());
@ -25,10 +20,6 @@ public class GoalBlock implements Goal {
this.z = z;
}
public BlockPos pos() {
return new BlockPos(x, y, z);
}
@Override
public boolean isInGoal(BlockPos pos) {
return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z;
@ -47,6 +38,11 @@ public class GoalBlock implements Goal {
double zDiff = pos.getZ() - this.z;
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) {
double pythaDist = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
@ -69,9 +65,8 @@ public class GoalBlock implements Goal {
heuristic += GoalXZ.calculate(xDiff, zDiff, pythaDist);
return heuristic;
}
@Override
public String toString() {
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
public BlockPos getGoalPos() {
return new BlockPos(x, y, z);
}
}

View File

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