From a6679810c1fa217e9455db53da88860f6fe0cccf Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Tue, 11 Jul 2023 11:54:56 -0400 Subject: [PATCH] Removed broken sound code --- .../java/com/mojang/minecraft/Entity.java | 8 - .../java/com/mojang/minecraft/Minecraft.java | 38 +-- .../minecraft/OperatingSystemLookup.java | 37 --- .../minecraft/ResourceDownloadThread.java | 244 ------------------ .../mojang/minecraft/gamemode/GameMode.java | 5 - .../com/mojang/minecraft/level/Level.java | 33 --- .../com/mojang/minecraft/sound/Audio.java | 6 - .../com/mojang/minecraft/sound/AudioInfo.java | 11 - .../mojang/minecraft/sound/BaseSoundPos.java | 50 ---- .../minecraft/sound/EntitySoundPos.java | 27 -- .../mojang/minecraft/sound/LevelSoundPos.java | 31 --- .../com/mojang/minecraft/sound/Music.java | 80 ------ .../minecraft/sound/MusicPlayThread.java | 101 -------- .../com/mojang/minecraft/sound/Sound.java | 62 ----- .../com/mojang/minecraft/sound/SoundData.java | 13 - .../com/mojang/minecraft/sound/SoundInfo.java | 35 --- .../mojang/minecraft/sound/SoundManager.java | 96 ------- .../mojang/minecraft/sound/SoundPlayer.java | 107 -------- .../com/mojang/minecraft/sound/SoundPos.java | 8 - .../mojang/minecraft/sound/SoundReader.java | 89 ------- 20 files changed, 2 insertions(+), 1079 deletions(-) delete mode 100644 src/main/java/com/mojang/minecraft/OperatingSystemLookup.java delete mode 100644 src/main/java/com/mojang/minecraft/ResourceDownloadThread.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/Audio.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/AudioInfo.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/BaseSoundPos.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/EntitySoundPos.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/LevelSoundPos.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/Music.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/MusicPlayThread.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/Sound.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundData.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundInfo.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundManager.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundPlayer.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundPos.java delete mode 100644 src/main/java/com/mojang/minecraft/sound/SoundReader.java diff --git a/src/main/java/com/mojang/minecraft/Entity.java b/src/main/java/com/mojang/minecraft/Entity.java index ad033a8..3eef9da 100644 --- a/src/main/java/com/mojang/minecraft/Entity.java +++ b/src/main/java/com/mojang/minecraft/Entity.java @@ -306,10 +306,6 @@ public abstract class Entity implements Serializable { int var19 = this.level.getTile((int)this.x, (int)(this.y - 0.2F - this.heightOffset), (int)this.z); if(this.walkDist > (float)this.nextStep && var19 > 0) { ++this.nextStep; - Tile$SoundType var20; - if((var20 = Block.blocks[var19].stepsound) != Tile$SoundType.none) { - this.playSound("step." + var20.name, var20.getVolume() * 0.75F, var20.getPitch()); - } } } @@ -369,10 +365,6 @@ public abstract class Entity implements Serializable { this.level = var1; } - public void playSound(String var1, float var2, float var3) { - this.level.playSound(var1, this, var2, var3); - } - public void moveTo(float var1, float var2, float var3, float var4, float var5) { this.xo = this.x = var1; this.yo = this.y = var2; diff --git a/src/main/java/com/mojang/minecraft/Minecraft.java b/src/main/java/com/mojang/minecraft/Minecraft.java index bb99307..f163e97 100644 --- a/src/main/java/com/mojang/minecraft/Minecraft.java +++ b/src/main/java/com/mojang/minecraft/Minecraft.java @@ -29,8 +29,6 @@ import com.mojang.minecraft.render.*; import com.mojang.minecraft.render.texture.TextureFX; import com.mojang.minecraft.render.texture.TextureLavaFX; import com.mojang.minecraft.render.texture.TextureWaterFX; -import com.mojang.minecraft.sound.SoundManager; -import com.mojang.minecraft.sound.SoundPlayer; import com.mojang.net.NetworkHandler; import com.mojang.util.MathHelper; @@ -66,8 +64,6 @@ public final class Minecraft implements Runnable { public ProgressBarDisplay progressBar = new ProgressBarDisplay(this); public Renderer renderer = new Renderer(this); public LevelIO levelIo; - public SoundManager sound; - private ResourceDownloadThread resourceThread; private int ticks; private int blockHitTime; public String levelName; @@ -75,7 +71,6 @@ public final class Minecraft implements Runnable { public HUDScreen hud; public boolean online; public NetworkManager networkManager; - public SoundPlayer soundPlayer; public MovingObjectPosition selected; public static GameSettings settings; String server; @@ -89,7 +84,6 @@ public final class Minecraft implements Runnable { public Minecraft(int var3, int var4, boolean var5) { this.levelIo = new LevelIO(this.progressBar); - this.sound = new SoundManager(); this.ticks = 0; this.blockHitTime = 0; this.levelName = null; @@ -155,28 +149,8 @@ public final class Minecraft implements Runnable { } public final void shutdown() { - try { - if(this.soundPlayer != null) { - SoundPlayer var1 = this.soundPlayer; - this.soundPlayer.running = false; - } - - if(this.resourceThread != null) { - ResourceDownloadThread var4 = this.resourceThread; - this.resourceThread.running = true; - } - } catch (Exception var3) { - ; - } - -// Minecraft var5 = this; -// if(!this.levelLoaded) { -// try { -// LevelIO.save(var5.level, (OutputStream)(new FileOutputStream(new File("level.dat")))); -// } catch (Exception var2) { -// var2.printStackTrace(); -// } -// } + this.running = false; + MinecraftMain.canvas.delete(); } public final void run() { @@ -1114,14 +1088,6 @@ public final class Minecraft implements Runnable { } private void tick() { - if(this.soundPlayer != null) { - SoundPlayer var1 = this.soundPlayer; - SoundManager var2 = this.sound; - if(System.currentTimeMillis() > var2.lastMusic && var2.playMusic(var1, "calm")) { - var2.lastMusic = System.currentTimeMillis() + (long)var2.random.nextInt(900000) + 300000L; - } - } - this.gamemode.spawnMob(); HUDScreen var17 = this.hud; ++this.hud.ticks; diff --git a/src/main/java/com/mojang/minecraft/OperatingSystemLookup.java b/src/main/java/com/mojang/minecraft/OperatingSystemLookup.java deleted file mode 100644 index fb9071c..0000000 --- a/src/main/java/com/mojang/minecraft/OperatingSystemLookup.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mojang.minecraft; - -import com.mojang.minecraft.Minecraft$OS; - -// $FF: synthetic class -final class OperatingSystemLookup { - - // $FF: synthetic field - static final int[] lookup = new int[Minecraft$OS.values().length]; - - - static { - try { - lookup[Minecraft$OS.linux.ordinal()] = 1; - } catch (NoSuchFieldError var3) { - ; - } - - try { - lookup[Minecraft$OS.solaris.ordinal()] = 2; - } catch (NoSuchFieldError var2) { - ; - } - - try { - lookup[Minecraft$OS.windows.ordinal()] = 3; - } catch (NoSuchFieldError var1) { - ; - } - - try { - lookup[Minecraft$OS.macos.ordinal()] = 4; - } catch (NoSuchFieldError var0) { - ; - } - } -} diff --git a/src/main/java/com/mojang/minecraft/ResourceDownloadThread.java b/src/main/java/com/mojang/minecraft/ResourceDownloadThread.java deleted file mode 100644 index f9f18c2..0000000 --- a/src/main/java/com/mojang/minecraft/ResourceDownloadThread.java +++ /dev/null @@ -1,244 +0,0 @@ -package com.mojang.minecraft; - -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; - -public class ResourceDownloadThread extends Thread -{ - public ResourceDownloadThread(File minecraftFolder, Minecraft minecraft) - { - this.minecraft = minecraft; - - this.setName("Resource download thread"); - this.setDaemon(true); - - dir = new File(minecraftFolder, "resources/"); - - if(!dir.exists() && !dir.mkdirs()) - { - throw new RuntimeException("The working directory could not be created: " + dir); - } - } - - @Override - public void run() - { - BufferedReader reader = null; - - try { - ArrayList list = new ArrayList(); - - URL base = new URL("http://dl.dropbox.com/u/40737374/minecraft_resources/"); - URL url = new URL(base, "resources/"); - - URLConnection con = url.openConnection(); - - con.setConnectTimeout(20000); - - reader = new BufferedReader(new InputStreamReader(con.getInputStream())); - - String line = null; - - while((line = reader.readLine()) != null) - { - list.add(line); - } - - reader.close(); - - /*for(String s : list) - { - try { - String split[] = s.split(","); - int size = Integer.parseInt(split[1]); - File file = new File(dir, split[0]); - - if(!file.exists() || file.length() != size) - { - try { - file.getParentFile().mkdirs(); - } catch(SecurityException e) { - e.printStackTrace(); - } - - URL url1 = new URL(base, split[0].replaceAll(" ", "%20")); - - download(url1, file, size); - } else { - int index = split[0].indexOf("/"); - - if(split[0].substring(0, index).equalsIgnoreCase("sound")) - { - minecraft.sound.registerSound(file, split[0].substring(index + 1, split[0].length() - 4).replaceAll("[1-9]", "").replaceAll("/", ".")); - //this.mc.audio.registerSound(split[0].substring(index + 1, split[0].length() - 4).replaceAll("[1-9]", "").replaceAll("/", "."), file.toURI().toURL(), true); - } else if (split[0].substring(0, index).equalsIgnoreCase("music")) { - if(split[0].contains("sweden")) - { - //this.mc.audio.registerMusic("menu", file.toURI().toURL(), true); - } - - //this.mc.audio.registerMusic("bg", file.toURI().toURL(), true); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - if (!this.running) return; - }*/ - - for(String s : list) - { - String split[] = s.split(","); - int size = Integer.parseInt(split[1]); - File file = new File(dir, split[0]); - - File musicFolder = new File(dir, "music"); - - if(!file.exists() || file.length() != size) - { - try { - file.getParentFile().mkdirs(); - } catch(SecurityException e) { - e.printStackTrace(); - } - - URL url1 = new URL(base, split[0].replaceAll(" ", "%20")); - - if(file.getPath().contains("music")) - { - if(file.getName().equals("minecraft.ogg") && !new File(musicFolder, "calm1.ogg").exists()) - { - download(url1, file, size); - } else if(file.getName().equals("clark.ogg") && !new File(musicFolder, "calm2.ogg").exists()) { - download(url1, file, size); - } else if(file.getName().equals("sweden.ogg") && !new File(musicFolder, "calm3.ogg").exists()) { - download(url1, file, size); - } - } else { - download(url1, file, size); - } - } - - File minecraftOGG = new File(musicFolder, "minecraft.ogg"); - File clarkOGG = new File(musicFolder, "clark.ogg"); - File swedenOGG = new File(musicFolder, "sweden.ogg"); - - minecraftOGG.renameTo(new File(musicFolder, "calm1.ogg")); - clarkOGG.renameTo(new File(musicFolder, "calm2.ogg")); - swedenOGG.renameTo(new File(musicFolder, "calm3.ogg")); - } - - File soundsFolder = new File(dir, "sound"); - File stepsFolder = new File(soundsFolder, "step"); - - for(int i = 1; i <= 4; i++) - { - minecraft.sound.registerSound(new File(stepsFolder, "grass" + i + ".ogg"), "step/grass" + i + ".ogg"); - minecraft.sound.registerSound(new File(stepsFolder, "gravel" + i + ".ogg"), "step/gravel" + i + ".ogg"); - minecraft.sound.registerSound(new File(stepsFolder, "stone" + i + ".ogg"), "step/stone" + i + ".ogg"); - minecraft.sound.registerSound(new File(stepsFolder, "wood" + i + ".ogg"), "step/wood" + i + ".ogg"); - } - - File musicFolder = new File(dir, "music"); - - for(int i = 1; i <= 3; i++) - { - minecraft.sound.registerMusic("calm" + i + ".ogg", new File(musicFolder, "calm" + i + ".ogg")); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (reader != null) - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - this.finished = true; - } - - private File dir; - private Minecraft minecraft; - boolean running = false; - - private boolean finished = false; - private int progress = 0; - - private void download(URL url, File file, int size) - { - System.out.println("Downloading: " + file.getName() + "..."); - - //minecraft.progressBar.setText(file.getName()); - - DataInputStream in = null; - DataOutputStream out = null; - - try - { - byte[] data = new byte[4096]; - - in = new DataInputStream(url.openStream()); - FileOutputStream fos = new FileOutputStream(file); - out = new DataOutputStream(fos); - - int done = 0; - - do - { - int length = in.read(data); - - if(length < 0) - { - in.close(); - out.close(); - - return; - } - - out.write(data, 0, length); - - done += length; - progress = (int)(((double)done / (double)size) * 100); - } while(!running); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try - { - if(in != null) - { - in.close(); - } - - if(out != null) - { - out.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - //minecraft.progressBar.setText(""); - progress = 0; - - System.out.println("Downloaded: " + file.getName()); - } - - public boolean isFinished() - { - return finished; - } - - public int getProgress() - { - return progress; - } -} diff --git a/src/main/java/com/mojang/minecraft/gamemode/GameMode.java b/src/main/java/com/mojang/minecraft/gamemode/GameMode.java index c823ca4..9ac7fac 100644 --- a/src/main/java/com/mojang/minecraft/gamemode/GameMode.java +++ b/src/main/java/com/mojang/minecraft/gamemode/GameMode.java @@ -53,11 +53,6 @@ public class GameMode minecraft.networkManager.sendBlockChange(x, y, z, 0, minecraft.player.inventory.getSelected()); } - if(block.stepsound != Tile$SoundType.none) - { - level.playSound("step." + block.stepsound.name, (float)x, (float)y, (float)z, (block.stepsound.getVolume() + 1.0F) / 2.0F, block.stepsound.getPitch() * 0.8F); - } - block.spawnBreakParticles(level, x, y, z, minecraft.particleManager); } diff --git a/src/main/java/com/mojang/minecraft/level/Level.java b/src/main/java/com/mojang/minecraft/level/Level.java index 52e96cd..ab918a2 100644 --- a/src/main/java/com/mojang/minecraft/level/Level.java +++ b/src/main/java/com/mojang/minecraft/level/Level.java @@ -11,9 +11,6 @@ import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.particle.ParticleManager; import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.render.LevelRenderer; -import com.mojang.minecraft.sound.AudioInfo; -import com.mojang.minecraft.sound.EntitySoundPos; -import com.mojang.minecraft.sound.LevelSoundPos; import com.mojang.util.MathHelper; import java.io.Serializable; import java.util.ArrayList; @@ -852,36 +849,6 @@ public class Level implements Serializable { } } - public void playSound(String var1, Entity var2, float var3, float var4) { - if(this.rendererContext$5cd64a7f != null) { - Minecraft var5; - if((var5 = this.rendererContext$5cd64a7f).soundPlayer == null || !var5.settings.sound) { - return; - } - - AudioInfo var6; - if(var2.distanceToSqr(var5.player) < 1024.0F && (var6 = var5.sound.getAudioInfo(var1, var3, var4)) != null) { - var5.soundPlayer.play(var6, new EntitySoundPos(var2, var5.player)); - } - } - - } - - public void playSound(String var1, float var2, float var3, float var4, float var5, float var6) { - if(this.rendererContext$5cd64a7f != null) { - Minecraft var7; - if((var7 = this.rendererContext$5cd64a7f).soundPlayer == null || !var7.settings.sound) { - return; - } - - AudioInfo var8; - if((var8 = var7.sound.getAudioInfo(var1, var5, var6)) != null) { - var7.soundPlayer.play(var8, new LevelSoundPos(var2, var3, var4, var7.player)); - } - } - - } - public boolean maybeGrowTree(int var1, int var2, int var3) { int var4 = this.random.nextInt(3) + 4; boolean var5 = true; diff --git a/src/main/java/com/mojang/minecraft/sound/Audio.java b/src/main/java/com/mojang/minecraft/sound/Audio.java deleted file mode 100644 index dcd4e50..0000000 --- a/src/main/java/com/mojang/minecraft/sound/Audio.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mojang.minecraft.sound; - -public interface Audio -{ - boolean play(int[] var1, int[] var2, int var3); -} diff --git a/src/main/java/com/mojang/minecraft/sound/AudioInfo.java b/src/main/java/com/mojang/minecraft/sound/AudioInfo.java deleted file mode 100644 index a827f21..0000000 --- a/src/main/java/com/mojang/minecraft/sound/AudioInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mojang.minecraft.sound; - -public class AudioInfo -{ - public float volume = 1.0F; - - public int update(short[] var1, int var2) - { - return 0; - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/BaseSoundPos.java b/src/main/java/com/mojang/minecraft/sound/BaseSoundPos.java deleted file mode 100644 index eb16cd9..0000000 --- a/src/main/java/com/mojang/minecraft/sound/BaseSoundPos.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.mojang.minecraft.sound; - -import com.mojang.minecraft.Entity; -import com.mojang.util.MathHelper; - -public abstract class BaseSoundPos implements SoundPos -{ - public BaseSoundPos(Entity listener) - { - this.listener = listener; - } - - private Entity listener; - - public float getRotationDiff(float x, float y) - { - x -= listener.x; - y -= listener.z; - - float var3 = MathHelper.sqrt(x * x + y * y); - - x /= var3; - y /= var3; - - if((var3 /= 2.0F) > 1.0F) - { - var3 = 1.0F; - } - - float var4 = MathHelper.cos(-listener.yRot * 0.017453292F + 3.1415927F); - - return (MathHelper.sin(-listener.yRot * 0.017453292F + 3.1415927F) * y - var4 * x) * var3; - } - - public float getDistanceSq(float x, float y, float z) - { - x -= listener.x; - y -= listener.y; - float var4 = z - listener.z; - - var4 = MathHelper.sqrt(x * x + y * y + var4 * var4); - - if((var4 = 1.0F - var4 / 32.0F) < 0.0F) - { - var4 = 0.0F; - } - - return var4; - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/EntitySoundPos.java b/src/main/java/com/mojang/minecraft/sound/EntitySoundPos.java deleted file mode 100644 index 56a2767..0000000 --- a/src/main/java/com/mojang/minecraft/sound/EntitySoundPos.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mojang.minecraft.sound; - -import com.mojang.minecraft.Entity; - -public class EntitySoundPos extends BaseSoundPos -{ - public EntitySoundPos(Entity source, Entity listener) - { - super(listener); - - this.source = source; - } - - @Override - public float getRotationDiff() - { - return super.getRotationDiff(source.x, source.z); - } - - @Override - public float getDistanceSq() - { - return super.getDistanceSq(source.x, source.y, source.z); - } - - private Entity source; -} diff --git a/src/main/java/com/mojang/minecraft/sound/LevelSoundPos.java b/src/main/java/com/mojang/minecraft/sound/LevelSoundPos.java deleted file mode 100644 index 4afa5bc..0000000 --- a/src/main/java/com/mojang/minecraft/sound/LevelSoundPos.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mojang.minecraft.sound; - -import com.mojang.minecraft.Entity; - -public final class LevelSoundPos extends BaseSoundPos -{ - public LevelSoundPos(float x, float y, float z, Entity listener) - { - super(listener); - - this.x = x; - this.y = y; - this.z = z; - } - - @Override - public float getRotationDiff() - { - return super.getRotationDiff(x, z); - } - - @Override - public float getDistanceSq() - { - return super.getDistanceSq(x, y, z); - } - - private float x; - private float y; - private float z; -} diff --git a/src/main/java/com/mojang/minecraft/sound/Music.java b/src/main/java/com/mojang/minecraft/sound/Music.java deleted file mode 100644 index a6bb799..0000000 --- a/src/main/java/com/mojang/minecraft/sound/Music.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.mojang.minecraft.sound; - -import de.jarnbjo.ogg.LogicalOggStreamImpl; -import de.jarnbjo.ogg.OggFormatException; -import de.jarnbjo.ogg.OnDemandUrlStream; -import de.jarnbjo.vorbis.VorbisFormatException; -import de.jarnbjo.vorbis.VorbisStream; - -import java.io.IOException; -import java.net.URL; -import java.nio.ByteBuffer; - -// TODO. -public final class Music implements Audio { - - ByteBuffer playing = ByteBuffer.allocate(176400); - ByteBuffer current = ByteBuffer.allocate(176400); - private ByteBuffer processing = null; - ByteBuffer previous = null; - VorbisStream stream; - SoundPlayer player; - boolean finished = false; - boolean stopped = false; - - - public Music(SoundPlayer var1, URL var2) { - this.player = var1; - try - { - LogicalOggStreamImpl var3 = (LogicalOggStreamImpl)(new OnDemandUrlStream(var2)).getLogicalStreams().iterator().next(); - this.stream = new VorbisStream(var3); - } catch (VorbisFormatException e) { - e.printStackTrace(); - } catch (OggFormatException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - (new MusicPlayThread(this)).start(); - } - - public final boolean play(int[] var1, int[] var2, int var3) { - if(!this.player.settings.music) { - this.stopped = true; - return false; - } else { - var3 = var3; - int var4 = 0; - - while(var3 > 0 && (this.processing != null || this.previous != null)) { - if(this.processing == null && this.previous != null) { - this.processing = this.previous; - this.previous = null; - } - - if(this.processing != null && this.processing.remaining() > 0) { - int var5; - if((var5 = this.processing.remaining() / 4) > var3) { - var5 = var3; - } - - for(int var6 = 0; var6 < var5; ++var6) { - var1[var4 + var6] += this.processing.getShort(); - var2[var4 + var6] += this.processing.getShort(); - } - - var4 += var5; - var3 -= var5; - } - - if(this.current == null && this.processing != null && this.processing.remaining() == 0) { - this.current = this.processing; - this.processing = null; - } - } - - return this.processing != null || this.previous != null || !this.finished; - } - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/MusicPlayThread.java b/src/main/java/com/mojang/minecraft/sound/MusicPlayThread.java deleted file mode 100644 index e187931..0000000 --- a/src/main/java/com/mojang/minecraft/sound/MusicPlayThread.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.mojang.minecraft.sound; - -import de.jarnbjo.vorbis.VorbisStream; - -import java.nio.ByteBuffer; - -// TODO. -final class MusicPlayThread extends Thread { - - // $FF: synthetic field - private Music music; - - - public MusicPlayThread(Music var1) { - super(); - this.music = var1; - this.setPriority(10); - this.setDaemon(true); - } - - public final void run() { - try { - do { - if(this.music.stopped) { - return; - } - - Music var1 = this.music; - ByteBuffer var2; - Music var10001; - if(this.music.playing == null) { - var1 = this.music; - if(this.music.current != null) { - var1 = this.music; - var2 = this.music.current; - var10001 = this.music; - this.music.playing = var2; - var2 = null; - var1 = this.music; - this.music.current = null; - var1 = this.music; - this.music.playing.clear(); - } - } - - var1 = this.music; - if(this.music.playing != null) { - var1 = this.music; - if(this.music.playing.remaining() != 0) { - while(true) { - var1 = this.music; - if(this.music.playing.remaining() == 0) { - break; - } - - var1 = this.music; - var1 = this.music; - var2 = this.music.playing; - VorbisStream var9 = this.music.stream; - int var10 = this.music.stream.readPcm(var2.array(), var2.position(), var2.remaining()); - var2.position(var2.position() + var10); - boolean var11; - if(var11 = var10 <= 0) { - this.music.finished = true; - this.music.stopped = true; - break; - } - } - } - } - - var1 = this.music; - if(this.music.playing != null) { - var1 = this.music; - if(this.music.previous == null) { - var1 = this.music; - this.music.playing.flip(); - var1 = this.music; - var2 = this.music.playing; - var10001 = this.music; - this.music.previous = var2; - var2 = null; - var1 = this.music; - this.music.playing = var2; - } - } - - Thread.sleep(10L); - var1 = this.music; - } while(this.music.player.running); - - return; - } catch (Exception var7) { - var7.printStackTrace(); - return; - } finally { - this.music.finished = true; - } - - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/Sound.java b/src/main/java/com/mojang/minecraft/sound/Sound.java deleted file mode 100644 index 43a9433..0000000 --- a/src/main/java/com/mojang/minecraft/sound/Sound.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mojang.minecraft.sound; - -// TODO. -public final class Sound implements Audio { - - private AudioInfo info; - private SoundPos pos; - private float pitch = 0.0F; - private float volume = 1.0F; - private static short[] data = new short[1]; - - - public Sound(AudioInfo var1, SoundPos var2) { - this.info = var1; - this.pos = var2; - this.pitch = var2.getRotationDiff(); - this.volume = var2.getDistanceSq() * var1.volume; - } - - public final boolean play(int[] var1, int[] var2, int var3) { - if(data.length < var3) { - data = new short[var3]; - } - - int var4; - boolean var5 = (var4 = this.info.update(data, var3)) > 0; - float var6 = this.pos.getRotationDiff(); - float var7 = this.pos.getDistanceSq() * this.info.volume; - int var8 = (int)((this.pitch > 0.0F?1.0F - this.pitch:1.0F) * this.volume * 65536.0F); - int var9 = (int)((this.pitch < 0.0F?1.0F + this.pitch:1.0F) * this.volume * 65536.0F); - int var10 = (int)((var6 > 0.0F?1.0F - var6:1.0F) * var7 * 65536.0F); - int var11 = (int)((var6 < 0.0F?var6 + 1.0F:1.0F) * var7 * 65536.0F); - var10 -= var8; - var11 -= var9; - int var12; - int var13; - int var14; - if(var10 == 0 && var11 == 0) { - if(var8 >= 0 || var9 != 0) { - var12 = var8; - var13 = var9; - - for(var14 = 0; var14 < var4; ++var14) { - var1[var14] += data[var14] * var12 >> 16; - var2[var14] += data[var14] * var13 >> 16; - } - } - } else { - for(var12 = 0; var12 < var4; ++var12) { - var13 = var8 + var10 * var12 / var3; - var14 = var9 + var11 * var12 / var3; - var1[var12] += data[var12] * var13 >> 16; - var2[var12] += data[var12] * var14 >> 16; - } - } - - this.pitch = var6; - this.volume = var7; - return var5; - } - -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundData.java b/src/main/java/com/mojang/minecraft/sound/SoundData.java deleted file mode 100644 index 700b960..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundData.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mojang.minecraft.sound; - -public class SoundData -{ - public SoundData(short[] data, float length) - { - this.data = data; - this.length = length; - } - - public short[] data; - public float length; -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundInfo.java b/src/main/java/com/mojang/minecraft/sound/SoundInfo.java deleted file mode 100644 index e98720f..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.mojang.minecraft.sound; - -// TODO. -public final class SoundInfo extends AudioInfo { - - private SoundData data; - private float seek = 0.0F; - private float pitch; - - - public SoundInfo(SoundData var1, float var2, float var3) { - this.data = var1; - this.pitch = var2 * 44100.0F / var1.length; - this.volume = var3; - } - - public final int update(short[] var1, int var2) { - if(this.seek >= (float)this.data.data.length) { - return 0; - } else { - for(int var3 = 0; var3 < var2; ++var3) { - int var4 = (int)this.seek; - short var5 = this.data.data[var4]; - short var6 = var4 < this.data.data.length - 1?this.data.data[var4 + 1]:0; - var1[var3] = (short)((int)((float)var5 + (float)(var6 - var5) * (this.seek - (float)var4))); - this.seek += this.pitch; - if(this.seek >= (float)this.data.data.length) { - return var3; - } - } - - return var2; - } - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundManager.java b/src/main/java/com/mojang/minecraft/sound/SoundManager.java deleted file mode 100644 index f794e8f..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundManager.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.mojang.minecraft.sound; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.*; - -// TODO. -public final class SoundManager { - - private SoundReader reader = new SoundReader(); - public Map sounds = new HashMap(); - private Map music = new HashMap(); - public Random random = new Random(); - public long lastMusic = System.currentTimeMillis() + 60000L; - - - public final AudioInfo getAudioInfo(String var1, float var2, float var3) { - List var4 = null; - Map var5 = this.sounds; - synchronized(this.sounds) { - var4 = (List)this.sounds.get(var1); - } - - if(var4 == null) { - return null; - } else { - SoundData var7 = (SoundData)var4.get(this.random.nextInt(var4.size())); - return new SoundInfo(var7, var3, var2); - } - } - - public void registerSound(File var1, String var2) { - try { - for(var2 = var2.substring(0, var2.length() - 4).replaceAll("/", "."); Character.isDigit(var2.charAt(var2.length() - 1)); var2 = var2.substring(0, var2.length() - 1)) { - ; - } - - SoundData var7 = SoundReader.read(var1.toURI().toURL()); - Map var3 = this.sounds; - synchronized(this.sounds) { - Object var4; - if((var4 = (List)this.sounds.get(var2)) == null) { - var4 = new ArrayList(); - this.sounds.put(var2, var4); - } - - ((List)var4).add(var7); - } - } catch (Exception var6) { - var6.printStackTrace(); - } - - } - - public final void registerMusic(String var1, File var2) { - Map var3 = this.music; - synchronized(this.music) { - for(var1 = var1.substring(0, var1.length() - 4).replaceAll("/", "."); Character.isDigit(var1.charAt(var1.length() - 1)); var1 = var1.substring(0, var1.length() - 1)) { - ; - } - - Object var4; - if((var4 = (List)this.music.get(var1)) == null) { - var4 = new ArrayList(); - this.music.put(var1, var4); - } - - ((List)var4).add(var2); - } - } - - public boolean playMusic(SoundPlayer var1, String var2) { - List var3 = null; - Map var4 = this.music; - synchronized(this.music) { - var3 = (List)this.music.get(var2); - } - - if(var3 == null) { - return false; - } else { - File var8 = (File)var3.get(this.random.nextInt(var3.size())); - - try { - var1.play(new Music(var1, var8.toURI().toURL())); - } catch (MalformedURLException var5) { - var5.printStackTrace(); - } catch (IOException var6) { - var6.printStackTrace(); - } - - return true; - } - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundPlayer.java b/src/main/java/com/mojang/minecraft/sound/SoundPlayer.java deleted file mode 100644 index 7a73138..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundPlayer.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.mojang.minecraft.sound; - -import com.mojang.minecraft.GameSettings; - -import javax.sound.sampled.SourceDataLine; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -// TODO. -public final class SoundPlayer implements Runnable { - - public boolean running = false; - public SourceDataLine dataLine; - private List audioQueue = new ArrayList(); - public GameSettings settings; - - - public SoundPlayer(GameSettings var1) { - this.settings = var1; - } - - public final void play(Audio var1) { - if(this.running) { - List var2 = this.audioQueue; - synchronized(this.audioQueue) { - this.audioQueue.add(var1); - } - } - } - - public final void play(AudioInfo var1, SoundPos var2) { - this.play(new Sound(var1, var2)); - } - - public final void run() { - int[] var1 = new int[4410]; - int[] var2 = new int[4410]; - - for(byte[] var3 = new byte[17640]; this.running; this.dataLine.write(var3, 0, 17640)) { - try { - Thread.sleep(1L); - } catch (InterruptedException var10) { - var10.printStackTrace(); - } - - Arrays.fill(var1, 0, 4410, 0); - Arrays.fill(var2, 0, 4410, 0); - boolean var4 = true; - int[] var5 = var2; - int[] var6 = var1; - List var12 = this.audioQueue; - List var7 = this.audioQueue; - synchronized(this.audioQueue) { - int var8 = 0; - - while(true) { - if(var8 >= var12.size()) { - break; - } - - if(!((Audio)var12.get(var8)).play(var6, var5, 4410)) { - var12.remove(var8--); - } - - ++var8; - } - } - - int var13; - if(!this.settings.music && !this.settings.sound) { - for(var13 = 0; var13 < 4410; ++var13) { - var3[var13 << 2] = 0; - var3[(var13 << 2) + 1] = 0; - var3[(var13 << 2) + 2] = 0; - var3[(var13 << 2) + 3] = 0; - } - } else { - for(var13 = 0; var13 < 4410; ++var13) { - int var15 = var1[var13]; - int var14 = var2[var13]; - if(var15 < -32000) { - var15 = -32000; - } - - if(var14 < -32000) { - var14 = -32000; - } - - if(var15 >= 32000) { - var15 = 32000; - } - - if(var14 >= 32000) { - var14 = 32000; - } - - var3[var13 << 2] = (byte)(var15 >> 8); - var3[(var13 << 2) + 1] = (byte)var15; - var3[(var13 << 2) + 2] = (byte)(var14 >> 8); - var3[(var13 << 2) + 3] = (byte)var14; - } - } - } - - } -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundPos.java b/src/main/java/com/mojang/minecraft/sound/SoundPos.java deleted file mode 100644 index f425b88..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundPos.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mojang.minecraft.sound; - -public interface SoundPos -{ - float getRotationDiff(); - - float getDistanceSq(); -} diff --git a/src/main/java/com/mojang/minecraft/sound/SoundReader.java b/src/main/java/com/mojang/minecraft/sound/SoundReader.java deleted file mode 100644 index ec57429..0000000 --- a/src/main/java/com/mojang/minecraft/sound/SoundReader.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.mojang.minecraft.sound; - -import de.jarnbjo.ogg.LogicalOggStreamImpl; -import de.jarnbjo.ogg.OggFormatException; -import de.jarnbjo.ogg.OnDemandUrlStream; -import de.jarnbjo.vorbis.IdentificationHeader; -import de.jarnbjo.vorbis.VorbisFormatException; -import de.jarnbjo.vorbis.VorbisStream; - -import java.io.IOException; -import java.net.URL; - -// TODO. -public final class SoundReader { - - public static SoundData read(URL var0) { - VorbisStream var12 = null; - try - { - LogicalOggStreamImpl var11 = (LogicalOggStreamImpl)(new OnDemandUrlStream(var0)).getLogicalStreams().iterator().next(); - var12 = new VorbisStream(var11); - } catch (VorbisFormatException e) { - e.printStackTrace(); - } catch (OggFormatException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - byte[] var2 = new byte[4096]; - int var3 = 0; - boolean var1 = false; - IdentificationHeader var14 = var12.getIdentificationHeader(); - int var4 = var12.getIdentificationHeader().getChannels(); - short[] var5 = new short[4096]; - int var6 = 0; - - label51: - while(var3 >= 0) { - int var15 = 0; - - while(true) { - try { - if(var15 < var2.length && (var3 = var12.readPcm(var2, var15, var2.length - var15)) > 0) { - var15 += var3; - continue; - } - } catch (Exception var10) { - var3 = -1; - } - - if(var15 <= 0) { - break; - } - - boolean var7 = false; - int var16 = 0; - - while(true) { - if(var16 >= var15) { - continue label51; - } - - int var8 = 0; - - for(int var9 = 0; var9 < var4; ++var9) { - var8 += var2[var16++] << 8 | var2[var16++] & 255; - } - - if(var6 == var5.length) { - short[] var18 = var5; - var5 = new short[var5.length << 1]; - System.arraycopy(var18, 0, var5, 0, var6); - } - - var5[var6++] = (short)(var8 / var4); - } - } - } - - if(var6 != var5.length) { - short[] var17 = var5; - var5 = new short[var6]; - System.arraycopy(var17, 0, var5, 0, var6); - } - - IdentificationHeader var13; - return new SoundData(var5, (float)(var13 = var12.getIdentificationHeader()).getSampleRate()); - } -}