From 7a3921eace3b36d2e07e8c7c06554f8699d5b311 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 24 Apr 2013 11:05:40 -0400 Subject: [PATCH] Make these actually random. --- .../com/gmail/nossr50/listeners/BlockListener.java | 6 +++--- .../com/gmail/nossr50/listeners/PlayerListener.java | 4 ++-- src/main/java/com/gmail/nossr50/util/Misc.java | 10 ++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index f69436457..c1646ce49 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -298,7 +298,7 @@ public class BlockListener implements Listener { * We don't need to check permissions here because they've already been checked for the ability to even activate. */ if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) { - player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH); + player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch()); } } @@ -341,7 +341,7 @@ public class BlockListener implements Listener { plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); event.setInstaBreak(true); - player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); } } // Another perm check for the cracked blocks activation @@ -356,7 +356,7 @@ public class BlockListener implements Listener { else if (BlockUtils.isLeaves(blockState)) { if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) { event.setInstaBreak(true); - player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 630396691..490a4bd1d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -246,7 +246,7 @@ public class PlayerListener implements Listener { event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer)); if (event.isCancelled()) { - player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); return; } } @@ -255,7 +255,7 @@ public class PlayerListener implements Listener { event.setCancelled(Unarmed.handleItemPickup(player.getInventory(), drop)); if (event.isCancelled()) { - player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); player.updateInventory(); return; } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 5f6580269..3b47aa3ee 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -27,15 +27,21 @@ public final class Misc { // Sound Pitches & Volumes from CB public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values - public static final float FIZZ_PITCH = 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F; public static final float FIZZ_VOLUME = 0.5F; - public static final float POP_PITCH = ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; public static final float POP_VOLUME = 0.2F; public static final float BAT_VOLUME = 1.0F; public static final float BAT_PITCH = 0.6F; private Misc() {}; + public static float getFizzPitch() { + return 2.6F + (getRandom().nextFloat() - getRandom().nextFloat()) * 0.8F; + } + + public static float getPopPitch() { + return ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; + } + public static boolean isNPCEntity(Entity entity) { if (entity == null || entity.hasMetadata("NPC")) { return true;