Skip to content

Commit

Permalink
fixed bugs, added sounds and particles
Browse files Browse the repository at this point in the history
  • Loading branch information
Percyqaz committed Dec 20, 2021
1 parent e763a7d commit 57fcce0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 11 additions & 5 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/me/Percyqaz/Lodestone/CompassListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ int checkPlayerCooldown(String name)
void PerformTeleport(Player player, Location oldLoc)
{
// Need to check player hasn't moved, is still holding a teleport compass
if (player.getLocation().distanceSquared(oldLoc) > 0 && !player.isDead())
if (player.getLocation().distance(oldLoc) > 0.1 || player.isDead())
{
player.sendMessage(config.getString("teleportFailedMovedBeforeTeleport"));
player.playSound(player.getLocation(), Sound.ITEM_LODESTONE_COMPASS_LOCK, 1.0f, 0.5f);
resetPlayerCooldown(player.getName());
return;
}
Expand All @@ -79,18 +80,20 @@ void PerformTeleport(Player player, Location oldLoc)
? config.getString("teleportSucceededNamedLocation").replace("%location%", itemMeta.getDisplayName())
: config.getString("teleportSucceeded");
player.sendMessage(teleportMessage);
player.spawnParticle(Particle.CLOUD, oldLoc.add(0.0f, 1.0f, 0.0f), 50);
player.spawnParticle(Particle.CLOUD, oldLoc.add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f);

Location pos = itemMeta.getLodestone();
player.teleport(pos.add(0.5, 1.5, 0.5));
item.setAmount(item.getAmount() - 1);

player.spawnParticle(Particle.CLOUD, player.getLocation().add(0.0f, 1.0f, 0.0f), 50);
player.spawnParticle(Particle.CLOUD, player.getLocation().add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f);
player.playSound(player.getLocation(), Sound.BLOCK_CONDUIT_ACTIVATE, 1.0f, 0.5f);
return;
}
}

player.sendMessage(config.getString("teleportFailedCompassNotInHand"));
player.playSound(oldLoc, Sound.ITEM_LODESTONE_COMPASS_LOCK, 1.0f, 0.5f);
resetPlayerCooldown(player.getName());
}

Expand All @@ -117,7 +120,8 @@ Boolean handlePlayerClickCompass(Player player, ItemStack item)
() -> PerformTeleport(player, oldLoc),
warmupTimeTicks
);
player.spawnParticle(Particle.ENCHANTMENT_TABLE, oldLoc.add(0.0f, 1.0f, 0.0f), 50);
player.spawnParticle(Particle.ENCHANTMENT_TABLE, player.getLocation().add(0.0f, 1.0f, 0.0f), 50);
player.playSound(player.getLocation(), Sound.ITEM_LODESTONE_COMPASS_LOCK, 1.0f, 1.5f);
return true;
}
return false;
Expand Down

0 comments on commit 57fcce0

Please sign in to comment.