Giter Club home page Giter Club logo

pathetic's Introduction

Pathetic

Pathetic is a simple and intuitive backwards-compatible up-to-date pathfinding API for Spigot and forks. See more info here: https://www.spigotmc.org/threads/how-pathetic.578998/#post-4644823

How to import

Maven

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
 
	<dependency>
	    <groupId>com.github.patheloper.pathetic</groupId>
	    <artifactId>pathetic-mapping</artifactId>
	    <version>VERSION</version>
	</dependency>

Gradle

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
    
	dependencies {
	        implementation 'com.github.patheloper.pathetic:pathetic-mapping:VERSION'
	}

Example API Usage

public class PathExample extends JavaPlugin {

  @Override
  public void onEnable() {
    PatheticMapper.initialize(this);
    goFindSomePath(randomLocation(), randomLocation());
  }

  @Override
  public void onDisable() {
    PatheticMapper.shutdown();
  }

  private void goFindSomePath(PathPosition start, PathPosition end) {
    Pathfinder pathfinder = PatheticMapper.newPathfinder();
    pathfinder
        .findPath(start, end, new DirectPathfinderStrategy())
        .thenAccept(
            pathfinderResult ->
                pathfinderResult
                    .getPath()
                    .forEach(
                        location ->
                            player.sendBlockChange(
                                location, Material.YELLOW_STAINED_GLASS.createBlockData())));
  }

  private PathPosition randomLocation() {
    ThreadLocalRandom instance = ThreadLocalRandom.current();
    return new PathPosition(
        instance.nextInt(0, 100), instance.nextInt(0, 100), instance.nextInt(0, 100));
  }
}

See the pathetic-example module for a more in-depth example plugin.

Docs:

Access the Javadocs here Access our Docs here

pathetic's People

Contributors

aematsubara avatar andyreckt avatar blitzdose avatar dependabot[bot] avatar gabber235 avatar godcipher avatar likegeil avatar olijeffers0n avatar tapwatero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pathetic's Issues

NullpointerException occurs on calling findPath

RuleSet:

PathingRuleSet.createAsyncRuleSet()
                .withAllowingDiagonal(true)
                .withAllowingFallback(true)
                .withLoadingChunks(false)
                .withAllowingFailFast(true)
                .withStrategy(WalkablePathfinderStrategy::class.java)

Stacktrace:

[15:52:05 WARN]: [Waypoints] Task #12 for Waypoints v4.0.0-SNAPSHOT generated an exception
java.lang.NullPointerException: Cannot invoke "org.patheloper.api.wrapper.PathBlock.isPassable()" because "pathBlock" is null
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.isBlockUnreachable(AbstractPathfinder.java:121) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.initialChecksFailed(AbstractPathfinder.java:111) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at org.patheloper.model.pathing.pathfinder.AbstractPathfinder.findPath(AbstractPathfinder.java:76) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at org.patheloper.model.pathing.pathfinder.AStarPathfinder.findPath(AStarPathfinder.java:23) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at de.md5lukas.waypoints.pointers.variants.TrailPointer.update(TrailPointer.kt:90) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at de.md5lukas.waypoints.pointers.Pointer.show(Pointer.kt:19) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at de.md5lukas.waypoints.pointers.ManagedPlayer$PlayerPointer.run(ManagedPlayer.kt:133) ~[waypoints-4.0.0-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.4.jar:git-Paper-538]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.4.jar:git-Paper-538]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1483) ~[paper-1.19.4.jar:git-Paper-538]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.19.4.jar:git-Paper-538]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.4.jar:git-Paper-538]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1174) ~[paper-1.19.4.jar:git-Paper-538]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-538]

Both start and stop are < 30 blocks apart and start is the players current position.

It doesn't matter if both blocks are air or set.

It seems to me the FailingSnapshotManager never retrieves chunk snapshots instead of only if they are loaded (as I would expect from the description in the JavaDoc https://patheticdocs.ollieee.xyz/org/patheloper/api/pathing/rules/PathingRuleSet.html)

(And just out of curiosity, why is NMS used to retrieve the ChunkSnapshots and not the Bukkit API?)

fix diagonal offset behaviour

allowingDiagonal is skipping blocks which therefore can't be processed by the strategy. means a path can go through walls ignoring the strategy etc.

The FailingSnapshotManager leaks memory

The cached chunks in the FailingSnapshotManager.SNAPSHOTS_MAP are only invalidated on block changes but otherwise never discarded.

If a player wanders around the world with constant path finding a lot of ChunkSnapshots accumulate and are never discarded.

Problem with install

Stack trace

Error occurred while disabling buplugin v1.0-SNAPSHOT
java.lang.NoClassDefFoundError: org/patheloper/mapping/PatheticMapper
        at dev.com.buskopan.buplugin.Buplugin.onDisable(Buplugin.java:84) ~[buplugin-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:290) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugin(PaperPluginInstanceManager.java:223) ~[paper-1.20.4.jar:git-Paper-454]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.disablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.4.jar:git-Paper-454]
        at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:537) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:192) ~[paper-1.20.4.jar:git-Paper-454]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-454]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:639) ~[paper-1.20.4.jar:git-Paper-454]
        at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:550) ~[paper-1.20.4.jar:git-Paper-454]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:671) ~[paper-1.20.4.jar:git-Paper-454]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.20.4.jar:git-Paper-454]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:309) ~[paper-1.20.4.jar:git-Paper-454]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1131) ~[paper-1.20.4.jar:git-Paper-454]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-454]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.ClassNotFoundException: org.patheloper.mapping.PatheticMapper
        ... 16 more

Actions to reproduce (if known)

No response

Other

This is my build.gradle:

    id 'java'
}

group = 'dev.com.buskopan'
version = '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven {
        name = "papermc-repo"
        url = "https://repo.papermc.io/repository/maven-public/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
    maven {
        name = "jitpack.io"
        url = 'https://jitpack.io' }
}

jar {
    destinationDirectory.set(file("C:/Users/Andre/Desktop/Server/plugins"))
}

dependencies {
    compileOnly "io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT"
    implementation 'com.github.patheloper.pathetic:pathetic-mapping:2.4'
}

def targetJavaVersion = 21
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'

    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release.set(targetJavaVersion)
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}

Mapping was not publish to maven

Trying to use this on 1.19.4 and your mapping is not published for version 2.1.1, only the api is listed but I need the mapping version

Simplifying the path finding result

I was wondering if it was possible that when a path is moving in a straight line, if there could be an option for a 'simple' version. IE: if Point A, Point B, Point C, Point D all go in the same direction diagonal, we don't really need point B / C if we are trying to use velocity to move an object, we only need a and d, so is is possible to have an option that only gives us A/D?

Block state / Material access

Is your feature request related to a problem?

It's not really possible to check for block states when checking for blocks in the pathfinding strategy (e.g. pathfind only on trapdoors if they are closed)

Describe the solution you'd like.

Having access to the block state or at least the material of the block in PathBlock

Describe alternatives you've considered.

Querying the block myself. But I think that would be pretty inefficient.

Other

There is probably a reason this doesn't exist. I haven't looked into how pathetic is built, but maybe it is because of performance memory management reasons. However, without this, implementing more complex strategies is not really possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.