Sounds volume and pitch are now configurable in the new sounds.yml file

This commit is contained in:
nossr50 2019-01-12 19:08:54 -08:00
parent 6927712a9d
commit 85fd0a79bc
22 changed files with 251 additions and 45 deletions

View File

@ -676,8 +676,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
@Override
protected void loadKeys() {}
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability.IncreaseLevel", 50); }
public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); }

View File

@ -573,5 +573,5 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPVPEnabled(PrimarySkill skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(PrimarySkill skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
}

View File

@ -0,0 +1,64 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.util.sounds.SoundType;
public class SoundConfig extends AutoUpdateConfigLoader {
private static SoundConfig instance;
public SoundConfig()
{
super("sounds.yml");
validate();
this.instance = this;
}
@Override
protected void loadKeys() {
}
public static SoundConfig getInstance()
{
if(instance == null)
return new SoundConfig();
return instance;
}
@Override
protected boolean validateKeys() {
for(SoundType soundType : SoundType.values())
{
if(config.getDouble("Sounds."+soundType.toString()+".Volume") < 0)
{
plugin.getLogger().info("[mcMMO] Sound volume cannot be below 0 for "+soundType.toString());
return false;
}
//Sounds with custom pitching don't use pitch values
if(!soundType.usesCustomPitch())
{
if(config.getDouble("Sounds."+soundType.toString()+".Pitch") < 0)
{
plugin.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for "+soundType.toString());
return false;
}
}
}
return true;
}
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
public float getVolume(SoundType soundType)
{
String key = "Sounds."+soundType.toString()+".Volume";
return (float) config.getDouble(key);
}
public float getPitch(SoundType soundType)
{
String key = "Sounds."+soundType.toString()+".Pitch";
return (float) config.getDouble(key);
}
}

View File

@ -37,8 +37,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
if(Config.getInstance().getMySQLSSL())
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
+ ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName() +
connectionString +=
"?verifyServerCertificate=false"+
"&useSSL=true"+
"&requireSSL=true";

View File

@ -8,6 +8,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
@ -239,7 +241,7 @@ public class Party {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
leader.playSound(leader.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
}
return;

View File

@ -45,6 +45,8 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.apache.commons.lang.Validate;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -512,7 +514,7 @@ public class McMMOPlayer {
}
if (Config.getInstance().getLevelUpSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
}
InteractionManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkill, profile.getSkillLevel(primarySkill));

View File

@ -21,6 +21,8 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -365,7 +367,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(SuperAbility.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
}
}
@ -404,7 +406,7 @@ public class BlockListener implements Listener {
else if (mcMMOPlayer.getAbilityMode(SuperAbility.BERSERK) && heldItem.getType() == Material.AIR) {
if (SuperAbility.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
@ -414,7 +416,7 @@ public class BlockListener implements Listener {
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
}
}

View File

@ -26,6 +26,8 @@ import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -303,7 +305,7 @@ public class PlayerListener implements Listener {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (event.isCancelled()) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
return;
}
}
@ -314,7 +316,7 @@ public class PlayerListener implements Listener {
event.setCancelled(cancel);
if (pickupSuccess) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
player.updateInventory();
return;
}

View File

@ -1,9 +1,6 @@
package com.gmail.nossr50;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.*;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
@ -381,6 +378,7 @@ public class mcMMO extends JavaPlugin {
AdvancedConfig.getInstance();
PotionConfig.getInstance();
CoreSkillsConfig.getInstance();
SoundConfig.getInstance();
new ChildConfig();

View File

@ -17,6 +17,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
@ -757,7 +759,7 @@ public final class PartyManager {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
if (levelUpSoundsEnabled) {
member.playSound(member.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP);
}
}
}

View File

@ -3,6 +3,8 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.Statistic;
@ -22,7 +24,7 @@ public class AprilTask extends BukkitRunnable {
int random = Misc.getRandom().nextInt(40) + 11;
int betterRandom = Misc.getRandom().nextInt(2000);
if (betterRandom == 0) {
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
fireworksShow(player);
}

View File

@ -2,6 +2,8 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
@ -85,11 +87,11 @@ public class KrakenAttackTask extends BukkitRunnable {
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
if (GLOBAL_EFFECTS) {
world.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
SoundManager.worldSendSound(world, location, SoundType.KRAKEN);
world.strikeLightningEffect(playerLocation);
}
else {
player.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
SoundManager.sendSound(player, playerLocation, SoundType.KRAKEN);
world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
}
}

View File

@ -23,6 +23,8 @@ import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -96,7 +98,7 @@ public class FishingManager extends SkillManager {
world.strikeLightningEffect(location);
world.strikeLightningEffect(location);
world.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
SoundManager.worldSendSound(world, location, SoundType.KRAKEN);
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
}
else {
@ -104,7 +106,7 @@ public class FishingManager extends SkillManager {
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
player.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
SoundManager.sendSound(player, location, SoundType.KRAKEN);
}
if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {

View File

@ -17,6 +17,8 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
@ -50,7 +52,7 @@ public class RepairManager extends SkillManager {
}
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
}
togglePlacedAnvil();
@ -149,7 +151,8 @@ public class RepairManager extends SkillManager {
// BWONG BWONG BWONG
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
}
// Repair the item!

View File

@ -13,6 +13,8 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -47,7 +49,7 @@ public class SalvageManager extends SkillManager {
}
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
}
togglePlacedAnvil();
@ -122,8 +124,10 @@ public class SalvageManager extends SkillManager {
// BWONG BWONG BWONG - CLUNK!
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
//player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
}
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success"));

View File

@ -18,9 +18,10 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.FurnaceBurnEvent;
@ -89,7 +90,7 @@ public class SmeltingManager extends SkillManager {
blockState.setType(Material.AIR);
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
}
ParticleEffectUtils.playFluxEffect(blockState.getLocation());

View File

@ -8,6 +8,8 @@ import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -131,7 +133,7 @@ public final class ChimaeraWing {
mcMMOPlayer.setTeleportCommenceLocation(null);
if (Config.getInstance().getChimaeraSoundEnabled()) {
player.playSound(location, Sound.ENTITY_BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING);
}
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));

View File

@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkill;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.google.common.collect.ImmutableList;
import org.bukkit.*;
import org.bukkit.FireworkEffect.Type;
@ -357,7 +359,7 @@ public final class HolidayManager {
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(PrimarySkill.MINING)) + 1;
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
}

