Clean up some goal constructors
This commit is contained in:
parent
ef938304f0
commit
2e19023357
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user