Foxikle / CustomNPCs

Foxikle's NPC plugin.
https://foxikle.dev/plugins
MIT License
7 stars 3 forks source link

Could not pass event PlayerMoveEvent to CustomNPCs v1.4.1 #25

Closed fejbioouuu closed 9 months ago

fejbioouuu commented 9 months ago

Describe the bug Bug appears on Console and Bugs Nps after time. Problem is that the Nps can't calculate the distance between the Player and the NPC as soon as the Player goes to another dimension. To Reproduce Steps to reproduce the behavior: I think the Bug occurs when creating an NPC in a other Dimension. Step to reproduce: Create World on a Paper Server Create an NPC in the Nether Go back to the Normal World Error Appears

Additional Info Error appears on: dev.foxikle.customnpcs.internal.listeners.Listeners.onMove(Listeners.java:198) src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java:198 As far as i understand the problem is that in the if (e.getPlayer().getLocation().distance(npc.getCurrentLocation()) <= 5) check the function can't calculate the distance if the player is in another dimension since it "Cannot measure distance between world and world_nether"

Expected behavior It would need to calculate the positions and the distance between the player and the npc over another function

Server(please complete the following information):

Full Error [23:09:03 ERROR]: Could not pass event PlayerMoveEvent to CustomNPCs v1.4.1 java.lang.IllegalArgumentException: Cannot measure distance between world and world_nether at org.bukkit.Location.distanceSquared(Location.java:510) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.Location.distance(Location.java:493) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at dev.foxikle.customnpcs.internal.listeners.Listeners.onMove(Listeners.java:198) ~[CustomNPCs-1.4.1.jar:?] at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor210.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:git-Paper-196] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.1.jar:git-Paper-196] at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.1.jar:git-Paper-196] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.handleMovePlayer(ServerGamePacketListenerImpl.java:1650) ~[?:?] at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.handle(ServerboundMovePlayerPacket.java:29) ~[?:?] at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos.handle(ServerboundMovePlayerPacket.java:66) ~[?:?] at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:51) ~[?:?] at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?] at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?] at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1338) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?] at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1315) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1308) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:114) ~[?:?] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1424) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1170) ~[paper-1.20.1.jar:git-Paper-196] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.20.1.jar:git-Paper-196] at java.lang.Thread.run(Thread.java:833) ~[?:?]

Foxikle commented 9 months ago

Hey! Thanks for reporting this. I'll look into it as soon as I can.