Skip to content

Commit

Permalink
Merge branch 'trunk' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Mar 27, 2023
2 parents 229d352 + e7e7607 commit f959ab7
Show file tree
Hide file tree
Showing 34 changed files with 647 additions and 301 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ public class PathExample extends JavaPlugin {
#### See the `pathetic-example` module for a more in-depth example plugin.

### Javadocs:
Access the Javadocs [here](http://patheticdocs.ollieee.xyz/)
Access the Javadocs [here](https://patheticdocs.ollieee.xyz/)
4 changes: 2 additions & 2 deletions pathetic-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>pathetic-main</artifactId>
<groupId>org.patheloper</groupId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>pathetic-api</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ public interface Path {
int length();

/**
* Interpolates the points of this Path using a spline algorithm
* Interpolates the positions of this Path to a new Path with the given resolution.
*
* @param nthBlock Will use every nth block of the path as a control point
* @param resolution The resolution of the interpolation (in blocks). The higher the resolution, the more points will be interpolated
* @return a newly created Path with interpolated points
* <p>The resulting path will have additional positions inserted between consecutive positions in the
* original path such that no two consecutive positions are more than `resolution` blocks apart.
* The interpolated positions are computed using linear interpolation, which means that the
* resulting path will have a smooth curve that passes through each of the original positions.
*
* @param resolution The desired distance between consecutive positions in the resulting path, in blocks.
* A lower value will result in a higher resolution and a smoother curve, but will also increase the
* number of positions in the resulting path and possibly reduce performance.
* @return a newly created Path with interpolated positions.
* @see #getPositions
*/
Path interpolate(int nthBlock, double resolution);

/**
* Enlarges the path by filling in the spaces between the points and adding new points in between based on the given resolution
* @param resolution The resolution of the enlargement (in blocks). The lower the resolution, the more points will be added
* between the existing points
*/
Path enlarge(double resolution);
Path interpolate(double resolution);

/**
* Joins this Path with the given Path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
* fallback - If pathfinding fails, it will fallback to the already found path.
*
* loadChunks - Whether to load / generate chunks
*
* postOptimization - Whether to run the post optimization algorithm
* NOTE: This can be very expensive
*
* counterCheck - Whether to run the counter check the path if it's not found to validate the result
* NOTE: counterCheck is a fallback mechanism which researches the entire path from end to beginning again
*/
@With
@Value
Expand Down Expand Up @@ -68,6 +74,8 @@ public static PathingRuleSet createRuleSet() {
boolean allowingFailFast;
boolean allowingFallback;
boolean loadingChunks;
boolean postOptimization;
boolean counterCheck;
}


Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ public PathPosition mid() {
return new PathPosition(this.pathEnvironment, this.getBlockX() + 0.5, this.getBlockY() + 0.5, this.getBlockZ() + 0.5);
}

public PathPosition midPoint(PathPosition end) {
return new PathPosition(this.pathEnvironment, (this.x + end.x) / 2, (this.y + end.y) / 2, (this.z + end.z) / 2);
}

/**
* Gets the {@link PathEnvironment} the position is in
*
Expand Down
2 changes: 1 addition & 1 deletion pathetic-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>org.patheloper</groupId>
<artifactId>pathetic-mapping</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public void onEnable() {
.withAllowingDiagonal(true)
.withAllowingFailFast(true)
.withAllowingFallback(true)
.withLoadingChunks(true));
.withLoadingChunks(true),
PatheticMapper.PathfinderType.ASTAR);

getCommand("pathetic").setExecutor(new PatheticCommand(reusablePathfinder));
}
Expand Down
6 changes: 3 additions & 3 deletions pathetic-mapping/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>pathetic-main</artifactId>
<groupId>org.patheloper</groupId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>pathetic-mapping</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>org.patheloper</groupId>
<artifactId>pathetic-model</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import org.patheloper.Pathetic;
import org.patheloper.api.pathing.Pathfinder;
import org.patheloper.api.pathing.rules.PathingRuleSet;
import org.patheloper.model.pathing.AStarPathfinder;
import org.patheloper.model.pathing.pathfinder.AStarPathfinder;
import org.patheloper.model.pathing.pathfinder.BidirectionalAStarPathfinder;

/**
* PatheticMapper is a utility class that maps the Pathetic API to the Pathetic Implementation.
Expand All @@ -24,30 +25,56 @@ public class PatheticMapper {
public void initialize(JavaPlugin javaPlugin) {
Pathetic.initialize(javaPlugin);
}

/**
* Instantiates a new pathfinder object.
*
* @param pathingRuleSet - The {@link PathingRuleSet}
* @return The {@link Pathfinder} object
* @throws IllegalStateException If the lib is not initialized yet
*/
public @NonNull Pathfinder newPathfinder() {
return newPathfinder(PathingRuleSet.createAsyncRuleSet());
}

/**
* Instantiates a new A*-pathfinder.
*
* @param pathingRuleSet - The {@link PathingRuleSet}
* @return The {@link Pathfinder}
* @throws IllegalStateException If the lib is not initialized yet
*/
public @NonNull Pathfinder newPathfinder(PathingRuleSet pathingRuleSet) {

if (Pathetic.isInitialized())
return new AStarPathfinder(pathingRuleSet);

throw new IllegalStateException("Pathetic is not initialized");
return newPathfinder(pathingRuleSet, PathfinderType.ASTAR);
}

/**
* Instantiates a new pathfinder object.
*
* @param pathingRuleSet - The {@link PathingRuleSet}
* @param pathfinderType - The {@link PathfinderType}
* @return The {@link Pathfinder} object
* @throws IllegalStateException If the lib is not initialized yet
*/
public @NonNull Pathfinder newPathfinder() {
return newPathfinder(PathingRuleSet.createAsyncRuleSet());
public @NonNull Pathfinder newPathfinder(PathingRuleSet pathingRuleSet, PathfinderType pathfinderType) {

if (Pathetic.isInitialized()) {
switch (pathfinderType) {
case ASTAR:
return new AStarPathfinder(pathingRuleSet);
case BIDIRECTIONAL_ASTAR:
return new BidirectionalAStarPathfinder(pathingRuleSet);
default:
throw new IllegalArgumentException("Unknown pathfinder type: " + pathfinderType);
}
}

throw new IllegalStateException("Pathetic is not initialized");
}

public enum PathfinderType {

ASTAR,
BIDIRECTIONAL_ASTAR
}

}
16 changes: 12 additions & 4 deletions pathetic-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>pathetic-main</artifactId>
<groupId>org.patheloper</groupId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>pathetic-model</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -33,6 +33,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -75,14 +83,14 @@
<dependency>
<groupId>org.patheloper</groupId>
<artifactId>pathetic-api</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.patheloper</groupId>
<artifactId>pathetic-nms</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Node implements Comparable<Node> {

private Node parent;

Node(PathPosition position, PathPosition start, PathPosition target, Integer depth) {
public Node(PathPosition position, PathPosition start, PathPosition target, Integer depth) {

this.position = position;
this.target = target;
Expand Down

This file was deleted.

Loading

0 comments on commit f959ab7

Please sign in to comment.