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;
|
package baritone.bot.pathing.goals;
|
||||||
|
|
||||||
import baritone.bot.pathing.actions.ActionCosts;
|
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;
|
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 + "}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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() {
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user