From ea6f053bab6f1692a6b8a39b330475fb04857660 Mon Sep 17 00:00:00 2001 From: ysl3000 Date: Wed, 11 Dec 2019 02:17:16 +0100 Subject: [PATCH] task: update to 1.15 removed deprecated methods and those that weren't right --- .../bukkit/pathfinding/entity/Insentient.kt | 73 ---- .../goals/PathfinderGoalGimmiCookie.kt | 2 +- .../goals/PathfinderGoalMoveToLocation.kt | 2 +- .../notworking/PathfinderGoalFollowEntity.kt | 2 +- .../PathfinderGoalReturnToLocation.kt | 2 +- .../notworking/PathfinderGoalSteerEntity.kt | 5 +- .../PathfinderGoalWalkToSteakAndEat.kt | 2 +- .../pathfinding/pathfinding/ControllerJump.kt | 14 - .../pathfinding/pathfinding/ControllerLook.kt | 91 ----- .../pathfinding/pathfinding/ControllerMove.kt | 13 - .../pathfinding/PathfinderManager.kt | 9 - PathfinderPlugin/pom.xml | 7 +- .../pathfinding/PathfinderGoalPlugin.kt | 2 +- .../bukkit/test/PathfinderTestPlugin.kt | 8 +- .../bukkit/test/PathfinderTestPlugin.java | 8 +- .../v1_12_R1/entity/CraftInsentient.kt | 138 ------- .../pathfinding/CraftPathfinderManager.kt | 2 - Pathfinder_1_13/pom.xml | 57 --- .../v1_13_R1/entity/CraftInsentient.kt | 378 ------------------ .../v1_13_R1/pathfinding/CraftNavigation.kt | 17 - .../pathfinding/CraftPathfinderPlayer.kt | 28 -- .../v1_13_R2/entity/CraftInsentient.kt | 87 ---- .../pathfinding/CraftPathfinderManager.kt | 2 - .../v1_14_R1/entity/CraftInsentient.kt | 89 +---- .../pathfinding/CraftPathfinderManager.kt | 2 - Pathfinder_1_15/pom.xml | 60 +++ .../v1_15_R1/entity/CraftInsentient.kt | 156 ++++++++ .../v1_15_R1/pathfinding/CraftNavigation.kt | 18 + .../pathfinding/CraftPathfinderGoalWrapper.kt | 16 +- .../pathfinding/CraftPathfinderManager.kt | 9 +- .../pathfinding/CraftPathfinderPlayer.kt | 25 ++ pom.xml | 2 +- 32 files changed, 289 insertions(+), 1037 deletions(-) delete mode 100644 PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerJump.kt delete mode 100644 PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerLook.kt delete mode 100644 PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerMove.kt delete mode 100644 Pathfinder_1_13/pom.xml delete mode 100644 Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/entity/CraftInsentient.kt delete mode 100644 Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftNavigation.kt delete mode 100644 Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderPlayer.kt create mode 100644 Pathfinder_1_15/pom.xml create mode 100644 Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/entity/CraftInsentient.kt create mode 100644 Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftNavigation.kt rename {Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1 => Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1}/pathfinding/CraftPathfinderGoalWrapper.kt (71%) rename {Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1 => Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1}/pathfinding/CraftPathfinderManager.kt (81%) create mode 100644 Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderPlayer.kt diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/entity/Insentient.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/entity/Insentient.kt index bafbb9b..b000516 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/entity/Insentient.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/entity/Insentient.kt @@ -14,43 +14,6 @@ interface Insentient { fun getLookingAt(): Location - /** - * Will return the PathfinderGoalTargetSelector - * - * @return targetSelector - */ - @Deprecated("") - fun getTargetSelector(): PathfinderGoalSelector - - /** - * Will return the PathfinderGoalSelector - * - * @return selector - */ - @Deprecated("") - fun getGoalSelector(): PathfinderGoalSelector - - /** - * Get the ControllerJump for jumping - * - * @return controllerJump to let the entity jump - */ - fun getControllerJump(): ControllerJump - - /** - * Get the ControllerLook for looking - * - * @return controllerLook to let the entity look at a target - */ - fun getControllerLook(): ControllerLook - - - /** - * Get the controllerMove direct movement - * - * @return controllerMove to move the entity directly - */ - fun getControllerMove(): ControllerMove /** * Get the Navigation for moving Entity @@ -67,21 +30,6 @@ interface Insentient { */ fun getHeadHeight(): Float - - /** - * Will return the entities default yaw - * - * @return yaw - */ - fun getDefaultYaw(): Int - - /** - * Will return the entities default pitch - * - * @return pitch - */ - fun getDefaultPitch(): Int - /** * Will return the LivingEntity of Bukkit * @@ -150,27 +98,6 @@ interface Insentient { fun onEntityKill(livingEntity: LivingEntity) - /** - * @param motionX relative motionX - * @param motionY relative motionY - * @param motionZ relative motionZ - */ - @Deprecated("use {@link Insentient#setMovementDirection(Vector, double)} Will move the Entity\n" + - " relative") - fun moveRelative(motionX: Double, motionY: Double, motionZ: Double) - - - /** - * @param motionX relative motionX - * @param motionY relative motionY - * @param motionZ relative motionZ - * @param speed the speed multiplier - */ - @Deprecated("use {@link Insentient#setMovementDirection(Vector, double)} Will move the Entity\n" + - " relative") - fun moveRelative(motionX: Double, motionY: Double, motionZ: Double, speed: Double) - - /** * Rotates the entity * diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalGimmiCookie.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalGimmiCookie.kt index 43e36d0..b56afc7 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalGimmiCookie.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalGimmiCookie.kt @@ -47,7 +47,7 @@ class PathfinderGoalGimmiCookie(private val pathfinderGoalEntity: Insentient, pr } override fun execute() { - this.pathfinderGoalEntity.getControllerJump().jump() + this.pathfinderGoalEntity.jump() if (creature.location.distanceSquared(nearestPlayer!!.location) <= 1) { this.creature.world.dropItem(nearestPlayer!!.location, COOKIE) this.creature.equipment?.setItemInMainHand(null) diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalMoveToLocation.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalMoveToLocation.kt index bfeb75e..3a9025c 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalMoveToLocation.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/PathfinderGoalMoveToLocation.kt @@ -35,7 +35,7 @@ class PathfinderGoalMoveToLocation(private val pathfinderGoalEntity: Insentient, override fun execute() { if (pathfinderGoalEntity.getBukkitEntity().location.add(pathfinderGoalEntity.getBukkitEntity().location.direction.normalize()) .block.type != Material.AIR) { - pathfinderGoalEntity.getControllerJump().jump() + pathfinderGoalEntity.jump() } } diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalFollowEntity.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalFollowEntity.kt index 096f1eb..07139b7 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalFollowEntity.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalFollowEntity.kt @@ -38,7 +38,7 @@ class PathfinderGoalFollowEntity(private val pathfinderGoalEntity: Insentient, p if (pathfinderGoalEntity.getBukkitEntity().location .add(pathfinderGoalEntity.getBukkitEntity().location.direction.normalize()) .block.type != Material.AIR) { - this.pathfinderGoalEntity.getControllerJump().jump() + this.pathfinderGoalEntity.jump() } } diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalReturnToLocation.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalReturnToLocation.kt index 430a9be..da10e99 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalReturnToLocation.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalReturnToLocation.kt @@ -31,7 +31,7 @@ class PathfinderGoalReturnToLocation(private val pathfinderGoalEntity: Insentien } override fun execute() { - this.pathfinderGoalEntity.getControllerJump().jump() + this.pathfinderGoalEntity.jump() } diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalSteerEntity.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalSteerEntity.kt index bf34243..eced79c 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalSteerEntity.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalSteerEntity.kt @@ -48,11 +48,10 @@ class PathfinderGoalSteerEntity(private val pathfinderManager: PathfinderManager if (blockInDirection.block.type.isSolid && !blockInDirection.add(0.0, 1.0, 0.0).block .type.isSolid) { - pathfinderGoalEntity.getControllerJump().jump() + pathfinderGoalEntity.jump() } - this.pathfinderGoalEntity.getControllerMove() - .move(pathfinderPlayer!!.getMotionForward(), pathfinderPlayer!!.getMotionSideward()) + this.pathfinderGoalEntity.setStrafeDirection(pathfinderPlayer!!.getMotionForward(), pathfinderPlayer!!.getMotionSideward()) val location = player.location this.pathfinderGoalEntity.setRotation(location.yaw, location.yaw) diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalWalkToSteakAndEat.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalWalkToSteakAndEat.kt index 7442df0..e09c56b 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalWalkToSteakAndEat.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/goals/notworking/PathfinderGoalWalkToSteakAndEat.kt @@ -51,7 +51,7 @@ class PathfinderGoalWalkToSteakAndEat(private val pathfinderGoalEntity: Insentie */ override fun execute() { pathfinderGoalEntity.getNavigation().moveTo(target!!, 2.0) - pathfinderGoalEntity.getControllerJump().jump() + pathfinderGoalEntity.jump() } diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerJump.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerJump.kt deleted file mode 100644 index b6b76d4..0000000 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerJump.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.pathfinding - -/** - * Use - * - */ -@Deprecated("{{@link Insentient#jump()}} Created by Yannick on 30.11.2016.") -interface ControllerJump { - - /** - * Lets the entity jump - */ - fun jump() -} \ No newline at end of file diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerLook.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerLook.kt deleted file mode 100644 index 6143214..0000000 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerLook.kt +++ /dev/null @@ -1,91 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.pathfinding - -import org.bukkit.Location -import org.bukkit.entity.Entity - - -@Deprecated("{{@link com.github.ysl3000.bukkit.pathfinding.entity.Insentient}} Created by Yannick\n" + - " on 30.11.2016.") -interface ControllerLook { - - /** - * Checks if the looking is reset - * - * @return if looking is default - */ - @Deprecated("") - fun isReset(): Boolean - - /** - * Use - * - * @return x-location - */ - @Deprecated("{{@link Insentient#getLookingAt()}}\n" + - " \n" + - " Gets the X-Location the entity is looking to") - fun getLocationX(): Double - - /** - * Use - * - * @return y-location - */ - @Deprecated("{{@link Insentient#getLookingAt()}}\n" + - " \n" + - " Gets the Y-Location the entity is looking to") - fun getLocationY(): Double - - /** - * Use - * - * @return z-location - */ - @Deprecated("{{@link Insentient#getLookingAt()}}\n" + - " \n" + - " Gets the Z-Location the entity is looking to") - fun getLocationZ(): Double - - /** - * * Use - * - * @param x x-location - * @param y y-location - * @param z z-location - * @param pitch head rotation pitch - * @param yaw head rotation yaw - */ - @Deprecated("{{@link com.github.ysl3000.bukkit.pathfinding.entity.Insentient#lookAt(Location)}}\n" + - " \n" + - " The entity will look to the given coordinates") - fun lookAt(x: Double, y: Double, z: Double, yaw: Float, pitch: Float) - - /** - * Use - * - * @param location the entity should look to - */ - @Deprecated("{{@link com.github.ysl3000.bukkit.pathfinding.entity.Insentient#lookAt(Location)}}\n" + - " \n" + - " The entity will look to the given location") - fun lookAt(location: Location) - - /** - * Use - * - * @param entity the entity which is targeted with eyes - * @param pitch head rotation pitch - * @param yaw head rotation yaw - */ - @Deprecated("{{@link com.github.ysl3000.bukkit.pathfinding.entity.Insentient#lookAt(Entity)}}\n" + - " The entity will look to the given entity") - fun lookAt(entity: Entity, yaw: Float, pitch: Float) - - /** - * Resets the current looking - */ - @Deprecated("") - fun reset() - - -} \ No newline at end of file diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerMove.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerMove.kt deleted file mode 100644 index 5dc3dfd..0000000 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/ControllerMove.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.pathfinding - -@Deprecated("") -interface ControllerMove { - fun move(motionX: Double, motionY: Double, motionZ: Double, speed: Double) - fun move(forward: Float, sideward: Float) - fun update() - fun getX(): Double - fun getY(): Double - fun getZ(): Double - fun getSpeed(): Double - fun isOperationMove(): Boolean -} diff --git a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/PathfinderManager.kt b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/PathfinderManager.kt index 849206d..4fa9e54 100644 --- a/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/PathfinderManager.kt +++ b/PathfinderAPI/src/main/java/com/github/ysl3000/bukkit/pathfinding/pathfinding/PathfinderManager.kt @@ -8,15 +8,6 @@ import org.bukkit.entity.* */ interface PathfinderManager { - /** - * Returns a pathfinderGoalEntity from creature - * - * @param creature entity you want to get the PathfinderGoalEntity - * @return pathfinderGoalEntity the entity you can apply pathfindergoals on to - */ - @Deprecated("Forgot r of pathfinder") - fun getPathfindeGoalEntity(creature: Creature): Insentient - /** * Returns a pathfinderGoalEntity from creature * diff --git a/PathfinderPlugin/pom.xml b/PathfinderPlugin/pom.xml index 4f60763..83cdde2 100644 --- a/PathfinderPlugin/pom.xml +++ b/PathfinderPlugin/pom.xml @@ -90,20 +90,21 @@ - Pathfinder_1_13 + Pathfinder_1_13_2 com.github.ysl3000.pathfindergoalapi compile ${project.parent.version} + - Pathfinder_1_13_2 + Pathfinder_1_14 com.github.ysl3000.pathfindergoalapi compile ${project.parent.version} - Pathfinder_1_14 + Pathfinder_1_15 com.github.ysl3000.pathfindergoalapi compile ${project.parent.version} diff --git a/PathfinderPlugin/src/main/java/com/github/ysl3000/bukkit/pathfinding/PathfinderGoalPlugin.kt b/PathfinderPlugin/src/main/java/com/github/ysl3000/bukkit/pathfinding/PathfinderGoalPlugin.kt index 44cfbd2..de27c3a 100644 --- a/PathfinderPlugin/src/main/java/com/github/ysl3000/bukkit/pathfinding/PathfinderGoalPlugin.kt +++ b/PathfinderPlugin/src/main/java/com/github/ysl3000/bukkit/pathfinding/PathfinderGoalPlugin.kt @@ -22,9 +22,9 @@ class PathfinderGoalPlugin : JavaPlugin() { when (version) { "v1_12_R1" -> this.craftPathfinderManager = com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_12_R1.pathfinding.CraftPathfinderManager() - "v1_13_R1" -> this.craftPathfinderManager = com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding.CraftPathfinderManager() "v1_13_R2" -> this.craftPathfinderManager = com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R2.pathfinding.CraftPathfinderManager() "v1_14_R1" -> this.craftPathfinderManager = com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_14_R1.pathfinding.CraftPathfinderManager() + "v1_15_R1" -> this.craftPathfinderManager = com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding.CraftPathfinderManager() else -> { println("This version of Minecraft is not supported") diff --git a/PathfinderTestPlugin/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.kt b/PathfinderTestPlugin/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.kt index cb87c67..790d95c 100644 --- a/PathfinderTestPlugin/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.kt +++ b/PathfinderTestPlugin/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.kt @@ -77,7 +77,7 @@ class PathfinderTestPlugin : JavaPlugin(), Listener { private fun chatCommand(p: Player, args: List): Boolean { val creature = p.world.spawn(p.location, Zombie::class.java) - val pathfinderGoalEntity = this.pathfinderManager?.getPathfindeGoalEntity(creature) + val pathfinderGoalEntity = this.pathfinderManager?.getPathfinderGoalEntity(creature) clear(pathfinderGoalEntity) pathfinderGoalEntity?.let { insentient: Insentient -> { @@ -94,7 +94,7 @@ class PathfinderTestPlugin : JavaPlugin(), Listener { val creature = p.world .spawn(Location(p.world, 235.0, 70.0, 246.0), Zombie::class.java) - val pathfinderGoalEntity = this.pathfinderManager?.getPathfindeGoalEntity(creature) + val pathfinderGoalEntity = this.pathfinderManager?.getPathfinderGoalEntity(creature) clear(pathfinderGoalEntity) pathfinderGoalEntity?.addPathfinderGoal(0, PathfinderGoalGimmiCookie(pathfinderGoalEntity, creature)) return true @@ -104,7 +104,7 @@ class PathfinderTestPlugin : JavaPlugin(), Listener { private fun moveToLocationCommand(p: Player, args: List): Boolean { val creature = p.world.spawn(p.location, Zombie::class.java) - val pathfinderGoalEntity = this.pathfinderManager?.getPathfindeGoalEntity(creature) + val pathfinderGoalEntity = this.pathfinderManager?.getPathfinderGoalEntity(creature) clear(pathfinderGoalEntity) pathfinderGoalEntity?.addPathfinderGoal(0, @@ -118,7 +118,7 @@ class PathfinderTestPlugin : JavaPlugin(), Listener { private fun printGoalCommand(p: Player, args: List): Boolean { val creature = p.world.spawn(p.location, Zombie::class.java) - val pathfinderGoalEntity = this.pathfinderManager?.getPathfindeGoalEntity(creature) + val pathfinderGoalEntity = this.pathfinderManager?.getPathfinderGoalEntity(creature) clear(pathfinderGoalEntity) pathfinderGoalEntity?.addPathfinderGoal(0, PathfinderGoalPrint() diff --git a/PathfinderTestPluginJava/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.java b/PathfinderTestPluginJava/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.java index 8c17d4b..d1ce42d 100644 --- a/PathfinderTestPluginJava/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.java +++ b/PathfinderTestPluginJava/src/main/java/com/github/ysl3000/bukkit/test/PathfinderTestPlugin.java @@ -77,7 +77,7 @@ private class Chat implements ICommand { public boolean execute(Player p, List args) { Creature creature = p.getWorld().spawn(p.getLocation(), Zombie.class); - Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfindeGoalEntity(creature); + Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfinderGoalEntity(creature); pathfinderGoalEntity.clearPathfinderGoals(); pathfinderGoalEntity.clearTargetPathfinderGoals(); @@ -100,7 +100,7 @@ public boolean execute(Player p, List args) { Creature creature = p.getWorld() .spawn(new Location(p.getWorld(), 235.0, 70.0, 246.0), Zombie.class); - Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfindeGoalEntity(creature); + Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfinderGoalEntity(creature); pathfinderGoalEntity.clearPathfinderGoals(); pathfinderGoalEntity.clearTargetPathfinderGoals(); @@ -124,7 +124,7 @@ private MoveToLocation(PathfinderManager pathfinderManager) { public boolean execute(Player p, List args) { Creature creature = p.getWorld().spawn(p.getLocation(), Zombie.class); - Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfindeGoalEntity(creature); + Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfinderGoalEntity(creature); pathfinderGoalEntity.clearPathfinderGoals(); pathfinderGoalEntity.clearTargetPathfinderGoals(); pathfinderGoalEntity.addPathfinderGoal(0, @@ -148,7 +148,7 @@ private PrintGoal(PathfinderManager pathfinderManager) { public boolean execute(Player p, List atgs) { Creature creature = p.getWorld().spawn(p.getLocation(), Zombie.class); - Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfindeGoalEntity(creature); + Insentient pathfinderGoalEntity = this.pathfinderManager.getPathfinderGoalEntity(creature); pathfinderGoalEntity.clearPathfinderGoals(); pathfinderGoalEntity.clearTargetPathfinderGoals(); pathfinderGoalEntity.addPathfinderGoal(0, diff --git a/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/entity/CraftInsentient.kt b/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/entity/CraftInsentient.kt index 971e904..58c9ef5 100644 --- a/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/entity/CraftInsentient.kt +++ b/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/entity/CraftInsentient.kt @@ -23,22 +23,8 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) override fun getLookingAt(): Location = Location(handle.bukkitEntity.world, handle.controllerLook.e(), handle.controllerLook.f(), handle.controllerLook.g()) - override fun getTargetSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = TargetGoalSelector() - - override fun getGoalSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = GoalSelector() - - override fun getControllerJump(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump = ControllerJump() - - override fun getControllerLook(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook = ControllerLookImpl() - - override fun getControllerMove(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove = ControllerMove() - override fun getHeadHeight(): Float = handle.headHeight - override fun getDefaultYaw(): Int = handle.O() - - override fun getDefaultPitch(): Int = handle.N() - override fun getBukkitEntity(): Entity = handle.bukkitEntity constructor(flying: Flying) : this((flying as CraftFlying).handle) @@ -150,17 +136,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) handle.b((livingEntity as CraftLivingEntity).handle) } - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double) { - moveRelative(motionX, motionY, motionZ, 1.0) - } - - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double, speed: Double) { - this.handle.motX += motionX * speed - this.handle.motY += motionY * speed - this.handle.motZ += motionZ * speed - this.handle.recalcPosition() - } - override fun setRotation(yaw: Float, pitch: Float) { this.handle.yaw = yaw this.handle.pitch = pitch @@ -171,119 +146,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) } - private inner class GoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - /** - * Add a pathfinder goal to the entity - * - * @param priority the priority 0 highest - * @param goal The goal to add - */ - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.addPathfinderGoal(priority, goal) - } - - /** - * Remove a pathfinder goal from the entity - * - * @param goal The goal to remove - */ - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.removePathfinderGoal(goal) - } - - /** - * Will clear all goals - */ - override fun clearGoals() { - this@CraftInsentient.clearPathfinderGoals() - } - } - - private inner class TargetGoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - /** - * Add a pathfinder goal to the entity - * - * @param priority the priority 0 highest - * @param goal The goal to add - */ - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.addTargetPathfinderGoal(priority, goal) - } - - /** - * Remove a pathfinder goal from the entity - * - * @param goal The goal to remove - */ - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.removeTargetPathfinderGoal(goal) - } - - /** - * Will clear all goals - */ - override fun clearGoals() { - this@CraftInsentient.clearTargetPathfinderGoals() - } - } - - private inner class ControllerJump : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump { - - /** - * Lets the entity jump - */ - override fun jump() { - this@CraftInsentient.jump() - } - } - - private inner class ControllerMove : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove { - - override fun isOperationMove(): Boolean = handle.controllerMove.h == net.minecraft.server.v1_12_R1.ControllerMove.Operation.MOVE_TO - - override fun getX(): Double = handle.controllerMove.c() - - override fun getY(): Double = handle.controllerMove.d() - - override fun getZ(): Double = handle.controllerMove.e() - - override fun getSpeed(): Double = handle.controllerMove.f() - - override fun move(motionX: Double, motionY: Double, motionZ: Double, speed: Double) = - this@CraftInsentient.setMovementDirection(Vector(motionX, motionY, motionZ), speed) - - override fun move(forward: Float, sideward: Float) = - this@CraftInsentient.setStrafeDirection(forward, sideward) - - override fun update() = handle.controllerMove.a() - } - - private inner class ControllerLookImpl : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook { - - override fun isReset(): Boolean = handle.controllerLook.b() - - override fun getLocationX(): Double = handle.controllerMove.d() - - override fun getLocationY(): Double = handle.controllerMove.e() - - override fun getLocationZ(): Double = handle.controllerMove.f() - - override fun lookAt(x: Double, y: Double, z: Double, yaw: Float, pitch: Float) = this@CraftInsentient - .lookAt(Location(handle.bukkitEntity.world, x, y, z, yaw, pitch)) - - override fun lookAt(location: Location) = this@CraftInsentient.lookAt(location) - - override fun lookAt(entity: Entity, yaw: Float, pitch: Float) = this@CraftInsentient.lookAt(entity) - - override fun reset() = handle.controllerLook.a() - } - companion object { private var reset: Method? = null diff --git a/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/pathfinding/CraftPathfinderManager.kt b/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/pathfinding/CraftPathfinderManager.kt index 79e4af2..c7b8d53 100644 --- a/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/pathfinding/CraftPathfinderManager.kt +++ b/Pathfinder_1_12/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_12_R1/pathfinding/CraftPathfinderManager.kt @@ -9,8 +9,6 @@ import org.bukkit.entity.* class CraftPathfinderManager : PathfinderManager { override fun getPathfinderGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) - override fun getPathfindeGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) - override fun getPathfinderGoalEntity(flying: Flying): Insentient = CraftInsentient(flying) override fun getPathfinderGoalEntity(ambient: Ambient): Insentient = CraftInsentient(ambient) diff --git a/Pathfinder_1_13/pom.xml b/Pathfinder_1_13/pom.xml deleted file mode 100644 index fde67a1..0000000 --- a/Pathfinder_1_13/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - Pathfinder_1_13 - - - - - kotlin-maven-plugin - - 1.8 - - - - - compile - - compile - compile - - - - test-compile - - test-compile - test-compile - - - org.jetbrains.kotlin - ${kotlin.version} - - - - - - - spigot - org.spigotmc - provided - 1.13-R0.1-SNAPSHOT - - - PathfinderAPI - com.github.ysl3000.pathfindergoalapi - provided - ${project.parent.version} - - - 4.0.0 - - - PathfindergoalAPI - com.github.ysl3000.pathfindergoalapi - 1.3.3.6-SNAPSHOT - - - - \ No newline at end of file diff --git a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/entity/CraftInsentient.kt b/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/entity/CraftInsentient.kt deleted file mode 100644 index b9eec8e..0000000 --- a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/entity/CraftInsentient.kt +++ /dev/null @@ -1,378 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.entity - -import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding.CraftNavigation -import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding.CraftPathfinderGoalWrapper -import com.github.ysl3000.bukkit.pathfinding.entity.Insentient -import com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook -import com.github.ysl3000.bukkit.pathfinding.pathfinding.Navigation -import net.minecraft.server.v1_13_R1.EntityInsentient -import net.minecraft.server.v1_13_R1.PathfinderGoal -import net.minecraft.server.v1_13_R1.PathfinderGoalSelector -import org.bukkit.Location -import org.bukkit.craftbukkit.v1_13_R1.entity.* -import org.bukkit.entity.* -import org.bukkit.util.Vector -import java.lang.reflect.InvocationTargetException -import java.lang.reflect.Method -import java.util.* - -/** - * Created by ysl3000 - */ -class CraftInsentient private constructor(private val handle: EntityInsentient) : Insentient { - override fun getLookingAt(): Location = - Location( - handle.bukkitEntity.world, - handle.controllerLook.e(), - handle.controllerLook.f(), - handle.controllerLook.g() - ) - - override fun getControllerLook(): ControllerLook = controllerLook - override fun getControllerMove(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove = controllerMove - override fun getNavigation(): Navigation = navigation - - override fun getTargetSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = targetSelector - override fun getGoalSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = goalSelector - - override fun getControllerJump(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump = controllerJump - - override fun getHeadHeight(): Float = handle.headHeight - - override fun getDefaultYaw(): Int = handle.L() - - override fun getDefaultPitch(): Int = handle.K() - - override fun getBukkitEntity(): Entity = handle.bukkitEntity - - - private val nmsGoals = HashMap() - private val nmsTargetGoals = HashMap() - - constructor(flying: Flying) : this((flying as CraftFlying).handle) - - private val navigation: Navigation - private val controllerLook: ControllerLook - private val controllerMove: ControllerMove - private val controllerJump: ControllerJump - private val targetSelector: GoalSelector - private val goalSelector: GoalSelector - - init { - navigation = CraftNavigation(handle.navigation) - controllerLook = ControllerLookImpl() - controllerMove = ControllerMove() - controllerJump = ControllerJump() - targetSelector = GoalSelector() - goalSelector = GoalSelector() - } - - - constructor(enderDragon: EnderDragon) : this((enderDragon as CraftEnderDragon).handle) - - constructor(creature: Creature) : this((creature as CraftCreature).handle) - - constructor(mob: Mob) : this((mob as CraftMob).handle) - - constructor(ambient: Ambient) : this((ambient as CraftAmbient).handle) - - constructor(slime: Slime) : this((slime as CraftSlime).handle) - - override fun addPathfinderGoal(priority: Int, - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - val goalWrapper = CraftPathfinderGoalWrapper(pathfinderGoal) - this.nmsGoals[pathfinderGoal] = goalWrapper - handle.goalSelector.a(priority, goalWrapper) - } - - override fun removePathfinderGoal( - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - if (nmsGoals.containsKey(pathfinderGoal)) { - val nmsGoal = nmsGoals.remove(pathfinderGoal) - handle.goalSelector.a(nmsGoal) - } - } - - override fun hasPathfinderGoal( - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal): Boolean { - return nmsGoals.containsKey(pathfinderGoal) - } - - override fun clearPathfinderGoals() { - handle.goalSelector = PathfinderGoalSelector(handle.getWorld().methodProfiler) - nmsGoals.clear() - } - - - override fun addTargetPathfinderGoal(priority: Int, - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - val goalWrapper = CraftPathfinderGoalWrapper(pathfinderGoal) - this.nmsTargetGoals[pathfinderGoal] = goalWrapper - handle.targetSelector.a(priority, goalWrapper) - } - - override fun removeTargetPathfinderGoal( - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - if (nmsTargetGoals.containsKey(pathfinderGoal)) { - val nmsGoal = nmsTargetGoals.remove(pathfinderGoal) - handle.goalSelector.a(nmsGoal) - } - } - - override fun hasTargetPathfinderGoal( - pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal): Boolean { - return nmsTargetGoals.containsKey(pathfinderGoal) - } - - override fun clearTargetPathfinderGoals() { - handle.targetSelector = PathfinderGoalSelector(handle.getWorld().methodProfiler) - nmsTargetGoals.clear() - } - - override fun jump() { - handle.controllerJump.a() - } - - override fun lookAt(location: Location) { - handle.controllerLook - .a(location.x, location.y, location.z, location.yaw, - location.pitch) - } - - override fun lookAt(entity: Entity) { - lookAt(entity.location) - } - - override fun setMovementDirection(direction: Vector, speed: Double) { - handle.controllerMove.a(direction.x, direction.blockY.toDouble(), direction.z, speed) - } - - override fun setStrafeDirection(forward: Float, sideward: Float) { - handle.controllerMove.a(forward, sideward) - } - - override fun resetGoalsToDefault() { - if (reset == null) { - return - } - try { - reset!!.invoke(handle) - } catch (e: IllegalAccessException) { - e.printStackTrace() - } catch (e: InvocationTargetException) { - e.printStackTrace() - } - - } - - override fun hasPositionChanged(): Boolean { - return handle.positionChanged - } - - override fun onEntityKill(livingEntity: LivingEntity) { - handle.b((livingEntity as CraftLivingEntity).handle) - } - - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double) { - moveRelative(motionX, motionY, motionZ, 1.0) - } - - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double, speed: Double) { - this.handle.motX += motionX * speed - this.handle.motY += motionY * speed - this.handle.motZ += motionZ * speed - this.handle.recalcPosition() - } - - override fun setRotation(yaw: Float, pitch: Float) { - this.handle.yaw = yaw - this.handle.pitch = pitch - } - - override fun updateRenderAngles() { - handle.controllerMove.a() - } - - - private inner class GoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - /** - * Add a pathfinder goal to the entity - * - * @param priority the priority 0 highest - * @param goal The goal to add - */ - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.addPathfinderGoal(priority, goal) - } - - /** - * Remove a pathfinder goal from the entity - * - * @param goal The goal to remove - */ - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.removePathfinderGoal(goal) - } - - /** - * Will clear all goals - */ - override fun clearGoals() { - this@CraftInsentient.clearPathfinderGoals() - } - } - - private inner class TargetGoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - /** - * Add a pathfinder goal to the entity - * - * @param priority the priority 0 highest - * @param goal The goal to add - */ - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.addTargetPathfinderGoal(priority, goal) - } - - /** - * Remove a pathfinder goal from the entity - * - * @param goal The goal to remove - */ - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) { - this@CraftInsentient.removeTargetPathfinderGoal(goal) - } - - /** - * Will clear all goals - */ - override fun clearGoals() { - this@CraftInsentient.clearTargetPathfinderGoals() - } - } - - private inner class ControllerJump : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump { - - /** - * Lets the entity jump - */ - override fun jump() { - this@CraftInsentient.jump() - } - } - - private inner class ControllerMove : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove { - override fun getX(): Double = handle.controllerMove.c() - - override fun getY(): Double = handle.controllerMove.d() - - override fun getZ(): Double = handle.controllerMove.e() - - override fun getSpeed(): Double = handle.controllerMove.f() - - override fun isOperationMove(): Boolean = handle.controllerMove.b() - - override fun move(motionX: Double, motionY: Double, motionZ: Double, speed: Double) = - this@CraftInsentient.setMovementDirection(Vector(motionX, motionY, motionZ), speed) - - override fun move(forward: Float, sideward: Float) = - this@CraftInsentient.setStrafeDirection(forward, sideward) - - override fun update() = - handle.controllerMove.a() - - } - - private inner class ControllerLookImpl : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook { - - /** - * Checks if the looking is reset - * - * @return if looking is default - */ - override fun isReset(): Boolean = handle.controllerLook.b() - - /** - * Gets the X-Location the entity is looking to - * - * @return x-location - */ - override fun getLocationX(): Double = handle.controllerMove.c() - - /** - * Gets the Y-Location the entity is looking to - * - * @return y-location - */ - override fun getLocationY(): Double = handle.controllerMove.d() - - /** - * Gets the Z-Location the entity is looking to - * - * @return z-location - */ - override fun getLocationZ(): Double = handle.controllerMove.f() - - /** - * The entity will look to the given coordinates - * - * @param x x-location - * @param y y-location - * @param z z-location - * @param yaw head rotation yaw - * @param pitch head rotation pitch - */ - override fun lookAt(x: Double, y: Double, z: Double, yaw: Float, pitch: Float) = this@CraftInsentient - .lookAt(Location(handle.bukkitEntity.world, x, y, z, yaw, pitch)) - - /** - * The entity will look to the given location - * - * @param location the entity should look to - */ - override fun lookAt(location: Location) { - this@CraftInsentient.lookAt(location) - } - - /** - * The entity will look to the given entity - * - * @param entity the entity which is targeted with eyes - * @param yaw head rotation yaw - * @param pitch head rotation pitch - */ - override fun lookAt(entity: Entity, yaw: Float, pitch: Float) { - this@CraftInsentient.lookAt(entity) - } - - /** - * Resets the current looking - */ - override fun reset() { - handle.controllerLook.a() - } - } - - companion object { - - - private var reset: Method? = null - - init { - - try { - reset = EntityInsentient::class.java.getDeclaredMethod("n") - reset!!.isAccessible = true - } catch (e: NoSuchMethodException) { - e.printStackTrace() - } - - } - } - -} diff --git a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftNavigation.kt b/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftNavigation.kt deleted file mode 100644 index 6717c0a..0000000 --- a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftNavigation.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding - -import com.github.ysl3000.bukkit.pathfinding.AbstractNavigation -import net.minecraft.server.v1_13_R1.NavigationAbstract -import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity -import org.bukkit.entity.Entity - -class CraftNavigation(private val navigationAbstract: NavigationAbstract) : AbstractNavigation( - doneNavigating = { navigationAbstract.p() }, - pathSearchRange = { navigationAbstract.j() }, - moveToPositionU = { x, y, z -> navigationAbstract.a(x, y, z) }, - moveToPositionB = { x, y, z, speed -> navigationAbstract.a(x, y, z, speed) }, - moveToEntityU = { entity -> navigationAbstract.a((entity as CraftEntity).handle) }, - moveToentityB = { entity: Entity, speed: Double -> navigationAbstract.a((entity as CraftEntity).handle, speed) }, - speedU = { speed -> navigationAbstract.a(speed) }, - clearPathEntityU = { navigationAbstract.q() } -) diff --git a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderPlayer.kt b/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderPlayer.kt deleted file mode 100644 index bc69c83..0000000 --- a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderPlayer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding - -import com.github.ysl3000.bukkit.pathfinding.AbstractPathfinderPlayer -import net.minecraft.server.v1_13_R1.EntityPlayer -import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer -import org.bukkit.entity.Player - -/** - * Created by ysl3000 - */ -class CraftPathfinderPlayer private constructor(private val entityPlayer: EntityPlayer) : AbstractPathfinderPlayer( - jump = { entityPlayer.motY > STILL }, - player = { entityPlayer.bukkitEntity }, - relativeMotionX = { entityPlayer.motX }, - relativeMotionY = { entityPlayer.motY }, - relativeMotionZ = { entityPlayer.motZ }, - relativeMotionForward = { entityPlayer.bh }, - relativeMotionSideward = { entityPlayer.bj }, - relativeMotionPitch = { entityPlayer.pitch }, - relativeMotionYaw = { entityPlayer.yaw } -) { - - companion object { - private const val STILL = -0.0784000015258789 - } - - constructor(player: Player) : this((player as CraftPlayer).handle) -} diff --git a/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/entity/CraftInsentient.kt b/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/entity/CraftInsentient.kt index 493f086..4be3774 100644 --- a/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/entity/CraftInsentient.kt +++ b/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/entity/CraftInsentient.kt @@ -103,10 +103,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) override fun setStrafeDirection(forward: Float, sideward: Float) = handle.controllerMove.a(forward, sideward) - override fun getTargetSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = TargetGoalSelector() - - override fun getGoalSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = GoalSelector() - override fun resetGoalsToDefault() { if (reset == null) { return @@ -121,34 +117,16 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) } - override fun getControllerJump(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump = ControllerJump() - - override fun getControllerLook(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook = ControllerLookImpl() - - override fun getControllerMove(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove = ControllerMove() - override fun getNavigation(): com.github.ysl3000.bukkit.pathfinding.pathfinding.Navigation = navigation override fun getHeadHeight(): Float = handle.headHeight - override fun getDefaultYaw(): Int = handle.L() - - override fun getDefaultPitch(): Int = handle.K() - override fun hasPositionChanged(): Boolean = handle.positionChanged override fun onEntityKill(livingEntity: LivingEntity) = handle.b((livingEntity as CraftLivingEntity).handle) override fun getBukkitEntity(): Entity = handle.bukkitEntity - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double) = moveRelative(motionX, motionY, motionZ, 1.0) - - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double, speed: Double) { - this.handle.motX += motionX * speed - this.handle.motY += motionY * speed - this.handle.motZ += motionZ * speed - this.handle.recalcPosition() - } override fun setRotation(yaw: Float, pitch: Float) { this.handle.yaw = yaw @@ -158,71 +136,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) override fun updateRenderAngles() = handle.controllerMove.a() - private inner class GoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.addPathfinderGoal(priority, goal) - - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.removePathfinderGoal(goal) - - override fun clearGoals() = this@CraftInsentient.clearPathfinderGoals() - } - - private inner class TargetGoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.addTargetPathfinderGoal(priority, goal) - - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.removeTargetPathfinderGoal(goal) - - - override fun clearGoals() = this@CraftInsentient.clearTargetPathfinderGoals() - } - - private inner class ControllerJump : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump { - override fun jump() = this@CraftInsentient.jump() - } - - private inner class ControllerMove : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove { - - override fun isOperationMove(): Boolean = handle.controllerMove.b() - - override fun move(motionX: Double, motionY: Double, motionZ: Double, speed: Double) = this@CraftInsentient.setMovementDirection(Vector(motionX, motionY, motionZ), speed) - - override fun move(forward: Float, sideward: Float) = this@CraftInsentient.setStrafeDirection(forward, sideward) - - override fun update() = handle.controllerMove.a() - - override fun getX(): Double = handle.controllerMove.c() - - override fun getY(): Double = handle.controllerMove.d() - - override fun getZ(): Double = handle.controllerMove.e() - - override fun getSpeed(): Double = handle.controllerMove.f() - } - - private inner class ControllerLookImpl : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook { - - override fun lookAt(x: Double, y: Double, z: Double, yaw: Float, pitch: Float) = this@CraftInsentient.lookAt(Location(handle.bukkitEntity.world, x, y, z, yaw, pitch)) - - override fun lookAt(location: Location) = this@CraftInsentient.lookAt(location) - - override fun lookAt(entity: Entity, yaw: Float, pitch: Float) = this@CraftInsentient.lookAt(entity) - - override fun reset() = handle.controllerLook.a() - - override fun isReset(): Boolean = handle.controllerLook.b() - - override fun getLocationX(): Double = handle.controllerMove.d() - - override fun getLocationY(): Double = handle.controllerMove.e() - - override fun getLocationZ(): Double = handle.controllerMove.f() - } - companion object { private var reset: Method? = null diff --git a/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/pathfinding/CraftPathfinderManager.kt b/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/pathfinding/CraftPathfinderManager.kt index 1e5547d..cfeb3c3 100644 --- a/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/pathfinding/CraftPathfinderManager.kt +++ b/Pathfinder_1_13_2/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R2/pathfinding/CraftPathfinderManager.kt @@ -12,8 +12,6 @@ class CraftPathfinderManager : PathfinderManager { override fun getPathfinderGoalEntity(mob: Mob): Insentient = CraftInsentient(mob) - override fun getPathfindeGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) - override fun getPathfinderGoalEntity(flying: Flying): Insentient = CraftInsentient(flying) override fun getPathfinderGoalEntity(ambient: Ambient): Insentient = CraftInsentient(ambient) diff --git a/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/entity/CraftInsentient.kt b/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/entity/CraftInsentient.kt index db9d1b5..56ead8b 100644 --- a/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/entity/CraftInsentient.kt +++ b/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/entity/CraftInsentient.kt @@ -28,7 +28,8 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) constructor(flying: Flying) : this((flying as CraftFlying).handle) init { - this.navigation = CraftNavigation(handle.navigation,(handle.bukkitEntity as Attributable).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)?.value?:0.7) + this.navigation = CraftNavigation(handle.navigation, (handle.bukkitEntity as Attributable).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)?.value + ?: 0.7) } @@ -106,9 +107,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) override fun setStrafeDirection(forward: Float, sideward: Float) = handle.controllerMove.a(forward, sideward) - override fun getTargetSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = TargetGoalSelector() - - override fun getGoalSelector(): com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector = GoalSelector() override fun resetGoalsToDefault() { if (reset == null) { @@ -124,33 +122,16 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) } - override fun getControllerJump(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump = ControllerJump() - - override fun getControllerLook(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook = ControllerLookImpl() - - override fun getControllerMove(): com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove = ControllerMove() - override fun getNavigation(): com.github.ysl3000.bukkit.pathfinding.pathfinding.Navigation = navigation override fun getHeadHeight(): Float = handle.headHeight - override fun getDefaultYaw(): Int = handle.dC() - - override fun getDefaultPitch(): Int = handle.M() - override fun hasPositionChanged(): Boolean = handle.positionChanged override fun onEntityKill(livingEntity: LivingEntity) = handle.b((livingEntity as CraftLivingEntity).handle) override fun getBukkitEntity(): Entity = handle.bukkitEntity - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double) = moveRelative(motionX, motionY, motionZ, 1.0) - - override fun moveRelative(motionX: Double, motionY: Double, motionZ: Double, speed: Double) { - this.handle.mot = this.handle.mot.add(motionX * speed, motionY * speed, motionZ * speed) - this.handle.recalcPosition() - } - override fun setRotation(yaw: Float, pitch: Float) { this.handle.yaw = yaw this.handle.pitch = pitch @@ -158,72 +139,6 @@ class CraftInsentient private constructor(private val handle: EntityInsentient) override fun updateRenderAngles() = handle.controllerMove.a() - - private inner class GoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.addPathfinderGoal(priority, goal) - - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.removePathfinderGoal(goal) - - override fun clearGoals() = this@CraftInsentient.clearPathfinderGoals() - } - - private inner class TargetGoalSelector : com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoalSelector { - - override fun addPathfinderGoal(priority: Int, - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.addTargetPathfinderGoal(priority, goal) - - override fun removePathfinderGoal( - goal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) = this@CraftInsentient.removeTargetPathfinderGoal(goal) - - - override fun clearGoals() = this@CraftInsentient.clearTargetPathfinderGoals() - } - - private inner class ControllerJump : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerJump { - override fun jump() = this@CraftInsentient.jump() - } - - private inner class ControllerMove : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerMove { - - override fun isOperationMove(): Boolean = handle.controllerMove.b() - - override fun move(motionX: Double, motionY: Double, motionZ: Double, speed: Double) = this@CraftInsentient.setMovementDirection(Vector(motionX, motionY, motionZ), speed) - - override fun move(forward: Float, sideward: Float) = this@CraftInsentient.setStrafeDirection(forward, sideward) - - override fun update() = handle.controllerMove.a() - - override fun getX(): Double = handle.controllerMove.c() - - override fun getY(): Double = handle.controllerMove.d() - - override fun getZ(): Double = handle.controllerMove.e() - - override fun getSpeed(): Double = handle.controllerMove.f() - } - - private inner class ControllerLookImpl : com.github.ysl3000.bukkit.pathfinding.pathfinding.ControllerLook { - - override fun lookAt(x: Double, y: Double, z: Double, yaw: Float, pitch: Float) = this@CraftInsentient.lookAt(Location(handle.bukkitEntity.world, x, y, z, yaw, pitch)) - - override fun lookAt(location: Location) = this@CraftInsentient.lookAt(location) - - override fun lookAt(entity: Entity, yaw: Float, pitch: Float) = this@CraftInsentient.lookAt(entity) - - override fun reset() = handle.controllerLook.a() - - override fun isReset(): Boolean = handle.controllerLook.c() - - override fun getLocationX(): Double = handle.controllerMove.d() - - override fun getLocationY(): Double = handle.controllerMove.e() - - override fun getLocationZ(): Double = handle.controllerMove.f() - } - companion object { private var reset: Method? = null diff --git a/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/pathfinding/CraftPathfinderManager.kt b/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/pathfinding/CraftPathfinderManager.kt index 6750074..18e5131 100644 --- a/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/pathfinding/CraftPathfinderManager.kt +++ b/Pathfinder_1_14/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_14_R1/pathfinding/CraftPathfinderManager.kt @@ -12,8 +12,6 @@ class CraftPathfinderManager : PathfinderManager { override fun getPathfinderGoalEntity(mob: Mob): Insentient = CraftInsentient(mob) - override fun getPathfindeGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) - override fun getPathfinderGoalEntity(flying: Flying): Insentient = CraftInsentient(flying) override fun getPathfinderGoalEntity(ambient: Ambient): Insentient = CraftInsentient(ambient) diff --git a/Pathfinder_1_15/pom.xml b/Pathfinder_1_15/pom.xml new file mode 100644 index 0000000..890a3ed --- /dev/null +++ b/Pathfinder_1_15/pom.xml @@ -0,0 +1,60 @@ + + + + PathfindergoalAPI + com.github.ysl3000.pathfindergoalapi + 1.3.3.6-SNAPSHOT + + 4.0.0 + + Pathfinder_1_15 + + + + + + kotlin-maven-plugin + + 1.8 + + + + + compile + + compile + compile + + + + test-compile + + test-compile + test-compile + + + org.jetbrains.kotlin + ${kotlin.version} + + + + + + + spigot + org.spigotmc + provided + 1.15-R0.1-SNAPSHOT + + + + PathfinderAPI + com.github.ysl3000.pathfindergoalapi + provided + ${parent.version} + + + + \ No newline at end of file diff --git a/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/entity/CraftInsentient.kt b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/entity/CraftInsentient.kt new file mode 100644 index 0000000..9bce408 --- /dev/null +++ b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/entity/CraftInsentient.kt @@ -0,0 +1,156 @@ +package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.entity + +import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding.CraftNavigation +import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding.CraftPathfinderGoalWrapper +import com.github.ysl3000.bukkit.pathfinding.entity.Insentient +import com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal +import net.minecraft.server.v1_15_R1.EntityInsentient +import net.minecraft.server.v1_15_R1.PathfinderGoalSelector +import org.bukkit.Location +import org.bukkit.attribute.Attributable +import org.bukkit.attribute.Attribute +import org.bukkit.craftbukkit.v1_15_R1.entity.* +import org.bukkit.entity.* +import org.bukkit.util.Vector +import java.lang.reflect.InvocationTargetException +import java.lang.reflect.Method +import java.util.HashMap + +class CraftInsentient private constructor(private val handle: EntityInsentient) : Insentient { + + + private val nmsGoals = HashMap() + private val nmsTargetGoals = HashMap() + + private val navigation: com.github.ysl3000.bukkit.pathfinding.pathfinding.Navigation + + constructor(flying: Flying) : this((flying as CraftFlying).handle) + + init { + this.navigation = CraftNavigation(handle.navigation,handle,(handle.bukkitEntity as Attributable).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)?.value?:0.7) + } + + + constructor(enderDragon: EnderDragon) : this((enderDragon as CraftEnderDragon).handle) + + constructor(creature: Creature) : this((creature as CraftCreature).handle) + + constructor(mob: Mob) : this((mob as CraftMob).handle) + + constructor(ambient: Ambient) : this((ambient as CraftAmbient).handle) + + constructor(slime: Slime) : this((slime as CraftSlime).handle) + + override fun addPathfinderGoal(priority: Int, + pathfinderGoal: PathfinderGoal) { + val goalWrapper = CraftPathfinderGoalWrapper(pathfinderGoal) + this.nmsGoals[pathfinderGoal] = goalWrapper + handle.goalSelector.a(priority, goalWrapper) + } + + override fun removePathfinderGoal( + pathfinderGoal: PathfinderGoal) { + if (nmsGoals.containsKey(pathfinderGoal)) { + val nmsGoal = nmsGoals.remove(pathfinderGoal) + handle.goalSelector.a(nmsGoal) + } + } + + override fun hasPathfinderGoal( + pathfinderGoal: PathfinderGoal): Boolean = nmsGoals.containsKey(pathfinderGoal) + + override fun clearPathfinderGoals() { + handle.goalSelector = PathfinderGoalSelector(handle.getWorld().methodProfiler) + nmsGoals.clear() + } + + + override fun addTargetPathfinderGoal(priority: Int, + pathfinderGoal: PathfinderGoal) { + val goalWrapper = CraftPathfinderGoalWrapper(pathfinderGoal) + this.nmsTargetGoals[pathfinderGoal] = goalWrapper + handle.targetSelector.a(priority, goalWrapper) + } + + override fun removeTargetPathfinderGoal( + pathfinderGoal: PathfinderGoal) { + if (nmsTargetGoals.containsKey(pathfinderGoal)) { + val nmsGoal = nmsTargetGoals.remove(pathfinderGoal) + handle.goalSelector.a(nmsGoal) + } + } + + override fun hasTargetPathfinderGoal( + pathfinderGoal: PathfinderGoal): Boolean = nmsTargetGoals.containsKey(pathfinderGoal) + + override fun clearTargetPathfinderGoals() { + handle.targetSelector = PathfinderGoalSelector(handle.getWorld().methodProfiler) + nmsTargetGoals.clear() + } + + override fun jump() { + handle.controllerJump.jump() + } + + override fun lookAt(location: Location) = handle.controllerLook + .a(location.x, location.y, location.z, location.yaw, + location.pitch) + + override fun lookAt(entity: Entity) = lookAt(entity.location) + + override fun getLookingAt(): Location = Location(handle.bukkitEntity.world, handle.controllerLook.d(), handle.controllerLook.e(), + handle.controllerLook.f()) + + override fun setMovementDirection(direction: Vector, speed: Double) = handle.controllerMove.a(direction.x, direction.blockY.toDouble(), direction.z, speed) + + override fun setStrafeDirection(forward: Float, sideward: Float) = handle.controllerMove.a(forward, sideward) + + override fun resetGoalsToDefault() { + if (reset == null) { + return + } + try { + reset!!.invoke(handle) + } catch (e: IllegalAccessException) { + e.printStackTrace() + } catch (e: InvocationTargetException) { + e.printStackTrace() + } + + } + + override fun getNavigation(): com.github.ysl3000.bukkit.pathfinding.pathfinding.Navigation = navigation + + override fun getHeadHeight(): Float = handle.headHeight + + + override fun hasPositionChanged(): Boolean = handle.positionChanged + + override fun onEntityKill(livingEntity: LivingEntity) = handle.b((livingEntity as CraftLivingEntity).handle) + + override fun getBukkitEntity(): Entity = handle.bukkitEntity + + override fun setRotation(yaw: Float, pitch: Float) { + this.handle.yaw = yaw + this.handle.pitch = pitch + } + + override fun updateRenderAngles() = handle.controllerMove.a() + + + companion object { + private var reset: Method? = null + + init { + + try { + reset = EntityInsentient::class.java.getDeclaredMethod("initPathfinder") + reset!!.isAccessible = true + } catch (e: NoSuchMethodException) { + e.printStackTrace() + } + + } + } + +} \ No newline at end of file diff --git a/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftNavigation.kt b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftNavigation.kt new file mode 100644 index 0000000..c88c236 --- /dev/null +++ b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftNavigation.kt @@ -0,0 +1,18 @@ +package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding + +import com.github.ysl3000.bukkit.pathfinding.AbstractNavigation +import net.minecraft.server.v1_15_R1.EntityInsentient +import net.minecraft.server.v1_15_R1.GenericAttributes +import net.minecraft.server.v1_15_R1.NavigationAbstract +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity + +class CraftNavigation(private val navigationAbstract: NavigationAbstract, private val handle: EntityInsentient, private val defaultSpeed: Double) : AbstractNavigation( + doneNavigating = { navigationAbstract.n() }, + pathSearchRange = { handle.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).value.toFloat() }, + moveToPositionU = { x, y, z -> navigationAbstract.a(x, y, z, defaultSpeed) }, + moveToPositionB = { x, y, z, speed -> navigationAbstract.a(x, y, z, speed) }, + moveToEntityU = { entity -> navigationAbstract.a((entity as CraftEntity).handle, defaultSpeed) }, + moveToentityB = { entity, speed -> navigationAbstract.a((entity as CraftEntity).handle, speed) }, + speedU = { speed -> navigationAbstract.a(speed) }, + clearPathEntityU = { navigationAbstract.q() } +) \ No newline at end of file diff --git a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderGoalWrapper.kt b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderGoalWrapper.kt similarity index 71% rename from Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderGoalWrapper.kt rename to Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderGoalWrapper.kt index 8748221..720ef3a 100644 --- a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderGoalWrapper.kt +++ b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderGoalWrapper.kt @@ -1,12 +1,7 @@ -package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding +package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding +import net.minecraft.server.v1_15_R1.PathfinderGoal -import net.minecraft.server.v1_13_R1.PathfinderGoal - - -/** - * Created by Yannick on 30.11.2016. - */ class CraftPathfinderGoalWrapper( private val pathfinderGoal: com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderGoal) : PathfinderGoal() { @@ -19,9 +14,4 @@ class CraftPathfinderGoalWrapper( override fun d() = pathfinderGoal.reset() override fun e() = pathfinderGoal.execute() -} - - - - - +} \ No newline at end of file diff --git a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderManager.kt b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderManager.kt similarity index 81% rename from Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderManager.kt rename to Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderManager.kt index addd4e1..f7cbfc1 100644 --- a/Pathfinder_1_13/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_13_R1/pathfinding/CraftPathfinderManager.kt +++ b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderManager.kt @@ -1,18 +1,17 @@ -package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.pathfinding +package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding -import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_13_R1.entity.CraftInsentient +import com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.entity.CraftInsentient import com.github.ysl3000.bukkit.pathfinding.entity.Insentient import com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderManager import com.github.ysl3000.bukkit.pathfinding.pathfinding.PathfinderPlayer import org.bukkit.entity.* class CraftPathfinderManager : PathfinderManager { + override fun getPathfinderGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) override fun getPathfinderGoalEntity(mob: Mob): Insentient = CraftInsentient(mob) - override fun getPathfindeGoalEntity(creature: Creature): Insentient = CraftInsentient(creature) - override fun getPathfinderGoalEntity(flying: Flying): Insentient = CraftInsentient(flying) override fun getPathfinderGoalEntity(ambient: Ambient): Insentient = CraftInsentient(ambient) @@ -22,4 +21,4 @@ class CraftPathfinderManager : PathfinderManager { override fun getPathfinderGoalEntity(enderDragon: EnderDragon): Insentient = CraftInsentient(enderDragon) override fun getPathfinderPlayer(player: Player): PathfinderPlayer = CraftPathfinderPlayer(player) -} +} \ No newline at end of file diff --git a/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderPlayer.kt b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderPlayer.kt new file mode 100644 index 0000000..937d55a --- /dev/null +++ b/Pathfinder_1_15/src/main/java/com/github/ysl3000/bukkit/pathfinding/craftbukkit/v1_15_R1/pathfinding/CraftPathfinderPlayer.kt @@ -0,0 +1,25 @@ +package com.github.ysl3000.bukkit.pathfinding.craftbukkit.v1_15_R1.pathfinding + +import com.github.ysl3000.bukkit.pathfinding.AbstractPathfinderPlayer +import net.minecraft.server.v1_15_R1.EntityPlayer +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer +import org.bukkit.entity.Player + +class CraftPathfinderPlayer private constructor(ep: EntityPlayer) : + AbstractPathfinderPlayer( + player = { ep.bukkitEntity }, + relativeMotionX = { ep.mot.x }, + relativeMotionY = { ep.mot.y }, + relativeMotionZ = { ep.mot.z }, + relativeMotionYaw = { ep.yaw }, + relativeMotionPitch = { ep.pitch }, + relativeMotionForward = { ep.az }, + relativeMotionSideward = { ep.ba }, + jump = { ep.mot.y > STILL } + ) { + constructor(player: Player) : this((player as CraftPlayer).handle) + + companion object { + private const val STILL = -0.0784000015258789 + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index f3f5619..f21d07b 100644 --- a/pom.xml +++ b/pom.xml @@ -42,9 +42,9 @@ PathfinderPlugin Pathfinder_1_12 - Pathfinder_1_13 Pathfinder_1_13_2 Pathfinder_1_14 + Pathfinder_1_15