View File

@ -31,7 +31,7 @@ public final class Misc {
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
// 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_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F * Config.getInstance().getMasterVolume();
public static final float POP_VOLUME = 0.2F * Config.getInstance().getMasterVolume();
@ -39,24 +39,12 @@ public final class Misc {
public static final float BAT_PITCH = 0.6F;
public static final float GHAST_VOLUME = 1.0F * Config.getInstance().getMasterVolume();
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always
public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always*/
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
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 float getGhastPitch() {
return (getRandom().nextFloat() - getRandom().nextFloat()) * 0.2F + 1.0F;
}
public static boolean isNPCEntity(Entity entity) {
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}

View File

@ -0,0 +1,81 @@
package com.gmail.nossr50.util.sounds;
import com.gmail.nossr50.config.SoundConfig;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class SoundManager {
/**
* Sends a sound to the player
* @param soundType the type of sound
*/
public static void sendSound(Player player, Location location, SoundType soundType)
{
player.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
}
public static void worldSendSound(World world, Location location, SoundType soundType)
{
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
}
/**
* All volume is multiplied by the master volume to get its final value
* @param soundType target soundtype
* @return the volume for this soundtype
*/
private static float getVolume(SoundType soundType)
{
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
}
private static float getPitch(SoundType soundType)
{
if(soundType == SoundType.FIZZ)
return getFizzPitch();
else if (soundType == SoundType.POP)
return getPopPitch();
else if (soundType == SoundType.KRAKEN)
return getKrakenPitch();
else
return SoundConfig.getInstance().getPitch(soundType);
}
private static Sound getSound(SoundType soundType)
{
switch(soundType)
{
case ANVIL:
return Sound.BLOCK_ANVIL_PLACE;
case ITEM_BREAK:
return Sound.ENTITY_ITEM_BREAK;
case POP:
return Sound.ENTITY_ITEM_PICKUP;
case KRAKEN:
return Sound.ENTITY_GHAST_SCREAM;
case CHIMAERA_WING:
return Sound.ENTITY_BAT_TAKEOFF;
case LEVEL_UP:
return Sound.ENTITY_PLAYER_LEVELUP;
case FIZZ:
return Sound.BLOCK_FIRE_EXTINGUISH;
default:
return null;
}
}
public static float getFizzPitch() {
return 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F;
}
public static float getPopPitch() {
return ((Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
}
public static float getKrakenPitch() {
return (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.2F + 1.0F;
}
}

View File

@ -0,0 +1,23 @@
package com.gmail.nossr50.util.sounds;
public enum SoundType {
ANVIL,
LEVEL_UP,
FIZZ,
ITEM_BREAK,
POP,
KRAKEN,
CHIMAERA_WING;
public boolean usesCustomPitch()
{
switch(this){
case POP:
case FIZZ:
case KRAKEN:
return true;
default:
return false;
}
}
}

View File

@ -0,0 +1,27 @@
# A volume of 1.0 is pretty loud
# Keep this in mind
Sounds:
# 1.0 = Max volume
# 0.0 = No Volume
MasterVolume: 1.0
ANVIL:
Volume: 1.0
Pitch: 0.3
#Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
FIZZ:
Volume: 0.5
LEVEL_UP:
Volume: 0.75
Pitch: 0.5
ITEM_BREAK:
Volume: 1.0
Pitch: 1.0
#Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
POP:
Volume: 0.2
#Fizz, Pop, and Kraken make use of a adding and multiplying random numbers together to make a unique pitch everytime they are heard
KRAKEN:
Volume: 1.0
CHIMAERA_WING:
Volume: 1.0
Pitch: 0.6