diff --git a/build.gradle b/build.gradle index 2809dd07..b7b30c10 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'java' apply plugin: 'application' -project.version = '0.5' +project.version = '1.0' sourceCompatibility = 8 mainClassName = 'minicraft.core.Game' @@ -15,12 +15,14 @@ repositories { } dependencies { - implementation 'org.jetbrains:annotations:24.0.0' - implementation 'org.json:json:20230227' + implementation 'org.jetbrains:annotations:24.1.0' + implementation 'org.json:json:20240205' implementation 'com.konghq:unirest-java:3.14.5' - implementation 'org.tinylog:tinylog-api:2.6.2' - implementation 'org.tinylog:tinylog-impl:2.6.2' + implementation 'org.tinylog:tinylog-api:2.7.0' + implementation 'org.tinylog:tinylog-impl:2.7.0' implementation 'com.github.JnCrMx:discord-game-sdk4j:v0.5.5' + implementation 'org.jogamp.gluegen:gluegen-rt-main:2.3.2' + implementation 'org.jogamp.joal:joal-main:2.3.2' } buildscript { diff --git a/src/main/java/minicraft/core/Game.java b/src/main/java/minicraft/core/Game.java index 390c4141..5ae919a1 100644 --- a/src/main/java/minicraft/core/Game.java +++ b/src/main/java/minicraft/core/Game.java @@ -3,9 +3,7 @@ import java.awt.GraphicsEnvironment; import java.io.PrintWriter; import java.io.StringWriter; -import java.net.UnknownHostException; import java.text.SimpleDateFormat; -import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -14,10 +12,6 @@ import org.jetbrains.annotations.Nullable; import org.tinylog.Logger; -import de.jcm.discordgamesdk.Core; -import de.jcm.discordgamesdk.CreateParams; -import de.jcm.discordgamesdk.GameSDKException; -import de.jcm.discordgamesdk.activity.Activity; import minicraft.core.io.FileHandler; import minicraft.core.io.InputHandler; import minicraft.core.io.Settings; @@ -45,7 +39,7 @@ protected Game() {} // Can't instantiate the Game class. public static boolean debug = false; // --debug arg public static final String NAME = "Aircraft"; // This is the name on the application window - public static final String BUILD = "0.5"; // Aircraft version + public static final String BUILD = "1.0"; // Aircraft version // TODO: not use anymore Minicraft plus versioning public static final Version VERSION = new Version("2.2.0-dev2"); // Minicraft plus mod base version @@ -71,7 +65,7 @@ public static void exitDisplay() { Logger.warn("Game tried to exit display, but no menu is open."); return; } - Sound.Menu_back.playOnDisplay(); + Sound.play("Menu_back"); newDisplay = display.getParent(); } @@ -163,9 +157,6 @@ public static void main(String[] args) { " Java Version: " + Utils.JAVA_VERSION + ", " + Utils.JAVA_VENDOR + "\n" + " Java VM Version: " + Utils.JVM_NAME + " (" + Utils.JVM_INFO + "), " + Utils.JVM_VENDOR + "\n" + " Memory: " + Utils.memoryInfo() + "\n\n" + - - "Flags: " + "\n" + - " isAudioOutputAvailible: " + Sound.isAudioOutputAvailable() + "\n\n" + "~~ ERROR ~~ " + "\n" + @@ -187,50 +178,12 @@ public static void main(String[] args) { Initializer.frame.pack(); Initializer.frame.setVisible(true); }); - // START EVENTS // Clean previously downloaded native files FileHandler.cleanNativesFiles(); - - // Discord rich presence - Core discordCore = null; - try { - final long CLIENT_ID = 981764521616093214L; - final String LARGE_TEXT = "Aircraft " + BUILD + ", Nice!"; - final String SMALL_TEXT = "Minicraft+ mod"; - - Core.initDownload(); // download java-discord SDK - CreateParams params = new CreateParams(); - params.setClientID(CLIENT_ID); // Discord APP ID - params.setFlags(CreateParams.getDefaultFlags()); - params.setFlags(CreateParams.Flags.NO_REQUIRE_DISCORD); - discordCore = new Core(params); - Activity activity = new Activity(); - activity.assets().setLargeImage("logo"); // Big image - activity.assets().setLargeText(LARGE_TEXT); // Big image text - activity.assets().setSmallImage("small-logo"); // Small image - activity.assets().setSmallText(SMALL_TEXT); // Small image text - activity.timestamps().setStart(Instant.now()); // Start timer - - discordCore.activityManager().updateActivity(activity); - if (debug) Logger.debug("Initializing discord RPC ..."); - - } catch (GameSDKException exception) { - Logger.error("Failed to initialize Discord SDK, no discord detected!"); - exception.printStackTrace(); - - } catch (UnknownHostException exception) { - Logger.error("Failed to download Discord SDK, no internet connection!"); - exception.printStackTrace(); - - } catch (Exception exception) { - Logger.error("Unknown error"); - exception.printStackTrace(); - } - // Parses the command line arguments Initializer.parseArgs(args); @@ -265,12 +218,12 @@ public static void main(String[] args) { setDisplay(new TitleDisplay()); // Start tick() count and start the game - Initializer.run(discordCore); - + Initializer.run(); - // EXIT EVENTS + Sound.shutdown(); - Logger.debug("Main game loop ended; Terminating application..."); + // EXIT EVENTS + Logger.debug("Game main loop ended, terminating application ..."); System.exit(0); } diff --git a/src/main/java/minicraft/core/Initializer.java b/src/main/java/minicraft/core/Initializer.java index 542866ca..d5cff239 100644 --- a/src/main/java/minicraft/core/Initializer.java +++ b/src/main/java/minicraft/core/Initializer.java @@ -10,6 +10,8 @@ import java.awt.event.WindowListener; import java.awt.image.BufferedImage; import java.io.IOException; +import java.net.UnknownHostException; +import java.time.Instant; import java.util.Objects; import javax.imageio.ImageIO; @@ -20,6 +22,9 @@ import org.tinylog.Logger; import de.jcm.discordgamesdk.Core; +import de.jcm.discordgamesdk.CreateParams; +import de.jcm.discordgamesdk.GameSDKException; +import de.jcm.discordgamesdk.activity.Activity; import minicraft.core.io.FileHandler; /* @@ -53,7 +58,6 @@ static void parseArgs(String[] args) { i++; saveDir = args[i]; } else if (args[i].equals("--fullscreen")) { - // Initializes fullscreen Updater.FULLSCREEN = true; } } @@ -70,7 +74,47 @@ static void parseArgs(String[] args) { * - fires the command to render out the screen. * - update the discord rpc */ - static void run(Core discordCore) { + static void run() { + + // Discord rich presence + Core discordCore = null; + + try { + if (debug) Logger.debug("Initializing discord RPC ..."); + + final long CLIENT_ID = 981764521616093214L; + final String LARGE_TEXT = "Aircraft " + BUILD + ", Nice!"; + final String SMALL_TEXT = "Minicraft+ mod"; + + Core.initDownload(); + CreateParams params = new CreateParams(); + params.setClientID(CLIENT_ID); + params.setFlags(CreateParams.getDefaultFlags()); + params.setFlags(CreateParams.Flags.NO_REQUIRE_DISCORD); + discordCore = new Core(params); + + Activity activity = new Activity(); + activity.assets().setLargeImage("logo"); + activity.assets().setLargeText(LARGE_TEXT); + activity.assets().setSmallImage("small-logo"); + activity.assets().setSmallText(SMALL_TEXT); + activity.timestamps().setStart(Instant.now()); + + discordCore.activityManager().updateActivity(activity); + + } catch (GameSDKException exception) { + Logger.warn("Failed to initialize Discord SDK, no discord running!"); + exception.printStackTrace(); + + } catch (UnknownHostException exception) { + Logger.warn("Failed to download Discord SDK, no internet connection!"); + exception.printStackTrace(); + + } catch (Exception exception) { + Logger.error("Unknown error"); + exception.printStackTrace(); + } + long lastTick = System.nanoTime(); long lastRender = System.nanoTime(); double unprocessed = 0; // delta? @@ -129,9 +173,12 @@ static void run(Core discordCore) { fra = (int) Math.round(frames * 1000D / interval); // saves total frames in last second tik = (int) Math.round(ticks * 1000D / interval); // saves total ticks in last second frames = 0; // resets frames - ticks = 0; // resets ticks; ie, frames and ticks only are per second + ticks = 0; // resets ticks; ie, frames and ticks only are per second } } + + // Finalize discord rich presence + discordCore.activityManager().clearActivity(Core.DEFAULT_CALLBACK); } diff --git a/src/main/java/minicraft/core/Updater.java b/src/main/java/minicraft/core/Updater.java index 6362009b..fb61cd50 100644 --- a/src/main/java/minicraft/core/Updater.java +++ b/src/main/java/minicraft/core/Updater.java @@ -171,6 +171,7 @@ public static void tick() { if (!Renderer.canvas.hasFocus()) { input.releaseAll(); } + if (Renderer.canvas.hasFocus()) { gameTime++; @@ -302,7 +303,7 @@ public static void changeTimeOfDay(int timeOfDay) { if (timeOfDay > 0 && timeOfDay < times.length) { changeTimeOfDay(times[timeOfDay]); // it just references the other one. } else { - Logger.warn("Time " + timeOfDay + " does not exist."); + Logger.warn("Time {} does not exist", timeOfDay); } } diff --git a/src/main/java/minicraft/core/io/FileHandler.java b/src/main/java/minicraft/core/io/FileHandler.java index b3b01a7e..20b5a24b 100644 --- a/src/main/java/minicraft/core/io/FileHandler.java +++ b/src/main/java/minicraft/core/io/FileHandler.java @@ -167,6 +167,8 @@ public FileVisitResult visitFileFailed(Path path, IOException exception) { * Remove all the natives files downloaded */ public static void cleanNativesFiles() { + Logger.info("Looking for old natives & assets to clean up ..."); + // Remove these native libraries String[] folderNames = { "java-discord" diff --git a/src/main/java/minicraft/core/io/Sound.java b/src/main/java/minicraft/core/io/Sound.java index 377045cc..4bf02e50 100644 --- a/src/main/java/minicraft/core/io/Sound.java +++ b/src/main/java/minicraft/core/io/Sound.java @@ -1,302 +1,241 @@ package minicraft.core.io; -import java.io.IOException; -import java.net.URL; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.sound.sampled.AudioFileFormat; -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.FloatControl; -import javax.sound.sampled.Line; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.Mixer; -import javax.sound.sampled.SourceDataLine; -import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.HashMap; +import org.jetbrains.annotations.Nullable; import org.tinylog.Logger; +import com.jogamp.openal.AL; +import com.jogamp.openal.ALFactory; +import com.jogamp.openal.util.ALut; + import minicraft.core.Game; import minicraft.entity.mob.Player; // Creates sounds from their respective files public class Sound { - - // Executor service to manage playing multiple clips simultaneously (yeah, im bad optimizing this :/) - private static final ExecutorService executorService = Executors.newFixedThreadPool(10); - - // Player - public static final Sound playerHurt = new Sound("/resources/sounds/mob/player/hurt.wav"); - public static final Sound playerDeath = new Sound("/resources/sounds/mob/player/death.wav"); - public static final Sound playerCraft = new Sound("/resources/sounds/mob/player/craft.wav"); - public static final Sound playerPickup = new Sound("/resources/sounds/mob/player/pickup.wav"); - public static final Sound playerPlace = new Sound("/resources/sounds/mob/player/place.wav"); - public static final Sound playerChangeLevel = new Sound("/resources/sounds/mob/player/changelevel.wav"); - - // Sheep - public static final Sound sheepSay1 = new Sound("/resources/sounds/mob/sheep/say1.wav"); - public static final Sound sheepSay2 = new Sound("/resources/sounds/mob/sheep/say2.wav"); - public static final Sound sheepSay3 = new Sound("/resources/sounds/mob/sheep/say3.wav"); - - // Cow - public static final Sound cowSay1 = new Sound("/resources/sounds/mob/cow/say1.wav"); - public static final Sound cowSay2 = new Sound("/resources/sounds/mob/cow/say2.wav"); - public static final Sound cowSay3 = new Sound("/resources/sounds/mob/cow/say3.wav"); - - // Pig - public static final Sound pigSay1 = new Sound("/resources/sounds/mob/pig/say1.wav"); - public static final Sound pigSay2 = new Sound("/resources/sounds/mob/pig/say2.wav"); - public static final Sound pigSay3 = new Sound("/resources/sounds/mob/pig/say3.wav"); - - // Chicken - public static final Sound chickenSay1 = new Sound("/resources/sounds/mob/chicken/say1.wav"); - public static final Sound chickenSay2 = new Sound("/resources/sounds/mob/chicken/say2.wav"); - public static final Sound chickenSay3 = new Sound("/resources/sounds/mob/chicken/say3.wav"); - - // Air Wizard - public static final Sound airWizardDeath = new Sound("/resources/sounds/mob/airwizard/bossdeath.wav"); - public static final Sound airWizardAttack = new Sound("/resources/sounds/mob/airwizard/wizardattack.wav"); - public static final Sound airWizardChangePhase = new Sound("/resources/sounds/mob/airwizard/changephase.wav"); - public static final Sound airWizardSpawnSpark = new Sound("/resources/sounds/mob/airwizard/spawnspark.wav"); - - // Keeper - public static final Sound keeperDeath = new Sound("/resources/sounds/entities/Keeper/keeperdeath.wav"); - - // Eye Queen - public static final Sound eyeQueenDeath = new Sound("/resources/sounds/entities/EyeQueen/eyedeath.wav"); - public static final Sound eyeQueenChangePhase = new Sound("/resources/sounds/entities/EyeQueen/changephase.wav"); - - // Dungeon chest - public static final Sound dungeonChest1 = new Sound("/resources/sounds/furniture/dungeonchest/dungeonchest1.wav"); - public static final Sound dungeonChest2 = new Sound("/resources/sounds/furniture/dungeonchest/dungeonchest2.wav"); - public static final Sound dungeonChest3 = new Sound("/resources/sounds/furniture/dungeonchest/dungeonchest3.wav"); - - // Spawner - public static final Sound Furniture_spawner_destroy = new Sound("/resources/sounds/entities/Spawner/destroy.wav"); - public static final Sound Furniture_spawner_destroy_2 = new Sound("/resources/sounds/entities/Spawner/destroy 2.wav"); - public static final Sound Furniture_spawner_destroy_3 = new Sound("/resources/sounds/entities/Spawner/destroy 3.wav"); - public static final Sound Furniture_spawner_spawn = new Sound("/resources/sounds/entities/Spawner/spawn.wav"); - public static final Sound Furniture_spawner_hurt = new Sound("/resources/sounds/entities/Spawner/hurt.wav"); - - // Menu - public static final Sound Menu_back = new Sound("/resources/sounds/gui/back.wav"); - public static final Sound Menu_select = new Sound("/resources/sounds/gui/select.wav"); - public static final Sound Menu_confirm = new Sound("/resources/sounds/gui/confirm.wav"); - public static final Sound Menu_loaded = new Sound("/resources/sounds/gui/loaded.wav"); - public static final Sound Menu_page_up = new Sound("/resources/sounds/gui/page up.wav"); - - public static final Sound Intro = new Sound("/resources/sounds/music/title/Intro.wav"); - public static final Sound Intro2 = new Sound("/resources/sounds/music/title/Intro 2.wav"); - - public static final Sound Amulet_locked = new Sound("/resources/sounds/music/amulet/Amulet locked.wav"); - public static final Sound Amulet_locked_2 = new Sound("/resources/sounds/music/amulet/Amulet locked 2.wav"); - public static final Sound Amulet_sucess = new Sound("/resources/sounds/music/amulet/Amulet sucess.wav"); - - // Cave and ambience sounds - public static final Sound Ambience1 = new Sound("/resources/sounds/ambient/Ambience1.wav"); - public static final Sound Ambience2 = new Sound("/resources/sounds/ambient/Ambience2.wav"); - public static final Sound Ambience3 = new Sound("/resources/sounds/ambient/Ambience3.wav"); - public static final Sound Ambience4 = new Sound("/resources/sounds/ambient/Ambience4.wav"); - public static final Sound Ambience5 = new Sound("/resources/sounds/ambient/Ambience5.wav"); + private static final HashMap sounds = new HashMap<>(); - public static final Sound Sky_enviroment = new Sound("/resources/sounds/ambient/sky environment.wav"); + private static final AL al = ALFactory.getAL(); + private final int source; - // Snow tile - public static final Sound Tile_snow = new Sound("/resources/sounds/tiles/Snow/snow.wav"); - public static final Sound Tile_snow_2 = new Sound("/resources/sounds/tiles/Snow/snow 2.wav"); - public static final Sound Tile_snow_3 = new Sound("/resources/sounds/tiles/Snow/snow 3.wav"); - public static final Sound Tile_snow_4 = new Sound("/resources/sounds/tiles/Snow/snow 4.wav"); - - // Farmland and Sky farmland tile - public static final Sound Tile_farmland = new Sound("/resources/sounds/tiles/Farmland/farmland.wav"); - public static final Sound Tile_farmland_2 = new Sound("/resources/sounds/tiles/Farmland/farmland 2.wav"); - public static final Sound Tile_farmland_3 = new Sound("/resources/sounds/tiles/Farmland/farmland 3.wav"); - - // Themes - public static final Sound Theme_Fall = new Sound("/resources/sounds/music/fall.wav"); - public static final Sound Theme_Surface = new Sound("/resources/sounds/music/surface.wav"); - public static final Sound Theme_Peaceful = new Sound("/resources/sounds/music/peaceful.wav"); - public static final Sound Theme_Cave = new Sound("/resources/sounds/music/cave.wav"); - public static final Sound Theme_Cavern = new Sound("/resources/sounds/music/cavern.wav"); - public static final Sound Theme_Cavern_drip = new Sound("/resources/sounds/music/cavern drip.wav"); - - // Rain sounds - public static final Sound rainThunder1 = new Sound("/resources/sounds/ambient/weather/thunder1.wav"); - public static final Sound rainThunder2 = new Sound("/resources/sounds/ambient/weather/thunder2.wav"); - public static final Sound rainThunder3 = new Sound("/resources/sounds/ambient/weather/thunder3.wav"); - - // Generic hurt sound - public static final Sound genericExplode = new Sound("/resources/sounds/genericExplode.wav"); - public static final Sound genericFuse = new Sound("/resources/sounds/genericFuse.wav"); - public static final Sound genericHurt = new Sound("/resources/sounds/genericHurt.wav"); - - private Clip clip; - private FloatControl volumeControl; - private Thread soundFadeThread; + static { + ALut.alutInit(); + al.alGetError(); + } public static void initialize() { Logger.debug("Initializing sound engine ..."); - } - - public static boolean isAudioOutputAvailable() { - Mixer.Info[] mixers = AudioSystem.getMixerInfo(); - for (Mixer.Info mixerInfo : mixers) { - Mixer mixer = AudioSystem.getMixer(mixerInfo); - Line.Info lineInfo = new Line.Info(SourceDataLine.class); - if (mixer.isLineSupported(lineInfo)) { - return true; - } - } - return false; - } - - private Sound(String name) { - if (!isAudioOutputAvailable()) { - Logger.warn("No audio devices or mixer available!, {} will not load ...", name.substring(name.lastIndexOf('/') + 1)); - return; - } - if (Game.debug) Logger.debug("Loading sound clip '{}' ...", name); - - try { - URL clipUrl = getClass().getResource(name); - AudioFileFormat audioFileFormat = AudioSystem.getAudioFileFormat(clipUrl); - DataLine.Info clipInfo = new DataLine.Info(Clip.class, audioFileFormat.getFormat()); - - if (!AudioSystem.isLineSupported(clipInfo)) { - Logger.error("Audio failure, audio format of file {} is not supported to {}!", name, audioFileFormat); - - Logger.info("Supported audio formats:"); - Logger.info("-- source:"); - - Line.Info[] sourceInfo = AudioSystem.getSourceLineInfo(clipInfo); - Line.Info[] targetInfo = AudioSystem.getTargetLineInfo(clipInfo); - - for (Line.Info value : sourceInfo) { - if (value instanceof DataLine.Info) { - DataLine.Info dataLineInfo = (DataLine.Info) value; - AudioFormat[] supportedFormats = dataLineInfo.getFormats(); - for (AudioFormat audioFormat : supportedFormats) { - Logger.info("- {}", audioFormat); - } - } - } - - Logger.info("-- target:"); - for (int i = 0; i < targetInfo.length; i++) { - if (targetInfo[i] instanceof DataLine.Info) { - DataLine.Info dataLineInfo = (DataLine.Info) targetInfo[i]; - AudioFormat[] supportedFormats = dataLineInfo.getFormats(); - for (AudioFormat audioFormat : supportedFormats) { - Logger.info("- {}", audioFormat); - } - } - } - - return; - } - - clip = (Clip) AudioSystem.getLine(clipInfo); - clip.open(AudioSystem.getAudioInputStream(clipUrl)); - volumeControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); - - clip.addLineListener(e -> { - if (e.getType() == LineEvent.Type.STOP) { - clip.flush(); - clip.setFramePosition(0); - } - }); - - } catch (LineUnavailableException | UnsupportedAudioFileException | IOException exception) { - Logger.error("Could not load sound file {}", name); - exception.printStackTrace(); + // This sucks, but is better thant statics variables for each one :) + + String[][] sounds = { + {"playerHurt", "/resources/sounds/mob/player/hurt.wav"}, + {"playerDeath", "/resources/sounds/mob/player/death.wav"}, + {"playerCraft", "/resources/sounds/mob/player/craft.wav"}, + {"playerPickup", "/resources/sounds/mob/player/pickup.wav"}, + {"playerPlace", "/resources/sounds/mob/player/place.wav"}, + {"playerChangeLevel", "/resources/sounds/mob/player/changelevel.wav"}, + + {"sheepSay1", "/resources/sounds/mob/sheep/say1.wav"}, + {"sheepSay2", "/resources/sounds/mob/sheep/say2.wav"}, + {"sheepSay3", "/resources/sounds/mob/sheep/say3.wav"}, + + {"cowSay1", "/resources/sounds/mob/cow/say1.wav"}, + {"cowSay2", "/resources/sounds/mob/cow/say2.wav"}, + {"cowSay3", "/resources/sounds/mob/cow/say3.wav"}, + + {"pigSay1", "/resources/sounds/mob/pig/say1.wav"}, + {"pigSay2", "/resources/sounds/mob/pig/say2.wav"}, + {"pigSay3", "/resources/sounds/mob/pig/say3.wav"}, + + {"chickenSay1", "/resources/sounds/mob/chicken/say1.wav"}, + {"chickenSay2", "/resources/sounds/mob/chicken/say2.wav"}, + {"chickenSay3", "/resources/sounds/mob/chicken/say3.wav"}, + + {"wizardDeath", "/resources/sounds/mob/airwizard/bossdeath.wav"}, + {"wizardAttack", "/resources/sounds/mob/airwizard/wizardattack.wav"}, + {"wizardChangePhase", "/resources/sounds/mob/airwizard/changephase.wav"}, + {"wizardSpawnSpark", "/resources/sounds/mob/airwizard/spawnspark.wav"}, + + {"keeperDeath", "/resources/sounds/mob/keeper/keeperdeath.wav"}, + + {"eyeQueenDeath", "/resources/sounds/mob/eyequeen/eyedeath.wav"}, + {"eyeQueenChangePhase", "/resources/sounds/mob/eyequeen/changephase.wav"}, + + {"dungeonChest1", "/resources/sounds/furniture/dungeonchest/dungeonchest1.wav"}, + {"dungeonChest2", "/resources/sounds/furniture/dungeonchest/dungeonchest2.wav"}, + {"dungeonChest3", "/resources/sounds/furniture/dungeonchest/dungeonchest3.wav"}, + + {"spawnerSpawn", "/resources/sounds/furniture/spawner/spawn.wav"}, + {"spawnerHurt", "/resources/sounds/furniture/spawner/hurt.wav"}, + {"spawnerDestroy1", "/resources/sounds/furniture/spawner/destroy1.wav"}, + {"spawnerDestroy2", "/resources/sounds/furniture/spawner/destroy2.wav"}, + {"spawnerDestroy3", "/resources/sounds/furniture/spawner/destroy3.wav"}, + + {"Menu_back", "/resources/sounds/gui/back.wav"}, + {"Menu_select", "/resources/sounds/gui/select.wav"}, + {"Menu_confirm", "/resources/sounds/gui/confirm.wav"}, + {"Menu_loaded", "/resources/sounds/gui/loaded.wav"}, + {"Menu_page_up", "/resources/sounds/gui/page up.wav"}, + + {"Ambience1", "/resources/sounds/ambient/Ambience1.wav"}, + {"Ambience2", "/resources/sounds/ambient/Ambience2.wav"}, + {"Ambience3", "/resources/sounds/ambient/Ambience3.wav"}, + {"Ambience4", "/resources/sounds/ambient/Ambience4.wav"}, + {"Ambience5", "/resources/sounds/ambient/Ambience5.wav"}, + + {"Sky_enviroment", "/resources/sounds/ambient/sky environment.wav"}, + + {"Tile_snow", "/resources/sounds/tiles/Snow/snow.wav"}, + {"Tile_snow_2", "/resources/sounds/tiles/Snow/snow 2.wav"}, + {"Tile_snow_3", "/resources/sounds/tiles/Snow/snow 3.wav"}, + {"Tile_snow_4", "/resources/sounds/tiles/Snow/snow 4.wav"}, + {"Tile_farmland", "/resources/sounds/tiles/Farmland/farmland.wav"}, + {"Tile_farmland_2", "/resources/sounds/tiles/Farmland/farmland 2.wav"}, + {"Tile_farmland_3", "/resources/sounds/tiles/Farmland/farmland 3.wav"}, + + {"musicTheme1", "/resources/sounds/music/fall.wav"}, + {"musicTheme2", "/resources/sounds/music/surface.wav"}, + {"musicTheme3", "/resources/sounds/music/paradise.wav"}, + {"musicTheme4", "/resources/sounds/music/peaceful.wav"}, + {"musicTheme5", "/resources/sounds/music/cave.wav"}, + {"musicTheme6", "/resources/sounds/music/cavern.wav"}, + {"musicTheme7", "/resources/sounds/music/dripping.wav"}, + {"musicTheme8", "/resources/sounds/music/deeper.wav"}, + + {"rainThunder1", "/resources/sounds/ambient/weather/thunder1.wav"}, + {"rainThunder2", "/resources/sounds/ambient/weather/thunder2.wav"}, + {"rainThunder3", "/resources/sounds/ambient/weather/thunder3.wav"}, + + {"genericExplode", "/resources/sounds/genericExplode.wav"}, + {"genericFuse", "/resources/sounds/genericFuse.wav"}, + {"genericHurt", "/resources/sounds/genericHurt.wav"} + }; + + for (String[] sound : sounds) { + loadSound(sound[0], new BufferedInputStream(Game.class.getResourceAsStream(sound[1]))); } } - // NOTE: this is a headcache, try not play lot sounds (maximum 10) with this at same time ._. - public void playOnLevel(int x, int y) { - Player player = Game.levels[Game.currentLevel].getClosestPlayer(x, y); - - if (!Settings.getBoolean("sound") || player == null) { - return; - } + public static void shutdown() { + Logger.debug("Shutting down sound engine ..."); + + ALut.alutExit(); + + sounds.clear(); + } + + private Sound(int source) { + this.source = source; + } + + public static void resetSounds() { + sounds.clear(); + } + + public static void loadSound(String key, InputStream in) { + + if (Game.debug) Logger.debug("Loading sound clip '{}' ...", key); + + int[] buffer = new int[1]; + int[] source = new int[1]; + + int[] format = new int[1]; + int[] size = new int[1]; + + ByteBuffer[] data = new ByteBuffer[1]; + + int[] freq = new int[1]; + int[] loop = new int[1]; + al.alGenBuffers(1, buffer, 0); + ALut.alutLoadWAVFile(in, format, data, size, freq, loop); + al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]); + + al.alGenSources(1, source, 0); + al.alSourcei(source[0], AL.AL_BUFFER, buffer[0]); + sounds.put(key, new Sound(source[0])); + } + + @Nullable + public static Sound getSound(String key) { + return sounds.get(key); + } + + public static void play(String key) { + Sound sound = sounds.get(key); + Logger.debug("Playing sound clip '{}' ...", key); + if (sound != null) sound.play(); + } + + public static void playAt(String key, int x, int y) { + Sound sound = sounds.get(key); + Logger.debug("Playing sound clip '{}', at ({}, {}) ...", key, x, y); + if (sound != null) sound.playAt(x, y); + } + + public static void loop(String key, boolean start) { + Sound sound = sounds.get(key); + if (sound != null) sound.loop(start); + } + + public static void stop(String key) { + Sound sound = sounds.get(key); + if (sound != null) al.alSourceStop(sound.source); + } + + public void playAt(int x, int y) { + if (!Settings.getBoolean("sound")) { + return; + } + + Player player = Game.levels[Game.currentLevel].getClosestPlayer(x, y); + + if (player == null) { + return; + } + + // Play the source without setting the volume + al.alSourcePlay(source); // Calculate the distance between the sound source and the player double distance = Math.sqrt(Math.pow(x - player.x, 2) + Math.pow(y - player.y, 2)); + // TODO: improve this using an thread to dynamically change the 'Sound Gain' while the player moves + // Set the volume based on the distance from the player - float minVolume = volumeControl.getMinimum(); - float volume = 1.0f - (float) distance / 20.0f; // Start to fade after 28 (distance) - if (volume < minVolume) { - return; // Don't play the sound if the volume is too low + float volume = 1.0f - (float) distance / 160.0f; + if (volume < 0.0f) { + return; } - volumeControl.setValue(volume); - - float fadeRate = 0.1f; // Adjust this value to control the rate at which the sound fades - // Use executor service to play the clip in a separate thread - executorService.submit(() -> { - if (clip.isRunning() || clip.isActive()) { - clip.stop(); - } + // Set the source volume + al.alSourcef(source, AL.AL_GAIN, volume); + } - clip.start(); - - // Start a separate thread to gradually fade the sound as the player moves away - soundFadeThread = new Thread(() -> { - while (volumeControl.getValue() > volumeControl.getMinimum() && clip.isRunning()) { - // Calculate the new volume based on the current volume and the fade rate - float newVolume = volumeControl.getValue() - (0.1f * fadeRate); - // Make sure the new volume is above the minimum allowable value - if (newVolume > volumeControl.getMinimum()) { - volumeControl.setValue(newVolume); - } - try { - Thread.sleep(2); // Adjust this value to control how often the volume is decreased - } catch (InterruptedException exception) { - exception.printStackTrace(); - } - } - clip.stop(); - }, "Sound fade Thread"); - soundFadeThread.start(); - }); - } - - public void playOnDisplay() { - if (!Settings.getBoolean("sound") || clip == null) { + public void play() { + if (!Settings.getBoolean("sound")) { return; } - - if (clip.isRunning() || clip.isActive()) { - clip.stop(); - } - - clip.start(); + + al.alSourcePlay(source); } public void loop(boolean start) { - if (!Settings.getBoolean("sound") || clip == null) { + if (!Settings.getBoolean("sound")) { return; } - + if (start) { - clip.loop(-1); + al.alSourcei(source, AL.AL_LOOPING, AL.AL_TRUE); + al.alSourcePlay(source); } else { - clip.stop(); - } - } - - public void stop() { - if (!Settings.getBoolean("sound") || clip == null) { - return; + al.alSourcei(source, AL.AL_LOOPING, AL.AL_FALSE); + al.alSourceStop(source); } - - clip.stop(); } } \ No newline at end of file diff --git a/src/main/java/minicraft/entity/Arrow.java b/src/main/java/minicraft/entity/Arrow.java index 44d2ef83..1443df71 100644 --- a/src/main/java/minicraft/entity/Arrow.java +++ b/src/main/java/minicraft/entity/Arrow.java @@ -103,7 +103,7 @@ public void tick() { level.dropItem(x - (dir.getX() * 4), y - (dir.getY() * 4), Items.get("Arrow")); } - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); remove(); } } diff --git a/src/main/java/minicraft/entity/Boat.java b/src/main/java/minicraft/entity/Boat.java index 1cf780f5..7ca8c8f9 100644 --- a/src/main/java/minicraft/entity/Boat.java +++ b/src/main/java/minicraft/entity/Boat.java @@ -157,7 +157,7 @@ public boolean blocks(Entity entity) { @Override public boolean interact(Player player, @Nullable Item item, Direction attackDir) { if (item instanceof PowerGloveItem) { - Sound.genericHurt.playOnLevel(this.x, this.y); + Sound.playAt("genericHurt", this.x, this.y); remove(); // put whatever item the player is holding into their inventory diff --git a/src/main/java/minicraft/entity/Entity.java b/src/main/java/minicraft/entity/Entity.java index e1eb32cc..2eb1173b 100644 --- a/src/main/java/minicraft/entity/Entity.java +++ b/src/main/java/minicraft/entity/Entity.java @@ -270,7 +270,7 @@ public void remove() { removed = true; if (level == null) { - Logger.warn("Note: remove() called on entity with no level reference: " + getClass()); + Logger.warn("Note: remove() called on entity with no level reference: {}", getClass()); } else { level.remove(this); } @@ -282,7 +282,7 @@ public void remove() { */ public void remove(Level level) { if (level != this.level) { - if (Game.debug) Logger.info("Tried to remove entity " + this + " from level it is not in: " + level + "; in level " + this.level); + if (Game.debug) Logger.info("Tried to remove entity {} from level it is not in: {}; in level {}", this, level, this.level); } else { removed = true; // Should already be set. this.level = null; @@ -295,7 +295,7 @@ public void remove(Level level) { */ public void setLevel(Level level, int x, int y) { if (level == null) { - Logger.warn("Tried to set level of entity " + this + " to a null level; Should use remove(level)"); + Logger.warn("Tried to set level of entity {} to a null level; Should use remove(level)", this); return; } diff --git a/src/main/java/minicraft/entity/furniture/DungeonChest.java b/src/main/java/minicraft/entity/furniture/DungeonChest.java index 02530f5b..6d56fa0f 100644 --- a/src/main/java/minicraft/entity/furniture/DungeonChest.java +++ b/src/main/java/minicraft/entity/furniture/DungeonChest.java @@ -58,12 +58,12 @@ public void tick() { if (isLocked && tickTime / 2 % 16 == 0) { if (random.nextBoolean()) { if (!random.nextBoolean()) { - Sound.dungeonChest1.playOnLevel(this.x, this.y); + Sound.playAt("dungeonChest1", this.x, this.y); } else { - Sound.dungeonChest2.playOnLevel(this.x, this.y); + Sound.playAt("dungeonChest2",this.x, this.y); } } else { - Sound.dungeonChest3.playOnLevel(this.x, this.y); + Sound.playAt("dungeonChest3",this.x, this.y); } } } @@ -90,7 +90,7 @@ public boolean use(Player player) { level.add(new TextParticle("-1 key", x, y, Color.RED)); level.chestCount--; if (level.chestCount == 0) { // if this was the last chest... - Sound.rainThunder2.playOnDisplay(); + Sound.play("rainThunder2"); level.dropItem(x, y, 5, Items.get("Gold Apple")); diff --git a/src/main/java/minicraft/entity/furniture/Furniture.java b/src/main/java/minicraft/entity/furniture/Furniture.java index 28685f42..ef10dec7 100644 --- a/src/main/java/minicraft/entity/furniture/Furniture.java +++ b/src/main/java/minicraft/entity/furniture/Furniture.java @@ -118,7 +118,7 @@ protected void touchedBy(Entity entity) { @Override public boolean interact(Player player, @Nullable Item item, Direction attackDir) { if (item instanceof PowerGloveItem) { - Sound.genericHurt.playOnLevel(this.x, this.y); + Sound.playAt("genericHurt", this.x, this.y); remove(); if (!Game.isMode("Creative") && player.activeItem != null && !(player.activeItem instanceof PowerGloveItem)) { diff --git a/src/main/java/minicraft/entity/furniture/Spawner.java b/src/main/java/minicraft/entity/furniture/Spawner.java index 4bc284cb..260b1962 100644 --- a/src/main/java/minicraft/entity/furniture/Spawner.java +++ b/src/main/java/minicraft/entity/furniture/Spawner.java @@ -185,7 +185,7 @@ private void trySpawn() { if (Game.debug) level.printLevelLoc("Spawning new " + mob, (newmob.x >> 4), (newmob.y >> 4), "..."); level.add(newmob); - Sound.Furniture_spawner_spawn.playOnLevel(this.x, this.y); + Sound.playAt("spawnerSpawn", this.x, this.y); // Fire particles when spawn a mob if (Settings.get("particles").equals(true)) { @@ -201,7 +201,7 @@ public boolean interact(Player player, Item item, Direction attackDir) { if (item instanceof ToolItem) { ToolItem tool = (ToolItem) item; - Sound.genericHurt.playOnLevel(this.x, this.y); + Sound.playAt("genericHurt", this.x, this.y); int toolDamage; if (Game.isMode("Creative")) { @@ -225,11 +225,11 @@ public boolean interact(Player player, Item item, Direction attackDir) { // Random spawner sound switch (random.nextInt(3)) { - case 0: Sound.Furniture_spawner_hurt.playOnLevel(this.x, this.y); break; - case 1: Sound.Furniture_spawner_destroy.playOnLevel(this.x, this.y); break; - case 2: Sound.Furniture_spawner_destroy_2.playOnLevel(this.x, this.y); break; - case 3: Sound.Furniture_spawner_destroy_3.playOnLevel(this.x, this.y); break; - default: Sound.Furniture_spawner_hurt.playOnLevel(this.x, this.y); break; + case 0: Sound.playAt("spawnerHurt", this.x, this.y); break; + case 1: Sound.playAt("spawnerDestroy1", this.x, this.y); break; + case 2: Sound.playAt("spawnerDestroy2", this.x, this.y); break; + case 3: Sound.playAt("spawnerDestroy3", this.x, this.y); break; + default: Sound.playAt("spawnerHurt", this.x, this.y); break; } // Sound.playerDeath.playOnDisplay(); diff --git a/src/main/java/minicraft/entity/furniture/Tnt.java b/src/main/java/minicraft/entity/furniture/Tnt.java index f85de79c..64f5ee99 100644 --- a/src/main/java/minicraft/entity/furniture/Tnt.java +++ b/src/main/java/minicraft/entity/furniture/Tnt.java @@ -85,7 +85,7 @@ public void tick() { Tnt tnt = (Tnt) entity; if (!tnt.fuseLit) { tnt.fuseLit = true; - Sound.genericFuse.playOnLevel(this.x, this.y); + Sound.playAt("genericFuse", this.x, this.y); tnt.fuseTick = FUSE_TIME * 2 / 3; } @@ -107,7 +107,7 @@ public void tick() { } // Play explosion sound - Sound.genericExplode.playOnLevel(this.x, this.y); + Sound.playAt("genericExplode", this.x, this.y); level.setAreaTiles(xt, yt, 1, Tiles.get("Explode"), 0, explosionBlacklist); @@ -159,7 +159,7 @@ public boolean interact(Player player, Item heldItem, Direction attackDir) { } else { if (!fuseLit) { fuseLit = true; - Sound.genericFuse.playOnLevel(this.x, this.y); + Sound.playAt("genericFuse", this.x, this.y); return true; } } diff --git a/src/main/java/minicraft/entity/mob/AirWizard.java b/src/main/java/minicraft/entity/mob/AirWizard.java index 26ef676d..1ec46f28 100644 --- a/src/main/java/minicraft/entity/mob/AirWizard.java +++ b/src/main/java/minicraft/entity/mob/AirWizard.java @@ -113,14 +113,14 @@ public void tick() { // Change phases by health if (health <= (secondform ? 12000 : 7000) && currentPhase == 1) { // change to phase 2 - Sound.airWizardChangePhase.playOnLevel(this.x, this.y); + Sound.playAt("wizardChangePhase", this.x, this.y); spritesMain = spritesSecondPhase; currentPhase = 2; } if (health <= (secondform ? 6000 : 3500) && currentPhase == 2) { // change to phase 3 - Sound.airWizardChangePhase.playOnLevel(this.x, this.y); + Sound.playAt("wizardChangePhase", this.x, this.y); spritesMain = spritesThirdPhase; currentPhase = 3; } @@ -162,7 +162,7 @@ public void tick() { level.add(new Spark(this, Math.cos(dir) * speed, Math.sin(dir) * speed, 1)); // adds a spark entity with the cosine and sine of dir times speed. } - Sound.airWizardSpawnSpark.playOnLevel(this.x, this.y); + Sound.playAt("wizardSpawnSpark", this.x, this.y); return; // skips the rest of the code (attackTime was > 0; ie we're attacking.) } @@ -175,7 +175,7 @@ else if (attackTime > 0 && currentPhase == 2) { double speed = (secondform ? 1.2 : 0.7) + attackType * 0.2; level.add(new Spark(this, Math.cos(dir) * speed, Math.sin(dir) * speed, 2)); - Sound.airWizardSpawnSpark.playOnLevel(this.x, this.y); + Sound.playAt("wizardSpawnSpark", this.x, this.y); return; } @@ -188,7 +188,7 @@ else if (attackTime > 0 && currentPhase == 3) { double speed = (secondform ? 1.2 : 0.7) + attackType * 0.2; level.add(new Spark(this, Math.cos(dir) * speed, Math.sin(dir) * speed, 3)); - Sound.airWizardSpawnSpark.playOnLevel(this.x, this.y); + Sound.playAt("wizardSpawnSpark", this.x, this.y); return; } @@ -302,7 +302,7 @@ public void die() { } } - Sound.airWizardDeath.playOnLevel(this.x, this.y); + Sound.playAt("wizardDeath", this.x, this.y); level.dropItem(x, y, Items.get("AlAzif")); diff --git a/src/main/java/minicraft/entity/mob/Chicken.java b/src/main/java/minicraft/entity/mob/Chicken.java index 29296965..47a632b4 100644 --- a/src/main/java/minicraft/entity/mob/Chicken.java +++ b/src/main/java/minicraft/entity/mob/Chicken.java @@ -2,7 +2,6 @@ import minicraft.core.Game; import minicraft.core.io.Settings; -import minicraft.core.io.Sound; import minicraft.graphic.MobSprite; import minicraft.item.Item; import minicraft.item.Items; @@ -10,8 +9,8 @@ public class Chicken extends PassiveMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(10, 40); - private boolean eggDropped = false; - + private static final String[] sounds = new String[] {"chickenSay1", "chickenSay2", "chickenSay3"}; + /** * Creates a Chicken. */ @@ -25,7 +24,7 @@ public void tick() { if (tickTime % 2000 == 0) { if (Game.isMode("Survival")) { // drop eggs each 15 secs - dropItem(0, 1, Items.get("egg")); + level.dropItem(x, y, Items.get("egg")); } } @@ -33,16 +32,8 @@ public void tick() { followOnHold(Items.get("Seeds"), 2); // Chicken sounds - if (tickTime / 8 % 16 == 0 && random.nextInt(8) == 4) { - if (random.nextBoolean()) { - if (!random.nextBoolean()) { - Sound.chickenSay1.playOnLevel(this.x, this.y); - } else { - Sound.chickenSay2.playOnLevel(this.x, this.y); - } - } else { - Sound.chickenSay3.playOnLevel(this.x, this.y); - } + if ((this.tickTime % (random.nextInt(100) + 120) == 0)) { + doPlaySound(sounds, 6); } } @@ -53,15 +44,11 @@ public void die() { String difficulty = (String) Settings.get("diff"); - if (difficulty == "Peaceful" || difficulty == "Easy") { + if (difficulty.equals("Peaceful") || difficulty.equals("Easy")) { min = 1; max = 2; - } - - if (difficulty == "Normal") { + } else if (difficulty.equals("Normal")) { min = 1; max = 1; - } - - if (difficulty == "Hard") { + } else if (difficulty.equals("Hard")) { min = 0; max = 1; } @@ -69,7 +56,6 @@ public void die() { Items.get("raw chicken"), Items.get("feather") }); - super.die(); } } \ No newline at end of file diff --git a/src/main/java/minicraft/entity/mob/Cow.java b/src/main/java/minicraft/entity/mob/Cow.java index 7e29338d..f97b9ee6 100644 --- a/src/main/java/minicraft/entity/mob/Cow.java +++ b/src/main/java/minicraft/entity/mob/Cow.java @@ -1,13 +1,13 @@ package minicraft.entity.mob; import minicraft.core.io.Settings; -import minicraft.core.io.Sound; import minicraft.graphic.MobSprite; import minicraft.item.Item; import minicraft.item.Items; public class Cow extends PassiveMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(0, 40); + private static final String[] sounds = new String[] {"cowSay1", "cowSay2", "cowSay3"}; /** * Creates the cow with the right sprites and color. @@ -23,17 +23,8 @@ public void tick() { followOnHold(Items.get("Wheat"), 3); // Cow sounds - if ((this.tickTime % (random.nextInt(100) + 120) == 0) && random.nextInt(8) == 0) { - if (random.nextBoolean()) { - if (!random.nextBoolean()) { - Sound.cowSay1.playOnLevel(this.x, this.y); - } else { - Sound.cowSay2.playOnLevel(this.x, this.y); - } - } else { - Sound.cowSay3.playOnLevel(this.x, this.y); - } - + if ((tickTime % (random.nextInt(100) + 120) == 0)) { + doPlaySound(sounds, 8); } } diff --git a/src/main/java/minicraft/entity/mob/Creeper.java b/src/main/java/minicraft/entity/mob/Creeper.java index 6fe1622b..6e4c54a6 100644 --- a/src/main/java/minicraft/entity/mob/Creeper.java +++ b/src/main/java/minicraft/entity/mob/Creeper.java @@ -91,7 +91,7 @@ public void tick() { // It will only blow up if there are any players nearby. if (playerInRange) { // Play explosion sound - Sound.genericExplode.playOnLevel(this.x, this.y); + Sound.playAt("genericExplode", this.x, this.y); // figure out which tile the mob died on int xt = x >> 4; @@ -186,7 +186,7 @@ protected void touchedBy(Entity entity) { if (entity instanceof Player) { if (fuseTime == 0 && !fuseLit) { - Sound.genericFuse.playOnLevel(this.x, this.y); + Sound.playAt("genericFuse", this.x, this.y); fuseTime = MAX_FUSE_TIME; fuseLit = true; } @@ -212,7 +212,7 @@ public boolean interact(Player player, @Nullable Item item, Direction attackDir) if (tool.type == ToolType.Igniter) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { if (fuseTime == 0 && !fuseLit) { - Sound.genericFuse.playOnLevel(this.x, this.y); + Sound.playAt("genericFuse", this.x, this.y); fuseTime = MAX_FUSE_TIME; fuseLit = true; return true; diff --git a/src/main/java/minicraft/entity/mob/EyeQueen.java b/src/main/java/minicraft/entity/mob/EyeQueen.java index 340ab4b2..3cc2653b 100644 --- a/src/main/java/minicraft/entity/mob/EyeQueen.java +++ b/src/main/java/minicraft/entity/mob/EyeQueen.java @@ -92,7 +92,7 @@ public void tick() { } // Change to phase 2 - Sound.eyeQueenChangePhase.playOnLevel(this.x, this.y); + Sound.playAt("eyeQueenChangePhase", this.x, this.y); currentPhase = 2; } @@ -102,7 +102,7 @@ public void tick() { } // Change to phase 3 - Sound.eyeQueenChangePhase.playOnLevel(this.x, this.y); + Sound.playAt("eyeQueenChangePhase", this.x, this.y); currentPhase = 3; } @@ -171,7 +171,7 @@ public void tick() { double speed = (0.7) + attackType * 0.2; // speed is dependent on the attackType. (higher attackType, faster speeds) level.add(new Fireball(this, Math.cos(dir) * speed, Math.sin(dir) * speed, 2, random.nextInt(2) + 1)); // adds a fireball entity with the cosine and sine of dir times speed. - Sound.airWizardSpawnSpark.playOnLevel(this.x, this.y); + Sound.playAt("wizardSpawnSpark", this.x, this.y); return; // skips the rest of the code (attackTime was > 0; ie we're attacking.) @@ -182,7 +182,7 @@ public void tick() { double speed = (0.7) + attackType * 0.2; level.add(new Fireball(this, Math.cos(dir) * speed, Math.sin(dir) * speed, 3, random.nextInt(3) + 1)); - Sound.airWizardSpawnSpark.playOnLevel(this.x, this.y); + Sound.playAt("wizardSpawnSpark", this.x, this.y); return; } @@ -204,7 +204,7 @@ public void tick() { if (this.health <= 100 && !this.deathing) { this.health = 200; this.deathing = true; - Sound.eyeQueenDeath.playOnLevel(this.x, this.y); + Sound.playAt("eyeQueenDeath", this.x, this.y); tickTime = 0; } diff --git a/src/main/java/minicraft/entity/mob/Goat.java b/src/main/java/minicraft/entity/mob/Goat.java index fa037f80..4873e8ab 100644 --- a/src/main/java/minicraft/entity/mob/Goat.java +++ b/src/main/java/minicraft/entity/mob/Goat.java @@ -1,6 +1,7 @@ package minicraft.entity.mob; import minicraft.core.io.Settings; +import minicraft.core.io.Sound; import minicraft.graphic.MobSprite; import minicraft.item.Items; import minicraft.level.tile.Tile; @@ -21,14 +22,34 @@ public void tick() { // follows to the player if holds wheat followOnHold(Items.get("Wheat"), 3); + - if (tickTime /16 %24 == 0) { + if ((tickTime % (random.nextInt(100) + 120) == 0)) { Tile tile = level.getTile(x >> 4, y >> 4); - if (tile == Tiles.get("Grass") || tile == Tiles.get("Sand") || tile == Tiles.get("Lawn") || tile == Tiles.get("Rose") || tile == Tiles.get("Daisy") || tile == Tiles.get("Dandelion") || tile == Tiles.get("Poppy")) { - this.remove(); + if (tile == Tiles.get("Grass") || tile == Tiles.get("Sand") + || tile == Tiles.get("Lawn") || tile == Tiles.get("Rose") + || tile == Tiles.get("Daisy") || tile == Tiles.get("Dandelion") + || tile == Tiles.get("Poppy")) { + remove(); level.add(new Sheep(), x, y); } + + // Sheep sounds + Player player = getClosestPlayer(); + + if (player != null && player.isWithin(8, this)) { + + if (random.nextBoolean()) { + if (!random.nextBoolean()) { + Sound.playAt("sheepSay1", this.x, this.y); + } else { + Sound.playAt("sheepSay2", this.x, this.y); + } + } else { + Sound.playAt("sheepSay3", this.x, this.y); + } + } } } diff --git a/src/main/java/minicraft/entity/mob/Keeper.java b/src/main/java/minicraft/entity/mob/Keeper.java index bda30f2f..bb97372f 100644 --- a/src/main/java/minicraft/entity/mob/Keeper.java +++ b/src/main/java/minicraft/entity/mob/Keeper.java @@ -135,7 +135,7 @@ public void die() { max = 2; } - Sound.keeperDeath.playOnLevel(this.x, this.y); + Sound.playAt("keeperDeath", this.x, this.y); beaten = true; active = false; diff --git a/src/main/java/minicraft/entity/mob/MobAi.java b/src/main/java/minicraft/entity/mob/MobAi.java index 18c53018..9edeaa6c 100644 --- a/src/main/java/minicraft/entity/mob/MobAi.java +++ b/src/main/java/minicraft/entity/mob/MobAi.java @@ -142,7 +142,7 @@ public void doHurt(int damage, Direction attackDir) { int xd = player.x - x; int yd = player.y - y; if (xd * xd + yd * yd < 80 * 80) { - Sound.genericHurt.playOnLevel(this.x, this.y); + Sound.playAt("genericHurt", this.x, this.y); } } // Make a text particle at this position in this level, bright red and displaying the damage inflicted @@ -231,6 +231,24 @@ protected static boolean checkStartPos(Level level, int x, int y, int playerDist protected void die(int points) { die(points, 0); } + + + protected void doPlaySound(String[] sounds, int heardRadius) { + Player player = getClosestPlayer(); + + if (player != null && player.isWithin(heardRadius, this)) { + int randomNum = random.nextInt(sounds.length); + Sound.playAt(sounds[randomNum], x, y); + } + } + + protected void doPlaySound(String sound, int heardRadius) { + Player player = getClosestPlayer(); + + if (player != null && player.isWithin(heardRadius, this)) { + Sound.playAt(sound, x, y); + } + } protected void die(int points, int scoreMultiplier) { for (Player player : level.getPlayers()) { diff --git a/src/main/java/minicraft/entity/mob/Phyg.java b/src/main/java/minicraft/entity/mob/Phyg.java index 4b72254a..7680df85 100644 --- a/src/main/java/minicraft/entity/mob/Phyg.java +++ b/src/main/java/minicraft/entity/mob/Phyg.java @@ -1,12 +1,12 @@ package minicraft.entity.mob; import minicraft.core.io.Settings; -import minicraft.entity.particle.HeartParticle; import minicraft.graphic.MobSprite; import minicraft.item.Items; public class Phyg extends SkyMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(20, 44); + private static final String[] sounds = new String[] {"pigSay1", "pigSay2", "pigSay3"}; /** * Creates a Phyg (Flying pig). @@ -18,31 +18,12 @@ public Phyg() { public void tick() { super.tick(); - Player player = getClosestPlayer(); - boolean holdingCarrot = player != null && player.activeItem != null && player.activeItem.name.equals("Carrot"); - - // Render heart particles - if (Settings.get("particles").equals(true) && holdingCarrot && random.nextInt(6) == 0) { - int randX = random.nextInt(10); - int randY = random.nextInt(9); - level.add(new HeartParticle(x - 9 + randX, y - 12 + randY)); - } - - if (holdingCarrot) { - int xd = player.x - x; - int yd = player.y - y; - - /// if player is less than 6.25 tiles away, then set move dir towards player - int sig0 = 1; // this prevents too precise estimates, preventing mobs from bobbing up and down. - xa = ya = 0; - - if (xd < sig0) xa = -1; - else if (xd > sig0) xa = 1; - if (yd < sig0) ya = -1; - else if (yd > sig0) ya = 1; - } else { - randomizeWalkDir(false); - } + // follows to the player if holds a carrot + followOnHold(Items.get("Gold Carrot"), 5); + + if ((this.tickTime % (random.nextInt(100) + 120) == 0)) { + doPlaySound(sounds, 7); + } } public void die() { diff --git a/src/main/java/minicraft/entity/mob/Pig.java b/src/main/java/minicraft/entity/mob/Pig.java index e6dae2db..518d019c 100644 --- a/src/main/java/minicraft/entity/mob/Pig.java +++ b/src/main/java/minicraft/entity/mob/Pig.java @@ -1,12 +1,12 @@ package minicraft.entity.mob; import minicraft.core.io.Settings; -import minicraft.core.io.Sound; import minicraft.graphic.MobSprite; import minicraft.item.Items; public class Pig extends PassiveMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(10, 38); + private static final String[] sounds = new String[] {"pigSay1", "pigSay2", "pigSay3"}; /** * Creates a pig. @@ -23,16 +23,8 @@ public void tick() { followOnHold(Items.get("Carrot"), 5); // Pig sounds - if ((tickTime % (random.nextInt(100) + 120) == 0) && random.nextInt(8) == 0) { - if (random.nextBoolean()) { - if (!random.nextBoolean()) { - Sound.pigSay1.playOnLevel(this.x, this.y); - } else { - Sound.pigSay2.playOnLevel(this.x, this.y); - } - } else { - Sound.pigSay3.playOnLevel(this.x, this.y); - } + if ((this.tickTime % (random.nextInt(100) + 120) == 0)) { + doPlaySound(sounds, 7); } } diff --git a/src/main/java/minicraft/entity/mob/Player.java b/src/main/java/minicraft/entity/mob/Player.java index 833906ce..7194836d 100644 --- a/src/main/java/minicraft/entity/mob/Player.java +++ b/src/main/java/minicraft/entity/mob/Player.java @@ -407,7 +407,7 @@ public void tick() { World.scheduleLevelChange((onTile == Tiles.get("Stairs Up")) ? 1 : -1); // Decide whether to go up or down. onStairDelay = 10; // Resets delay, since the level has now been changed. - Sound.playerChangeLevel.playOnDisplay(); + Sound.play("playerChangeLevel"); return; // SKIPS the rest of the tick() method. } @@ -1152,7 +1152,7 @@ public void render(Screen screen) { /** What happens when the player interacts with a itemEntity */ public void pickupItem(ItemEntity itemEntity) { // pickup sound - Sound.playerPickup.playOnLevel(itemEntity.x, itemEntity.y); + Sound.playAt("playerPickup", itemEntity.x, itemEntity.y); // remove the picked-up item itemEntity.remove(); @@ -1308,7 +1308,7 @@ public void die() { if (activeItem != null) deathChest.getInventory().add(activeItem); if (currentArmor != null) deathChest.getInventory().add(currentArmor); - Sound.playerDeath.playOnLevel(this.x, this.y); + Sound.playAt("playerDeath", this.x, this.y); // Add the death chest to the world. World.levels[Game.currentLevel].add(deathChest); @@ -1368,7 +1368,7 @@ protected void doHurt(int damage, Direction attackDir) { if (this == Game.player) super.doHurt(healthDamage, attackDir); // Sets knockback, and takes away health. } - Sound.playerHurt.playOnLevel(this.x, this.y); + Sound.playAt("playerHurt", this.x, this.y); hurtTime = playerHurtTime; } @@ -1392,7 +1392,7 @@ private void directHurt(int damage, Direction attackDir) { if (this == Game.player) super.doHurt(healthDamage, attackDir); // Sets knockback, and takes away health. } - Sound.playerHurt.playOnLevel(this.x, this.y); + Sound.playAt("playerHurt", this.x, this.y); hurtTime = playerHurtTime; } diff --git a/src/main/java/minicraft/entity/mob/Sheep.java b/src/main/java/minicraft/entity/mob/Sheep.java index d6a4f6f6..6a6f68b9 100644 --- a/src/main/java/minicraft/entity/mob/Sheep.java +++ b/src/main/java/minicraft/entity/mob/Sheep.java @@ -2,9 +2,7 @@ import org.jetbrains.annotations.Nullable; -import minicraft.core.Updater; import minicraft.core.io.Settings; -import minicraft.core.io.Sound; import minicraft.entity.Direction; import minicraft.graphic.MobSprite; import minicraft.graphic.Screen; @@ -19,8 +17,9 @@ public class Sheep extends PassiveMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(0, 42); private static final MobSprite[][] cutSprites = MobSprite.compileMobSpriteAnimations(0, 44); + + private static final String[] sounds = new String[] {"sheepSay1", "sheepSay2", "sheepSay3"}; - private static final int WOOL_GROW_TIME = (3 * 60) * Updater.normalSpeed; // Three minutes // Cut public boolean sheared = false; @@ -71,18 +70,7 @@ public void tick() { level.add(new Goat(), x, y); } - // Sheep sounds - if (random.nextInt(8) == 4) { - if (random.nextBoolean()) { - if (!random.nextBoolean()) { - Sound.sheepSay1.playOnLevel(this.x, this.y); - } else { - Sound.sheepSay2.playOnLevel(this.x, this.y); - } - } else { - Sound.sheepSay3.playOnLevel(this.x, this.y); - } - } + doPlaySound(sounds, 8); } } diff --git a/src/main/java/minicraft/entity/mob/Sheepuff.java b/src/main/java/minicraft/entity/mob/Sheepuff.java index c96fb184..6ba0771f 100644 --- a/src/main/java/minicraft/entity/mob/Sheepuff.java +++ b/src/main/java/minicraft/entity/mob/Sheepuff.java @@ -1,12 +1,12 @@ package minicraft.entity.mob; import minicraft.core.io.Settings; -import minicraft.core.io.Sound; import minicraft.graphic.MobSprite; import minicraft.item.Items; public class Sheepuff extends SkyMob { private static final MobSprite[][] sprites = MobSprite.compileMobSpriteAnimations(20, 42); + private static final String[] sounds = new String[] {"sheepSay1", "sheepSay2", "sheepSay3"}; /** * Creates a Sheepuff (Floating sheep). @@ -18,20 +18,11 @@ public Sheepuff() { @Override public void tick() { super.tick(); - - followOnHold(3, "Sky Wart", false); - // Sheep sounds - if (tickTime / 8 % 24 == 0 && random.nextInt(8) == 4) { - if (random.nextBoolean()) { - if (!random.nextBoolean()) { - Sound.sheepSay1.playOnLevel(this.x, this.y); - } else { - Sound.sheepSay2.playOnLevel(this.x, this.y); - } - } else { - Sound.sheepSay3.playOnLevel(this.x, this.y); - } + followOnHold(Items.get("Sky Wart"), 3); + + if ((tickTime % (random.nextInt(100) + 120) == 0)) { + doPlaySound(sounds, 8); } } diff --git a/src/main/java/minicraft/entity/mob/SkyMob.java b/src/main/java/minicraft/entity/mob/SkyMob.java index 7fd94837..4a5cb17e 100644 --- a/src/main/java/minicraft/entity/mob/SkyMob.java +++ b/src/main/java/minicraft/entity/mob/SkyMob.java @@ -3,9 +3,9 @@ import minicraft.core.Game; import minicraft.core.Updater; import minicraft.core.io.Settings; -import minicraft.entity.particle.HeartParticle; import minicraft.graphic.MobSprite; import minicraft.graphic.Screen; +import minicraft.item.Item; import minicraft.level.Level; import minicraft.level.tile.Tile; import minicraft.level.tile.Tiles; @@ -47,10 +47,10 @@ public void randomizeWalkDir(boolean byChance) { } } - public void followOnHold(int followRadius, String item, boolean heartParticles) { + public void followOnHold(Item item, int followRadius) { Player player = level.getClosestPlayer(x, y); // This is true if the player isnt null, the active item also isnt null, the player is holding the item and within the followRadius - boolean holdingItem = player != null && player.activeItem != null && player.activeItem.name.equals(item) && player.isWithin(followRadius, this); + boolean holdingItem = player != null && player.activeItem != null && player.activeItem.equals(item) && player.isWithin(followRadius, this); if (holdingItem) { // get player walk direction @@ -68,12 +68,6 @@ public void followOnHold(int followRadius, String item, boolean heartParticles) } else { randomizeWalkDir(false); } - - if (heartParticles) { - if (Settings.get("particles").equals(true) && tickTime /8 %12 == 0) { - level.add(new HeartParticle(x - 2 + random.nextInt(8), y - 16)); - } - } } public void die() { diff --git a/src/main/java/minicraft/item/TileItem.java b/src/main/java/minicraft/item/TileItem.java index a9252f37..b3bebfcc 100644 --- a/src/main/java/minicraft/item/TileItem.java +++ b/src/main/java/minicraft/item/TileItem.java @@ -124,6 +124,7 @@ protected TileItem(String name, Sprite sprite, int count, String model, List soundMap = new HashMap<>(); - soundMap.put(0, new Sound[]{Sound.Theme_Surface, Sound.Theme_Cave, Sound.Theme_Peaceful, Sound.Theme_Peaceful}); - soundMap.put(-1, new Sound[]{Sound.Ambience1, Sound.Ambience2, Sound.Ambience3, Sound.Ambience4}); - soundMap.put(-2, new Sound[]{Sound.Theme_Cavern, Sound.Theme_Cavern_drip}); - soundMap.put(1, new Sound[]{Sound.Theme_Surface, Sound.Theme_Fall}); + Map soundMap = new HashMap<>(); + soundMap.put(0, new String[]{"musicTheme2", "musicTheme5", "musicTheme4"}); + soundMap.put(-1, new String[]{"Ambience1", "Ambience2", "Ambience3", "Ambience4"}); + soundMap.put(-2, new String[]{"musicTheme6", "musicTheme7"}); + soundMap.put(1, new String[]{"musicTheme2", "musicTheme1"}); if (soundMap.containsKey(depth)) { - Sound[] sounds = soundMap.get(depth); + String[] sounds = soundMap.get(depth); int randomNum = random.nextInt(sounds.length); - sounds[randomNum].playOnDisplay(); + Sound.play(sounds[randomNum]); } } diff --git a/src/main/java/minicraft/level/tile/AltarTile.java b/src/main/java/minicraft/level/tile/AltarTile.java index dd4c8c7e..52d6879a 100644 --- a/src/main/java/minicraft/level/tile/AltarTile.java +++ b/src/main/java/minicraft/level/tile/AltarTile.java @@ -114,7 +114,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { hurtDamage = damage = altarHealth; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/CactusTile.java b/src/main/java/minicraft/level/tile/CactusTile.java index a01f144c..b22b77bf 100644 --- a/src/main/java/minicraft/level/tile/CactusTile.java +++ b/src/main/java/minicraft/level/tile/CactusTile.java @@ -40,7 +40,7 @@ public boolean hurt(Level level, int x, int y, Mob source, int hurtDamage, Direc level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); if (damage >= cactusHealth) { - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.setTile(x, y, Tiles.get("Sand")); level.dropItem((x << 4) + 8, (y << 4) + 8, 2, 4, Items.get("Cactus")); } else { diff --git a/src/main/java/minicraft/level/tile/CloudCactusTile.java b/src/main/java/minicraft/level/tile/CloudCactusTile.java index 8bff8837..de825413 100644 --- a/src/main/java/minicraft/level/tile/CloudCactusTile.java +++ b/src/main/java/minicraft/level/tile/CloudCactusTile.java @@ -65,7 +65,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/CloudTile.java b/src/main/java/minicraft/level/tile/CloudTile.java index 1196b077..eeb7dd56 100644 --- a/src/main/java/minicraft/level/tile/CloudTile.java +++ b/src/main/java/minicraft/level/tile/CloudTile.java @@ -71,7 +71,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel && player.payStamina(5)) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); /* If the current level is the sky then when breaking the diff --git a/src/main/java/minicraft/level/tile/DirtTile.java b/src/main/java/minicraft/level/tile/DirtTile.java index 46437118..ffda30ac 100644 --- a/src/main/java/minicraft/level/tile/DirtTile.java +++ b/src/main/java/minicraft/level/tile/DirtTile.java @@ -49,7 +49,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Hole")); level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get("Dirt")); @@ -62,7 +62,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D } if (tool.type == ToolType.Hoe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Farmland")); return true; } diff --git a/src/main/java/minicraft/level/tile/DoorTile.java b/src/main/java/minicraft/level/tile/DoorTile.java index c94925e2..a4de0f14 100644 --- a/src/main/java/minicraft/level/tile/DoorTile.java +++ b/src/main/java/minicraft/level/tile/DoorTile.java @@ -63,7 +63,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == type.getRequiredTool()) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get(id + 6)); // will get the corresponding floor tile. level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get(type.name() + " Door")); return true; diff --git a/src/main/java/minicraft/level/tile/FerrositeTile.java b/src/main/java/minicraft/level/tile/FerrositeTile.java index d6de9caf..b2e1877d 100644 --- a/src/main/java/minicraft/level/tile/FerrositeTile.java +++ b/src/main/java/minicraft/level/tile/FerrositeTile.java @@ -67,7 +67,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel && player.payStamina(5)) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); /* If the current level is the sky then when breaking the diff --git a/src/main/java/minicraft/level/tile/FloorTile.java b/src/main/java/minicraft/level/tile/FloorTile.java index 354e4889..46f55218 100644 --- a/src/main/java/minicraft/level/tile/FloorTile.java +++ b/src/main/java/minicraft/level/tile/FloorTile.java @@ -51,7 +51,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (tool.type == type.getRequiredTool()) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); if (level.depth == 1) { level.setTile(xt, yt, Tiles.get("Cloud hole")); diff --git a/src/main/java/minicraft/level/tile/FlowerTile.java b/src/main/java/minicraft/level/tile/FlowerTile.java index 80c341a4..7e9286dd 100644 --- a/src/main/java/minicraft/level/tile/FlowerTile.java +++ b/src/main/java/minicraft/level/tile/FlowerTile.java @@ -87,7 +87,7 @@ public boolean interact(Level level, int x, int y, Player player, Item item, Dir if (toolType == ToolType.Shears) { if (player.payStamina(2 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.setTile(x, y, Tiles.get("Grass")); diff --git a/src/main/java/minicraft/level/tile/GrassTile.java b/src/main/java/minicraft/level/tile/GrassTile.java index ff0393a6..a17e44df 100644 --- a/src/main/java/minicraft/level/tile/GrassTile.java +++ b/src/main/java/minicraft/level/tile/GrassTile.java @@ -1,5 +1,7 @@ package minicraft.level.tile; +import minicraft.core.Updater; +import minicraft.core.Updater.Time; import minicraft.core.io.Sound; import minicraft.entity.Direction; import minicraft.entity.mob.Player; @@ -13,15 +15,20 @@ import minicraft.level.Level; public class GrassTile extends Tile { - private static final ConnectorSprite sprite = new ConnectorSprite(GrassTile.class, new Sprite(0, 11, 3, 3, 1), new Sprite(3, 11, 2, 2, 1)) { - @Override - public boolean connectsTo(Tile tile, boolean isSide) { - if (!isSide) { - return true; + + private static final ConnectorSprite sprite; + + static { + sprite = new ConnectorSprite(GrassTile.class, new Sprite(0, 11, 3, 3, 1), new Sprite(3, 11, 2, 2, 1)) { + @Override + public boolean connectsTo(Tile tile, boolean isSide) { + if (!isSide) { + return true; + } + return tile.connectsToGrass; } - return tile.connectsToGrass; - } - }; + }; + } protected GrassTile(String name) { super(name, sprite); @@ -42,9 +49,9 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); - if (random.nextInt(5) == 0) { // 20% chance to drop seeds - level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Seeds")); + Sound.playAt("genericHurt", xt << 4, yt << 4); + if (random.nextInt(10) == 0) { // 20% chance to drop seeds + level.dropItem((xt << 4) + 8, (yt << 4) + 8, 1, Items.get("Seeds")); } level.setTile(xt, yt, Tiles.get("Dirt")); @@ -53,7 +60,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D } } else if (toolType == ToolType.Hoe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Dirt")); @@ -67,12 +74,12 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D } } else if (toolType == ToolType.Pickaxe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("path")); - if (random.nextInt(5) == 0) { // 20% chance to drop seeds - level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Seeds")); + if (random.nextInt(10) == 0) { // 20% chance to drop seeds + level.dropItem((xt << 4) + 8, (yt << 4) + 8, 1, Items.get("Seeds")); } return true; } @@ -99,9 +106,14 @@ public boolean tick(Level level, int xt, int yt) { case 1: yn += random.nextInt(2) * 2 - 1; break; } - if (level.getTile(xn, yn) == Tiles.get("Dirt")) { - level.setTile(xn, yn, this); + if (Updater.getTime() != Time.Night) { + if (level.getTile(xn, yn) == Tiles.get("Dirt")) { + level.setTile(xn, yn, this); + } else if (tickCount % 8192 == 0) { + level.setTile(xt, yt, Tiles.get("Lawn"), (short) random.nextInt(2)); + } } + return false; } } diff --git a/src/main/java/minicraft/level/tile/HardRockTile.java b/src/main/java/minicraft/level/tile/HardRockTile.java index 7190bcda..4db9cfb5 100644 --- a/src/main/java/minicraft/level/tile/HardRockTile.java +++ b/src/main/java/minicraft/level/tile/HardRockTile.java @@ -66,7 +66,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { hurtDamage = damage = hardrockHealth; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); if (damage <= 30) { diff --git a/src/main/java/minicraft/level/tile/HolyRockTile.java b/src/main/java/minicraft/level/tile/HolyRockTile.java index 5f6c2ed2..644501c9 100644 --- a/src/main/java/minicraft/level/tile/HolyRockTile.java +++ b/src/main/java/minicraft/level/tile/HolyRockTile.java @@ -73,7 +73,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { coalLvl = 1; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/IceSpikeTile.java b/src/main/java/minicraft/level/tile/IceSpikeTile.java index a3622515..c8546fe2 100644 --- a/src/main/java/minicraft/level/tile/IceSpikeTile.java +++ b/src/main/java/minicraft/level/tile/IceSpikeTile.java @@ -45,7 +45,7 @@ public boolean hurt(Level level, int x, int y, Mob source, int hurtDamage, Direc level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.BLUE)); if (damage >= iceHealth) { - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.setTile(x, y, Tiles.get("Snow")); level.dropItem((x << 4) + 8, (y << 4) + 8, 2, 4, Items.get("Icicle")); diff --git a/src/main/java/minicraft/level/tile/IceTile.java b/src/main/java/minicraft/level/tile/IceTile.java index b638875a..8b69e761 100644 --- a/src/main/java/minicraft/level/tile/IceTile.java +++ b/src/main/java/minicraft/level/tile/IceTile.java @@ -38,7 +38,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Pickaxe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Water")); //level.dropItem(xt *16 + 8, yt * 16 + 8, 0, 3, Items.get("Ice")); return true; diff --git a/src/main/java/minicraft/level/tile/LavaBrickTile.java b/src/main/java/minicraft/level/tile/LavaBrickTile.java index 1a56e8dd..bd0408d3 100644 --- a/src/main/java/minicraft/level/tile/LavaBrickTile.java +++ b/src/main/java/minicraft/level/tile/LavaBrickTile.java @@ -37,7 +37,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Pickaxe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Lava")); return true; } diff --git a/src/main/java/minicraft/level/tile/LavaTile.java b/src/main/java/minicraft/level/tile/LavaTile.java index 176f1f3c..e10e1b29 100644 --- a/src/main/java/minicraft/level/tile/LavaTile.java +++ b/src/main/java/minicraft/level/tile/LavaTile.java @@ -7,13 +7,16 @@ import minicraft.level.Level; public class LavaTile extends Tile { - private ConnectorSprite sprite = new ConnectorSprite(LavaTile.class, new Sprite(27, 21, 3, 3, 1), Sprite.dots(0)) { - public boolean connectsTo(Tile tile, boolean isSide) { - return tile.connectsToFluid; - } - }; - private Tile holeTile = Tiles.get("Hole"); + private static final ConnectorSprite sprite; + + static { + sprite = new ConnectorSprite(LavaTile.class, new Sprite(27, 21, 3, 3, 1), Sprite.dots(0)) { + public boolean connectsTo(Tile tile, boolean isSide) { + return tile.connectsToFluid; + } + }; + } protected LavaTile(String name) { super(name, (ConnectorSprite) null); @@ -49,7 +52,7 @@ public boolean tick(Level level, int xt, int yt) { } - if (level.getTile(xn, yn) == holeTile) { + if (level.getTile(xn, yn) == Tiles.get("Hole")) { level.setTile(xn, yn, this); } return false; diff --git a/src/main/java/minicraft/level/tile/LawnTile.java b/src/main/java/minicraft/level/tile/LawnTile.java index 1ad781a5..97b5e512 100644 --- a/src/main/java/minicraft/level/tile/LawnTile.java +++ b/src/main/java/minicraft/level/tile/LawnTile.java @@ -67,8 +67,8 @@ public boolean interact(Level level, int x, int y, Player player, Item item, Dir level.setTile(x, y, Tiles.get("Grass")); //Sound.genericHurt.playOnDisplay(); - if (random.nextInt(3) == 1) { // 28% chance to drop Seeds - level.dropItem((x << 4) + 8, (y << 4) + 8, Items.get("Seeds")); + if (random.nextInt(3) == 0) { // 28% chance to drop Seeds + level.dropItem((x << 4) + 8, (y << 4) + 8, 2, Items.get("Seeds")); } return true; @@ -78,8 +78,8 @@ public boolean interact(Level level, int x, int y, Player player, Item item, Dir } public boolean hurt(Level level, int x, int y, Mob source, int hurtDamage, Direction attackDir) { - if (random.nextInt(6) == 1) { // 20% chance to drop sky seeds - level.dropItem((x << 4) + 8, (y << 4) + 8, 0, 1, Items.get("Seeds")); + if (random.nextInt(3) == 0) { // 20% chance to drop sky seeds + level.dropItem((x << 4) + 8, (y << 4) + 8, 1, 2, Items.get("Seeds")); } level.setTile(x, y, Tiles.get("Grass")); diff --git a/src/main/java/minicraft/level/tile/MossyRockTile.java b/src/main/java/minicraft/level/tile/MossyRockTile.java index 01a6b4e8..e41459ec 100644 --- a/src/main/java/minicraft/level/tile/MossyRockTile.java +++ b/src/main/java/minicraft/level/tile/MossyRockTile.java @@ -47,7 +47,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { dropCoal = true; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); if (damage >= maxHealth) { diff --git a/src/main/java/minicraft/level/tile/MushroomTile.java b/src/main/java/minicraft/level/tile/MushroomTile.java index f5fdb213..cd885297 100644 --- a/src/main/java/minicraft/level/tile/MushroomTile.java +++ b/src/main/java/minicraft/level/tile/MushroomTile.java @@ -47,7 +47,7 @@ public boolean interact(Level level, int x, int y, Player player, Item item, Dir if (toolType == ToolType.Shovel) { if (player.payStamina(2 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x << 4, y << 4); level.setTile(x, y, Tiles.get("Mycelium")); level.dropItem((x << 4) + 8, (y << 4) + 8, Items.get(type.loot)); return true; diff --git a/src/main/java/minicraft/level/tile/MyceliumTile.java b/src/main/java/minicraft/level/tile/MyceliumTile.java index 528da249..bc323a7e 100644 --- a/src/main/java/minicraft/level/tile/MyceliumTile.java +++ b/src/main/java/minicraft/level/tile/MyceliumTile.java @@ -42,7 +42,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { level.setTile(xt, yt, Tiles.get("Dirt")); - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); if (random.nextInt(5) == 0) { // 20% chance to drop seeds level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Seeds")); @@ -54,7 +54,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Hoe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { level.setTile(xt, yt, Tiles.get("Dirt")); - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); if (random.nextInt(15) == 0) { // 80% chance to drop seeds level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get("Seeds")); @@ -69,7 +69,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Pickaxe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { level.setTile(xt, yt, Tiles.get("path")); - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); if (random.nextInt(5) == 0) { // 20% chance to drop seeds level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Seeds")); diff --git a/src/main/java/minicraft/level/tile/ObsidianTile.java b/src/main/java/minicraft/level/tile/ObsidianTile.java index 0418cc9c..2fb334c5 100644 --- a/src/main/java/minicraft/level/tile/ObsidianTile.java +++ b/src/main/java/minicraft/level/tile/ObsidianTile.java @@ -53,10 +53,10 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolType toolType = tool.type; if (toolType == ToolType.Pickaxe && tool.level != 4) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); } else { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Hole")); level.dropItem((xt << 4) + 8, (yt << 4) + 8, 1, 3, Items.get("Obsidian")); return true; diff --git a/src/main/java/minicraft/level/tile/OreTile.java b/src/main/java/minicraft/level/tile/OreTile.java index a1014c7b..8f06d58c 100644 --- a/src/main/java/minicraft/level/tile/OreTile.java +++ b/src/main/java/minicraft/level/tile/OreTile.java @@ -64,7 +64,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { hurtDamage = damage = oreHealth; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/RockTile.java b/src/main/java/minicraft/level/tile/RockTile.java index 0503957f..b2d380b5 100644 --- a/src/main/java/minicraft/level/tile/RockTile.java +++ b/src/main/java/minicraft/level/tile/RockTile.java @@ -58,7 +58,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { dropCoal = true; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/SandRockTile.java b/src/main/java/minicraft/level/tile/SandRockTile.java index c43d2bc1..c43a147e 100644 --- a/src/main/java/minicraft/level/tile/SandRockTile.java +++ b/src/main/java/minicraft/level/tile/SandRockTile.java @@ -73,7 +73,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { coalLvl = 1; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/SandTile.java b/src/main/java/minicraft/level/tile/SandTile.java index 82da5c86..30c8cb5d 100644 --- a/src/main/java/minicraft/level/tile/SandTile.java +++ b/src/main/java/minicraft/level/tile/SandTile.java @@ -67,7 +67,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Dirt")); level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get("Sand")); return true; diff --git a/src/main/java/minicraft/level/tile/SaplingTile.java b/src/main/java/minicraft/level/tile/SaplingTile.java index 2b3d89bb..fad83639 100644 --- a/src/main/java/minicraft/level/tile/SaplingTile.java +++ b/src/main/java/minicraft/level/tile/SaplingTile.java @@ -46,7 +46,7 @@ public boolean tick(Level level, int x, int y) { @Override public boolean hurt(Level level, int x, int y, Mob source, int hurtDamage, Direction attackDir) { - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); level.setTile(x, y, onType); return true; } diff --git a/src/main/java/minicraft/level/tile/SkyFernTile.java b/src/main/java/minicraft/level/tile/SkyFernTile.java index 1b9f34b8..0f071e57 100644 --- a/src/main/java/minicraft/level/tile/SkyFernTile.java +++ b/src/main/java/minicraft/level/tile/SkyFernTile.java @@ -79,7 +79,7 @@ public boolean interact(Level level, int x, int y, Player player, Item item, Dir ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(2 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); level.setTile(x, y, Tiles.get("Sky Grass")); diff --git a/src/main/java/minicraft/level/tile/SkyGrassTile.java b/src/main/java/minicraft/level/tile/SkyGrassTile.java index 9b114215..4629f1cc 100644 --- a/src/main/java/minicraft/level/tile/SkyGrassTile.java +++ b/src/main/java/minicraft/level/tile/SkyGrassTile.java @@ -76,7 +76,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Ferrosite")); // would allow you to shovel cloud, I think. if (random.nextInt(20) == 0) { // 20% chance to drop sky seeds level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Sky Seeds")); @@ -88,7 +88,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Hoe) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Sky Farmland")); return true; } diff --git a/src/main/java/minicraft/level/tile/SkyHighGrassTile.java b/src/main/java/minicraft/level/tile/SkyHighGrassTile.java index d1c11d83..56019fca 100644 --- a/src/main/java/minicraft/level/tile/SkyHighGrassTile.java +++ b/src/main/java/minicraft/level/tile/SkyHighGrassTile.java @@ -65,7 +65,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Sky grass")); // would allow you to shovel cloud, I think. if (random.nextInt(5) == 0) { // 45% chance to drop sky dirt level.dropItem((xt << 4) + 8, (yt << 4) + 8, 2, Items.get("Sky dirt")); @@ -76,7 +76,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (tool.type == ToolType.Pickaxe) { if (player.payStamina(1 - tool.level)) { // level.setTile(xt, yt, Tiles.get("path")); - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); } } } diff --git a/src/main/java/minicraft/level/tile/SproutTile.java b/src/main/java/minicraft/level/tile/SproutTile.java index bb3077d8..ff0e228a 100644 --- a/src/main/java/minicraft/level/tile/SproutTile.java +++ b/src/main/java/minicraft/level/tile/SproutTile.java @@ -51,7 +51,7 @@ public boolean tick(Level level, int x, int y) { @Override public boolean hurt(Level level, int x, int y, Mob source, int hurtDamage, Direction attackDir) { - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); level.setTile(x, y, onType); return true; } diff --git a/src/main/java/minicraft/level/tile/StairsTile.java b/src/main/java/minicraft/level/tile/StairsTile.java index d29d93c0..53018016 100644 --- a/src/main/java/minicraft/level/tile/StairsTile.java +++ b/src/main/java/minicraft/level/tile/StairsTile.java @@ -31,7 +31,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D // Makes it so you can remove the stairs if you are in creative and debug mode. if (item instanceof PowerGloveItem && Game.isMode("Creative") && Game.debug) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Grass")); return true; } else { diff --git a/src/main/java/minicraft/level/tile/TorchTile.java b/src/main/java/minicraft/level/tile/TorchTile.java index 3c22d673..4d34af9a 100644 --- a/src/main/java/minicraft/level/tile/TorchTile.java +++ b/src/main/java/minicraft/level/tile/TorchTile.java @@ -92,7 +92,7 @@ public int getLightRadius(Level level, int x, int y) { @Override public boolean interact(Level level, int xt, int yt, Player player, Item item, Direction attackDir) { if (item instanceof PowerGloveItem) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, this.onType); level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get("Torch")); return true; diff --git a/src/main/java/minicraft/level/tile/TreeTile.java b/src/main/java/minicraft/level/tile/TreeTile.java index fadd1789..4ced1408 100644 --- a/src/main/java/minicraft/level/tile/TreeTile.java +++ b/src/main/java/minicraft/level/tile/TreeTile.java @@ -193,7 +193,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { hurtDamage = damage = treeHealth; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/UpRockTile.java b/src/main/java/minicraft/level/tile/UpRockTile.java index 8b6595ca..a977f6e4 100644 --- a/src/main/java/minicraft/level/tile/UpRockTile.java +++ b/src/main/java/minicraft/level/tile/UpRockTile.java @@ -79,7 +79,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { dropCoal = true; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.DARK_RED)); diff --git a/src/main/java/minicraft/level/tile/WallTile.java b/src/main/java/minicraft/level/tile/WallTile.java index 80578249..affe5587 100644 --- a/src/main/java/minicraft/level/tile/WallTile.java +++ b/src/main/java/minicraft/level/tile/WallTile.java @@ -127,7 +127,7 @@ public void hurt(Level level, int x, int y, int hurtDamage) { hurtDamage = damage = sbwHealth; } - Sound.genericHurt.playOnLevel(x << 4, y << 4); + Sound.playAt("genericHurt", x << 4, y << 4); level.add(new SmashParticle(x << 4, y << 4)); level.add(new TextParticle("" + hurtDamage, (x << 4) + 8, (y << 4) + 8, Color.RED)); diff --git a/src/main/java/minicraft/level/tile/WaterTile.java b/src/main/java/minicraft/level/tile/WaterTile.java index 37662db5..2bbb16a4 100644 --- a/src/main/java/minicraft/level/tile/WaterTile.java +++ b/src/main/java/minicraft/level/tile/WaterTile.java @@ -7,12 +7,16 @@ import minicraft.level.Level; public class WaterTile extends Tile { - private ConnectorSprite sprite = new ConnectorSprite(WaterTile.class, new Sprite(18, 21, 3, 3, 1), Sprite.dots(0)) { - @Override - public boolean connectsTo(Tile tile, boolean isSide) { - return tile.connectsToFluid; - } - }; + private static final ConnectorSprite sprite; + + static { + sprite = new ConnectorSprite(WaterTile.class, new Sprite(18, 21, 3, 3, 1), Sprite.dots(0)) { + @Override + public boolean connectsTo(Tile tile, boolean isSide) { + return tile.connectsToFluid; + } + }; + } protected WaterTile(String name) { super(name, (ConnectorSprite) null); diff --git a/src/main/java/minicraft/level/tile/WoolTile.java b/src/main/java/minicraft/level/tile/WoolTile.java index 3583c9e6..84330946 100644 --- a/src/main/java/minicraft/level/tile/WoolTile.java +++ b/src/main/java/minicraft/level/tile/WoolTile.java @@ -58,7 +58,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D if (toolType == ToolType.Shears) { if (player.payStamina(3 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Hole")); level.dropItem((xt << 4) + 8, (yt << 4) + 8, Items.get(name)); return true; diff --git a/src/main/java/minicraft/level/tile/farming/CarrotTile.java b/src/main/java/minicraft/level/tile/farming/CarrotTile.java index 003c3ce5..fd3f5192 100644 --- a/src/main/java/minicraft/level/tile/farming/CarrotTile.java +++ b/src/main/java/minicraft/level/tile/farming/CarrotTile.java @@ -40,7 +40,7 @@ protected void harvest(Level level, int x, int y, Entity entity) { } // Play sound. - Sound.genericHurt.playOnDisplay(); + Sound.playAt("genericHurt", x, y); if (random.nextBoolean()) { level.setTile(x, y, Tiles.get("Dirt")); @@ -73,7 +73,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnDisplay(); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Dirt")); return true; } diff --git a/src/main/java/minicraft/level/tile/farming/FarmTile.java b/src/main/java/minicraft/level/tile/farming/FarmTile.java index 34708142..ab69d46f 100644 --- a/src/main/java/minicraft/level/tile/farming/FarmTile.java +++ b/src/main/java/minicraft/level/tile/farming/FarmTile.java @@ -38,7 +38,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnDisplay(); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Dirt")); return true; } @@ -74,11 +74,11 @@ public void steppedOn(Level level, int xt, int yt, Entity entity) { switch (random.nextInt(3)) { - case 0: Sound.Tile_farmland.playOnDisplay(); break; - case 1: Sound.Tile_farmland_2.playOnDisplay(); break; - case 2: Sound.Tile_farmland_3.playOnDisplay(); break; + case 0: Sound.play("Tile_farmland"); break; + case 1: Sound.play("Tile_farmland_2"); break; + case 2: Sound.play("Tile_farmland_3"); break; default: - Sound.Tile_farmland.playOnDisplay(); break; + Sound.play("Tile_farmland"); break; } } } \ No newline at end of file diff --git a/src/main/java/minicraft/level/tile/farming/ParsnipTile.java b/src/main/java/minicraft/level/tile/farming/ParsnipTile.java index 22bd3ed5..aac5a52c 100644 --- a/src/main/java/minicraft/level/tile/farming/ParsnipTile.java +++ b/src/main/java/minicraft/level/tile/farming/ParsnipTile.java @@ -1,5 +1,6 @@ package minicraft.level.tile.farming; +import minicraft.core.io.Sound; import minicraft.entity.Entity; import minicraft.entity.ItemEntity; import minicraft.entity.mob.Player; @@ -48,14 +49,14 @@ protected void harvest(Level level, int x, int y, Entity entity) { int age = level.getData(x, y); - // level.dropItem(x*16+8, y*16+8, 1, 2, Items.get("seeds")); - int count = 0; if (age >= maxAge) { count = random.nextInt(3) + 2; } else if (age >= maxAge - maxAge / 5) { count = random.nextInt(2); } + + Sound.playAt("genericHurt", x, y); level.dropItem((x << 4) + 8, (y << 4) + 8, count, Items.get("Gold Carrot")); diff --git a/src/main/java/minicraft/level/tile/farming/Plant.java b/src/main/java/minicraft/level/tile/farming/Plant.java index d9488a09..09e8b3b4 100644 --- a/src/main/java/minicraft/level/tile/farming/Plant.java +++ b/src/main/java/minicraft/level/tile/farming/Plant.java @@ -86,7 +86,7 @@ protected void harvest(Level level, int x, int y, Entity entity) { ((Player) entity).addScore(random.nextInt(5) + 1); } - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); if (random.nextBoolean()) { level.setTile(x, y, Tiles.get("Dirt")); diff --git a/src/main/java/minicraft/level/tile/farming/PotatoTile.java b/src/main/java/minicraft/level/tile/farming/PotatoTile.java index 5866f95c..a09905f9 100644 --- a/src/main/java/minicraft/level/tile/farming/PotatoTile.java +++ b/src/main/java/minicraft/level/tile/farming/PotatoTile.java @@ -62,7 +62,7 @@ protected void harvest(Level level, int x, int y, Entity entity) { } // Play sound - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); if (random.nextBoolean()) { level.setTile(x, y, Tiles.get("Dirt")); diff --git a/src/main/java/minicraft/level/tile/farming/SkyFarmTile.java b/src/main/java/minicraft/level/tile/farming/SkyFarmTile.java index 2165c1e0..566fce0b 100644 --- a/src/main/java/minicraft/level/tile/farming/SkyFarmTile.java +++ b/src/main/java/minicraft/level/tile/farming/SkyFarmTile.java @@ -35,7 +35,7 @@ public boolean interact(Level level, int xt, int yt, Player player, Item item, D ToolItem tool = (ToolItem) item; if (tool.type == ToolType.Shovel) { if (player.payStamina(4 - tool.level) && tool.payDurability()) { - Sound.genericHurt.playOnLevel(xt << 4, yt << 4); + Sound.playAt("genericHurt", xt << 4, yt << 4); level.setTile(xt, yt, Tiles.get("Sky dirt")); return true; } diff --git a/src/main/java/minicraft/level/tile/farming/SkyPlant.java b/src/main/java/minicraft/level/tile/farming/SkyPlant.java index aeedf490..cb670e6a 100644 --- a/src/main/java/minicraft/level/tile/farming/SkyPlant.java +++ b/src/main/java/minicraft/level/tile/farming/SkyPlant.java @@ -1,5 +1,6 @@ package minicraft.level.tile.farming; +import minicraft.core.io.Sound; import minicraft.entity.Direction; import minicraft.entity.Entity; import minicraft.entity.ItemEntity; @@ -83,6 +84,8 @@ protected void harvest(Level level, int x, int y, Entity entity) { } else if (age >= maxAge - maxAge / 5) { count = random.nextInt(2) + 1; } + + Sound.playAt("genericHurt", x, y); level.dropItem((x << 4) + 8, (y << 4) + 8, count, Items.get(name)); diff --git a/src/main/java/minicraft/level/tile/farming/SkyWartTile.java b/src/main/java/minicraft/level/tile/farming/SkyWartTile.java index 750ba8d7..13c48b65 100644 --- a/src/main/java/minicraft/level/tile/farming/SkyWartTile.java +++ b/src/main/java/minicraft/level/tile/farming/SkyWartTile.java @@ -1,5 +1,6 @@ package minicraft.level.tile.farming; +import minicraft.core.io.Sound; import minicraft.entity.Entity; import minicraft.entity.ItemEntity; import minicraft.entity.mob.Player; @@ -46,14 +47,14 @@ protected void harvest(Level level, int x, int y, Entity entity) { return; int age = level.getData(x, y); - // level.dropItem(x*16+8, y*16+8, 1, 2, Items.get("seeds")); - int count = 0; if (age >= maxAge) { count = random.nextInt(3) + 2; } else if (age >= maxAge - maxAge / 5) { count = random.nextInt(2); } + + Sound.playAt("genericHurt", x, y); level.dropItem((x << 4) + 8, (y << 4) + 8, count, Items.get("Sky wart")); diff --git a/src/main/java/minicraft/level/tile/farming/WheatTile.java b/src/main/java/minicraft/level/tile/farming/WheatTile.java index 7cc579c0..346b238e 100644 --- a/src/main/java/minicraft/level/tile/farming/WheatTile.java +++ b/src/main/java/minicraft/level/tile/farming/WheatTile.java @@ -66,7 +66,7 @@ protected void harvest(Level level, int x, int y, Entity entity) { } // Play sound. - Sound.genericHurt.playOnLevel(x, y); + Sound.playAt("genericHurt", x, y); if (random.nextBoolean()) { level.setTile(x, y, Tiles.get("Dirt")); diff --git a/src/main/java/minicraft/saveload/Load.java b/src/main/java/minicraft/saveload/Load.java index dcb6cb17..04902312 100644 --- a/src/main/java/minicraft/saveload/Load.java +++ b/src/main/java/minicraft/saveload/Load.java @@ -523,7 +523,7 @@ private void loadWorld(String filename) { if (Tiles.oldids.get(tileID) != null) { tilename = Tiles.oldids.get(tileID); } else { - Logger.warn("Tile list doesn't contain tile " + tileID); + Logger.warn("Tile list doesn't contain tile {}", tileID); tilename = "grass"; } } @@ -948,7 +948,7 @@ public static Entity loadEntity(String entityData, Version worldSaveVersion, boo } if (mobLvl == 0) { - if (Game.debug) Logger.info("Level 0 mob: " + entityName); + if (Game.debug) Logger.info("Level 0 mob: {}", entityName); mobLvl = 1; } diff --git a/src/main/java/minicraft/screen/AchievementsDisplay.java b/src/main/java/minicraft/screen/AchievementsDisplay.java index 668c028d..36d7baba 100644 --- a/src/main/java/minicraft/screen/AchievementsDisplay.java +++ b/src/main/java/minicraft/screen/AchievementsDisplay.java @@ -189,7 +189,7 @@ public void render(Screen screen) { @Override public void onExit() { // Play confirm sound. - Sound.Menu_confirm.playOnDisplay(); + Sound.play("Menu_confirm"); new Save(); } diff --git a/src/main/java/minicraft/screen/ChatDisplay.java b/src/main/java/minicraft/screen/ChatDisplay.java index 5d5eab62..6ad86dba 100644 --- a/src/main/java/minicraft/screen/ChatDisplay.java +++ b/src/main/java/minicraft/screen/ChatDisplay.java @@ -61,13 +61,13 @@ public void tick(InputHandler input) { // Play the sound effect if the command was recognized if (recognizedCommand) { - Sound.Menu_loaded.playOnDisplay(); + Sound.play("Menu_loaded"); } } else { String messageString = command.getUserInput(); Game.player.sendMessage(messageString); - Sound.Menu_back.playOnDisplay(); + Sound.play("Menu_back"); } command.clearUserInput(); diff --git a/src/main/java/minicraft/screen/CraftingDisplay.java b/src/main/java/minicraft/screen/CraftingDisplay.java index edb0ee5d..63a568a2 100644 --- a/src/main/java/minicraft/screen/CraftingDisplay.java +++ b/src/main/java/minicraft/screen/CraftingDisplay.java @@ -155,7 +155,7 @@ public void tick(InputHandler input) { selectedRecipe.craft(player); - Sound.playerCraft.playOnDisplay(); + Sound.play("playerCraft"); refreshData(); for (Recipe recipe : recipes) { diff --git a/src/main/java/minicraft/screen/Display.java b/src/main/java/minicraft/screen/Display.java index b635e3a7..c21173aa 100644 --- a/src/main/java/minicraft/screen/Display.java +++ b/src/main/java/minicraft/screen/Display.java @@ -89,7 +89,7 @@ public void tick(InputHandler input) { if (input.getKey(shift + "right").clicked) selection++; if (previousSelection != selection) { - Sound.Menu_select.playOnDisplay(); + Sound.play("Menu_select"); int delta = selection - previousSelection; selection = previousSelection; diff --git a/src/main/java/minicraft/screen/LoadingDisplay.java b/src/main/java/minicraft/screen/LoadingDisplay.java index 02777f71..8c5635b2 100644 --- a/src/main/java/minicraft/screen/LoadingDisplay.java +++ b/src/main/java/minicraft/screen/LoadingDisplay.java @@ -44,6 +44,13 @@ public void tick(InputHandler input) { @Override public void init(Display parent) { super.init(parent); + + Sound.stop("musicTheme5"); + Sound.stop("musicTheme6"); + Sound.stop("musicTheme1"); + Sound.stop("musicTheme4"); + Sound.stop("musicTheme2"); + percentage = 0; progressType = "World"; if (WorldSelectDisplay.hasLoadedWorld()) { @@ -99,11 +106,5 @@ public void render(Screen screen) { } Font.drawCentered(((progressType.length() > 0) ? (" " + Localization.getLocalized(progressType)) : ""), screen, Screen.h - 30, Color.get(1, 51)); - - Sound.Theme_Cave.stop(); - Sound.Theme_Cavern.stop(); - Sound.Theme_Fall.stop(); - Sound.Theme_Peaceful.stop(); - Sound.Theme_Surface.stop(); } } diff --git a/src/main/java/minicraft/screen/MeltingDisplay.java b/src/main/java/minicraft/screen/MeltingDisplay.java index a7690e9c..1738019a 100644 --- a/src/main/java/minicraft/screen/MeltingDisplay.java +++ b/src/main/java/minicraft/screen/MeltingDisplay.java @@ -115,7 +115,7 @@ public void tick(InputHandler input) { if (selctedRecipe.getCanCraft()) { selctedRecipe.craft(player); - Sound.playerCraft.playOnDisplay(); + Sound.play("playerCraft"); refreshData(); for (Recipe recipe : recipes) { diff --git a/src/main/java/minicraft/screen/Menu.java b/src/main/java/minicraft/screen/Menu.java index 42b11448..f7cbe054 100644 --- a/src/main/java/minicraft/screen/Menu.java +++ b/src/main/java/minicraft/screen/Menu.java @@ -294,7 +294,7 @@ public void tick(InputHandler input) { entries.get(selection).tick(input); // only ticks the entry on a frame where the selection cursor has not moved. return; } else { - Sound.Menu_select.playOnDisplay(); + Sound.play("Menu_select"); } do { diff --git a/src/main/java/minicraft/screen/TexturePackDisplay.java b/src/main/java/minicraft/screen/TexturePackDisplay.java index 49517ae2..c7134fbf 100644 --- a/src/main/java/minicraft/screen/TexturePackDisplay.java +++ b/src/main/java/minicraft/screen/TexturePackDisplay.java @@ -76,7 +76,7 @@ public TexturePackDisplay() { private static void update() { shouldUpdate = true; - Sound.Menu_loaded.playOnDisplay(); + Sound.play("Menu_loaded"); } private void updateSheets(Screen screen) throws IOException { diff --git a/src/main/java/minicraft/screen/TitleDisplay.java b/src/main/java/minicraft/screen/TitleDisplay.java index e2d38566..fe35b66a 100644 --- a/src/main/java/minicraft/screen/TitleDisplay.java +++ b/src/main/java/minicraft/screen/TitleDisplay.java @@ -109,12 +109,13 @@ public void init(Display parent) { Renderer.readyToRenderGameplay = false; if (TimeData.month() != Month.OCTOBER) { - switch (random.nextInt(4)) { - case 0: Sound.Theme_Cave.playOnDisplay(); break; - case 1: Sound.Theme_Surface.playOnDisplay(); break; - case 2: Sound.Theme_Fall.playOnDisplay(); break; - case 3: Sound.Theme_Peaceful.playOnDisplay(); break; - default: Sound.Theme_Fall.playOnDisplay(); break; + switch (random.nextInt(5)) { + case 0: Sound.play("musicTheme5"); break; + case 1: Sound.play("musicTheme2"); break; + case 2: Sound.play("musicTheme1"); break; + case 3: Sound.play("musicTheme4"); break; + case 4: Sound.play("musicTheme8"); break; + default: Sound.play("musicTheme3"); break; } } @@ -146,8 +147,8 @@ public void init(Display parent) { } if (TimeData.month() == Month.OCTOBER) { - if (TimeData.day() == 8) Sound.Theme_Cavern.playOnDisplay(); - if (TimeData.day() == 16) Sound.Theme_Cavern_drip.playOnDisplay(); + if (TimeData.day() == 8) Sound.play("musicTheme6"); + if (TimeData.day() == 16) Sound.play("musicTheme7"); } if (TimeData.month() == Month.AUGUST) { diff --git a/src/main/java/minicraft/screen/WorldEditDisplay.java b/src/main/java/minicraft/screen/WorldEditDisplay.java index ded525dd..a7e9f111 100644 --- a/src/main/java/minicraft/screen/WorldEditDisplay.java +++ b/src/main/java/minicraft/screen/WorldEditDisplay.java @@ -144,7 +144,7 @@ public void tick(InputHandler input) { confirm = false; - Sound.Menu_select.playOnDisplay(); + Sound.play("Menu_select"); if (!WorldSelectDisplay.getWorldNames().isEmpty()) { Game.setDisplay(new WorldSelectDisplay()); diff --git a/src/main/java/minicraft/screen/entry/ArrayEntry.java b/src/main/java/minicraft/screen/entry/ArrayEntry.java index 69337ca3..e13c08c9 100644 --- a/src/main/java/minicraft/screen/entry/ArrayEntry.java +++ b/src/main/java/minicraft/screen/entry/ArrayEntry.java @@ -119,7 +119,7 @@ public void tick(InputHandler input) { if (input.getKey("cursor-right").clicked) selection++; if (previousSelection != selection) { - Sound.Menu_select.playOnDisplay(); + Sound.play("Menu_select"); moveSelection(selection - previousSelection); } } diff --git a/src/main/java/minicraft/screen/entry/SelectEntry.java b/src/main/java/minicraft/screen/entry/SelectEntry.java index 026dee38..c29edd79 100644 --- a/src/main/java/minicraft/screen/entry/SelectEntry.java +++ b/src/main/java/minicraft/screen/entry/SelectEntry.java @@ -46,7 +46,7 @@ public String getText() { @Override public void tick(InputHandler input) { if (input.getKey("select").clicked && onSelect != null) { - Sound.Menu_confirm.playOnDisplay(); + Sound.play("Menu_confirm"); onSelect.act(); } } diff --git a/src/main/java/minicraft/util/Utils.java b/src/main/java/minicraft/util/Utils.java index 08129022..6304807f 100644 --- a/src/main/java/minicraft/util/Utils.java +++ b/src/main/java/minicraft/util/Utils.java @@ -56,8 +56,7 @@ public static void sleep(int millis) { public static int percentage(int current, int total) { return (current * 100) / total; } - - + /** Get the free JVM memory in Mbs **/ public static long freeMemory() { @@ -101,7 +100,7 @@ public static String getGeneralMemoryUsage() { } public static String getMemoryAllocationRate() { - long heapAllocationRate = heapMemory() / 1024; // Convert to MiB + long heapAllocationRate = heapMemory() / 1024; return String.format("R: %03dMB /s", heapAllocationRate); } diff --git a/src/main/resources/resources/sounds/entities/Skeleton/skeleton hurt.wav b/src/main/resources/resources/sounds/entities/Skeleton/skeleton hurt.wav deleted file mode 100644 index c2474ce1..00000000 Binary files a/src/main/resources/resources/sounds/entities/Skeleton/skeleton hurt.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/entities/Spark/spawn.wav b/src/main/resources/resources/sounds/entities/Spark/spawn.wav deleted file mode 100644 index 48b553a5..00000000 Binary files a/src/main/resources/resources/sounds/entities/Spark/spawn.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/entities/Villager/villager hurt.wav b/src/main/resources/resources/sounds/entities/Villager/villager hurt.wav deleted file mode 100644 index c2474ce1..00000000 Binary files a/src/main/resources/resources/sounds/entities/Villager/villager hurt.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/entities/Zombie/zombie hurt.wav b/src/main/resources/resources/sounds/entities/Zombie/zombie hurt.wav deleted file mode 100644 index c2474ce1..00000000 Binary files a/src/main/resources/resources/sounds/entities/Zombie/zombie hurt.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/entities/Spawner/destroy.wav b/src/main/resources/resources/sounds/furniture/spawner/destroy1.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Spawner/destroy.wav rename to src/main/resources/resources/sounds/furniture/spawner/destroy1.wav diff --git a/src/main/resources/resources/sounds/entities/Spawner/destroy 2.wav b/src/main/resources/resources/sounds/furniture/spawner/destroy2.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Spawner/destroy 2.wav rename to src/main/resources/resources/sounds/furniture/spawner/destroy2.wav diff --git a/src/main/resources/resources/sounds/entities/Spawner/destroy 3.wav b/src/main/resources/resources/sounds/furniture/spawner/destroy3.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Spawner/destroy 3.wav rename to src/main/resources/resources/sounds/furniture/spawner/destroy3.wav diff --git a/src/main/resources/resources/sounds/entities/Spawner/hurt.wav b/src/main/resources/resources/sounds/furniture/spawner/hurt.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Spawner/hurt.wav rename to src/main/resources/resources/sounds/furniture/spawner/hurt.wav diff --git a/src/main/resources/resources/sounds/entities/Spawner/spawn.wav b/src/main/resources/resources/sounds/furniture/spawner/spawn.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Spawner/spawn.wav rename to src/main/resources/resources/sounds/furniture/spawner/spawn.wav diff --git a/src/main/resources/resources/sounds/entities/EyeQueen/changephase.wav b/src/main/resources/resources/sounds/mob/eyequeen/changephase.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/EyeQueen/changephase.wav rename to src/main/resources/resources/sounds/mob/eyequeen/changephase.wav diff --git a/src/main/resources/resources/sounds/entities/EyeQueen/eyedeath.wav b/src/main/resources/resources/sounds/mob/eyequeen/eyedeath.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/EyeQueen/eyedeath.wav rename to src/main/resources/resources/sounds/mob/eyequeen/eyedeath.wav diff --git a/src/main/resources/resources/sounds/entities/Keeper/changephase.wav b/src/main/resources/resources/sounds/mob/keeper/changephase.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Keeper/changephase.wav rename to src/main/resources/resources/sounds/mob/keeper/changephase.wav diff --git a/src/main/resources/resources/sounds/entities/Keeper/keeperdeath.wav b/src/main/resources/resources/sounds/mob/keeper/keeperdeath.wav similarity index 100% rename from src/main/resources/resources/sounds/entities/Keeper/keeperdeath.wav rename to src/main/resources/resources/sounds/mob/keeper/keeperdeath.wav diff --git a/src/main/resources/resources/sounds/music/amulet/Amulet locked 2.wav b/src/main/resources/resources/sounds/music/amulet/Amulet locked 2.wav deleted file mode 100644 index 19330c80..00000000 Binary files a/src/main/resources/resources/sounds/music/amulet/Amulet locked 2.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/amulet/Amulet locked.wav b/src/main/resources/resources/sounds/music/amulet/Amulet locked.wav deleted file mode 100644 index 6b234737..00000000 Binary files a/src/main/resources/resources/sounds/music/amulet/Amulet locked.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/amulet/Amulet sucess.wav b/src/main/resources/resources/sounds/music/amulet/Amulet sucess.wav deleted file mode 100644 index 99f19081..00000000 Binary files a/src/main/resources/resources/sounds/music/amulet/Amulet sucess.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/deeper.wav b/src/main/resources/resources/sounds/music/deeper.wav new file mode 100644 index 00000000..728665fc Binary files /dev/null and b/src/main/resources/resources/sounds/music/deeper.wav differ diff --git a/src/main/resources/resources/sounds/music/cavern drip.wav b/src/main/resources/resources/sounds/music/dripping.wav similarity index 100% rename from src/main/resources/resources/sounds/music/cavern drip.wav rename to src/main/resources/resources/sounds/music/dripping.wav diff --git a/src/main/resources/resources/sounds/music/records/Record 12.wav b/src/main/resources/resources/sounds/music/records/Record 12.wav deleted file mode 100644 index 91cf52aa..00000000 Binary files a/src/main/resources/resources/sounds/music/records/Record 12.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/records/Record 14.wav b/src/main/resources/resources/sounds/music/records/Record 14.wav deleted file mode 100644 index 94272f78..00000000 Binary files a/src/main/resources/resources/sounds/music/records/Record 14.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/title/Intro 2.wav b/src/main/resources/resources/sounds/music/title/Intro 2.wav deleted file mode 100644 index 3287d023..00000000 Binary files a/src/main/resources/resources/sounds/music/title/Intro 2.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/title/Intro 3.wav b/src/main/resources/resources/sounds/music/title/Intro 3.wav deleted file mode 100644 index 9d116fb5..00000000 Binary files a/src/main/resources/resources/sounds/music/title/Intro 3.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/title/Intro 4.wav b/src/main/resources/resources/sounds/music/title/Intro 4.wav deleted file mode 100644 index 95e9a2f1..00000000 Binary files a/src/main/resources/resources/sounds/music/title/Intro 4.wav and /dev/null differ diff --git a/src/main/resources/resources/sounds/music/title/Intro.wav b/src/main/resources/resources/sounds/music/title/Intro.wav deleted file mode 100644 index 50934bba..00000000 Binary files a/src/main/resources/resources/sounds/music/title/Intro.wav and /dev/null differ diff --git a/src/main/resources/tinylog.properties b/src/main/resources/tinylog.properties index 4a94b3aa..81e4247d 100644 --- a/src/main/resources/tinylog.properties +++ b/src/main/resources/tinylog.properties @@ -4,7 +4,7 @@ writingthread = true writer1 = console writer1.level = debug writer1.charset = UTF-8 -writer1.format = {date:HH:mm:ss} | {level|size=6} -> {{class-name}|size=40} -> {message} +writer1.format = [{date:HH:mm:ss} | {level|size=6}]: {{class-name}|size=38} -> {message} writer1.tag = - writer1.locale = en_US