Skip to content

Commit

Permalink
Fixed #23 - If dogs leave the player's world, the distance could not …
Browse files Browse the repository at this point in the history
…be calculated
  • Loading branch information
HeroGamers committed Jan 19, 2022
1 parent 8f8865f commit ad8ffb5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/dk/fido2603/mydog/MyDog.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,17 @@ public void run()
Wolf wolf = (Wolf) plugin.getServer().getEntity(dog.getDogId());
if (wolf != null && !wolf.isSitting())
{
double distance = player.getLocation().distance(wolf.getLocation());
double distance = 0.0;
// if they are in two seperate worlds, it's safe to say that the distance is above 30 lol
if (!player.getWorld().getUID().equals(wolf.getWorld().getUID())) {
distance = 1000;
}
else {
distance = player.getLocation().distance(wolf.getLocation());
}

// A quick dirty check for ground below player
if (distance >= 30 && player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isSolid())
if (distance >= 30.0 && player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isSolid())
{
if (!experimentalTeleport)
{
Expand Down

0 comments on commit ad8ffb5

Please sign in to comment.