From 57fcce0ef94c97700eb6bae15d7edfe64036716e Mon Sep 17 00:00:00 2001 From: Percyqaz <> Date: Mon, 20 Dec 2021 02:16:32 +0000 Subject: [PATCH] fixed bugs, added sounds and particles --- .idea/workspace.xml | 16 +++++++++++----- src/me/Percyqaz/Lodestone/CompassListener.java | 12 ++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f9b53ba..064bc09 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,11 +1,9 @@ - + - - @@ -86,6 +91,7 @@ - \ No newline at end of file diff --git a/src/me/Percyqaz/Lodestone/CompassListener.java b/src/me/Percyqaz/Lodestone/CompassListener.java index ee67939..14dbb95 100644 --- a/src/me/Percyqaz/Lodestone/CompassListener.java +++ b/src/me/Percyqaz/Lodestone/CompassListener.java @@ -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; } @@ -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()); } @@ -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;