Fix sound manager

This commit is contained in:
PeytonPlayz595 2024-10-16 13:48:37 -04:00
parent d3142f1adf
commit 37b2baafb1
18 changed files with 571 additions and 311 deletions

View File

@ -90,14 +90,6 @@ public class GameSettings {
Minecraft.getMinecraft().gameSettings.skin = var3[1]; Minecraft.getMinecraft().gameSettings.skin = var3[1];
} }
if(var3[0].equals("lastServer")) {
Minecraft.getMinecraft().gameSettings.field_12259_z = var3[1];
}
if(var3[0].equals("username")) {
Minecraft.getMinecraft().gameSettings.username = var3[1];
}
for(int var4 = 0; var4 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var4) { for(int var4 = 0; var4 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var4) {
if(var3[0].equals("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var4].keyDescription)) { if(var3[0].equals("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var4].keyDescription)) {
Minecraft.getMinecraft().gameSettings.keyBindings[var4].keyCode = Integer.parseInt(var3[1]); Minecraft.getMinecraft().gameSettings.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
@ -129,12 +121,6 @@ public class GameSettings {
var1.println("difficulty:" + Minecraft.getMinecraft().gameSettings.difficulty); var1.println("difficulty:" + Minecraft.getMinecraft().gameSettings.difficulty);
var1.println("fancyGraphics:" + Minecraft.getMinecraft().gameSettings.fancyGraphics); var1.println("fancyGraphics:" + Minecraft.getMinecraft().gameSettings.fancyGraphics);
var1.println("skin:" + Minecraft.getMinecraft().gameSettings.skin); var1.println("skin:" + Minecraft.getMinecraft().gameSettings.skin);
if(Minecraft.getMinecraft().gameSettings.field_12259_z.length() != 0) {
var1.println("lastServer:" + Minecraft.getMinecraft().gameSettings.field_12259_z);
}
if(Minecraft.getMinecraft().gameSettings.username.length() != 0) {
var1.println("username:" + Minecraft.getMinecraft().gameSettings.username);
}
for(int var2 = 0; var2 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var2) { for(int var2 = 0; var2 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var2) {
var1.println("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyDescription + ":" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyCode); var1.println("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyDescription + ":" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyCode);

View File

@ -5505,8 +5505,8 @@ public class GL11_1 {
ss.setPitch(name, pitch); ss.setPitch(name, pitch);
ss.setVolume(name, volume); ss.setVolume(name, volume);
ss.play(name); ss.play(name);
}else { } else {
System.err.println("unknown sound event "+fileName); return -1;
} }
return id; return id;
} }
@ -5523,8 +5523,8 @@ public class GL11_1 {
ss.setPitch(name, pitch); ss.setPitch(name, pitch);
ss.setVolume(name, volume); ss.setVolume(name, volume);
ss.play(name); ss.play(name);
}else { } else {
System.err.println("unknown sound event "+fileName); return -1;
} }
return id; return id;
} }

View File

@ -1,219 +1,219 @@
package net.PeytonPlayz585.sound; //package net.PeytonPlayz585.sound;
//
import java.io.FileNotFoundException; //import java.io.FileNotFoundException;
import java.util.Map; //import java.util.Map;
import net.PeytonPlayz585.EaglercraftRandom; //import net.PeytonPlayz585.EaglercraftRandom;
//
import net.PeytonPlayz585.opengl.GL11; //import net.PeytonPlayz585.opengl.GL11;
import net.minecraft.client.Minecraft; //import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityPlayer; //import net.minecraft.src.EntityPlayer;
//
public class SoundManager { //public class SoundManager {
//
static String[] music = new String[] {"calm1", "calm2", "calm3"}; // static String[] music = new String[] {"calm1", "calm2", "calm3"};
static String[] newMusic = new String[] {"hal1", "hal2", "hal3", "hal4", "nuance1", "nuance2", "piano1", "piano2", "piano3"}; // static String[] newMusic = new String[] {"hal1", "hal2", "hal3", "hal4", "nuance1", "nuance2", "piano1", "piano2", "piano3"};
//
private static int song = 0; // private static int song = 0;
private static String prevSong = ""; // private static String prevSong = "";
//
/* // /*
* Will be set to true when a song begins playback // * Will be set to true when a song begins playback
* This will initiate the timer for the next song // * This will initiate the timer for the next song
*/ // */
private boolean musicFlag = false; // private boolean musicFlag = false;
private boolean musicTimerSet = false; // private boolean musicTimerSet = false;
private int musicTimer = 0; // private int musicTimer = 0;
//
public void func_336_b(String s, float f, float g, float h, float i, float j) { // public void func_336_b(String s, float f, float g, float h, float i, float j) {
String file = s.replace(".", "/"); // String file = s.replace(".", "/");
String[] integers = new String[] {"1", "2", "3", "4"}; // String[] integers = new String[] {"1", "2", "3", "4"};
boolean flag = false; // boolean flag = false;
int k = 0; // int k = 0;
//
for(String s1 : integers) { // for(String s1 : integers) {
if(file.endsWith(s1)) { // if(file.endsWith(s1)) {
k = Integer.parseInt(s1); // k = Integer.parseInt(s1);
flag = true; // flag = true;
} // }
} // }
//
if(i > 1.0F) { // if(i > 1.0F) {
i = 1.0F; // i = 1.0F;
} // }
//
file = "sounds/" + file; // file = "sounds/" + file;
if(flag) { // if(flag) {
int i1 = GL11.EaglerAdapterImpl2.beginPlayback(file + k + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // int i1 = GL11.EaglerAdapterImpl2.beginPlayback(file + k + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i1 == -1) { // if(i1 == -1) {
try { // try {
throw new FileNotFoundException("Audio file " + file + " not found!"); // throw new FileNotFoundException("Audio file " + file + " not found!");
} catch(Exception e) { // } catch(Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
} else { // } else {
EaglercraftRandom rand = new EaglercraftRandom(); // EaglercraftRandom rand = new EaglercraftRandom();
int i1 = rand.nextInt(4 - 1 + 1) + 1; // int i1 = rand.nextInt(4 - 1 + 1) + 1;
int i2 = GL11.EaglerAdapterImpl2.beginPlayback(file + i1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // int i2 = GL11.EaglerAdapterImpl2.beginPlayback(file + i1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i2 == -1) { // if(i2 == -1) {
int i3 = 0; // int i3 = 0;
if(i1 == 4) { // if(i1 == 4) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 3 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 3 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i3 == -1) { // if(i3 == -1) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 2 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 2 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i3 == -1) { // if(i3 == -1) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
} // }
} // }
} // }
//
if(i1 == 3) { // if(i1 == 3) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 2 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 2 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i3 == -1) { // if(i3 == -1) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
} // }
} // }
//
if(i1 == 2) { // if(i1 == 2) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + 1 + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
} // }
//
if(i1 == 1) { // if(i1 == 1) {
i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i3 = GL11.EaglerAdapterImpl2.beginPlayback(file + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
} // }
//
if(i3 == -1) { // if(i3 == -1) {
int i4 = 0; // int i4 = 0;
i4 = GL11.EaglerAdapterImpl2.beginPlayback(file + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j); // i4 = GL11.EaglerAdapterImpl2.beginPlayback(file + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
if(i4 == -1) { // if(i4 == -1) {
try { // try {
throw new FileNotFoundException("Audio file " + file + " not found!"); // throw new FileNotFoundException("Audio file " + file + " not found!");
} catch(Exception e) { // } catch(Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
}
}
}
}
public void func_338_a(EntityPlayer player, float f) {
if(player == null) {
GL11.EaglerAdapterImpl2.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
} else {
double x = player.prevPosX + (player.posX - player.prevPosX) * f;
double y = player.prevPosY + (player.posY - player.prevPosY) * f;
double z = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
double pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
try {
GL11.EaglerAdapterImpl2.setListenerPos((float)x, (float)y, (float)z, (float)player.motionX, (float)player.motionY, (float)player.motionZ, (float)pitch, (float)yaw);
} catch(Exception e) {
}
}
}
public void func_337_a(String file, float volume, float pitch) {
file = file.replace(".", "/");
String sound = "sounds/" + file;
if(!sound.endsWith(".mp3")) {
sound = sound + ".mp3";
}
if(volume > 1.0F) {
volume = 1.0F;
}
volume *= 0.25F;
int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
if(i == - 1) {
try {
throw new FileNotFoundException("Audio file " + file + " not found!");
} catch(Exception e) {
e.printStackTrace();
}
}
}
public void onSoundOptionsChanged() {
// for (Map.Entry<Integer, GL11.AudioBufferSourceNodeX> entry : GL11.activeSoundEffects.entrySet()) {
// int i = entry.getKey();
//
// if(GL11.isPlaying(i)) {
// if(i != song) {
// GL11.setVolume(i, GL11.getVolume(i) * Minecraft.getMinecraft().gameSettings.soundVolume);
// } else {
// GL11.setVolume(i, 1.0F * Minecraft.getMinecraft().gameSettings.musicVolume);
// } // }
// } // }
// } // }
} // }
//
int ticks = 0; // public void func_338_a(EntityPlayer player, float f) {
// if(player == null) {
public void musicTick() throws FileNotFoundException { // GL11.EaglerAdapterImpl2.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) { // } else {
if(GL11.EaglerAdapterImpl2.isPlaying(song)) { // double x = player.prevPosX + (player.posX - player.prevPosX) * f;
GL11.EaglerAdapterImpl2.endSound(song); // double y = player.prevPosY + (player.posY - player.prevPosY) * f;
} // double z = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
musicFlag = true; // double pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
musicTimer = 0; // double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
musicTimerSet = false; //
song = 0; // try {
return; // GL11.EaglerAdapterImpl2.setListenerPos((float)x, (float)y, (float)z, (float)player.motionX, (float)player.motionY, (float)player.motionZ, (float)pitch, (float)yaw);
} // } catch(Exception e) {
//
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && !musicTimerSet) { // }
EaglercraftRandom rand = new EaglercraftRandom(); // }
musicTimer = rand.nextInt(6 - 3 + 1) + 3; // }
musicTimer = musicTimer * 60; //
musicTimer = musicTimer * 20; // public void func_337_a(String file, float volume, float pitch) {
musicTimerSet = true; // file = file.replace(".", "/");
song = 0; // String sound = "sounds/" + file;
ticks = Minecraft.getMinecraft().ticksRan + musicTimer; // if(!sound.endsWith(".mp3")) {
return; // sound = sound + ".mp3";
} // }
//
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && musicTimerSet) { // if(volume > 1.0F) {
if(Minecraft.getMinecraft().ticksRan >= ticks) { // volume = 1.0F;
musicFlag = false; // }
musicTimer = 0; //
musicTimerSet = false; // volume *= 0.25F;
song = 0; // int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
return; // if(i == - 1) {
} // try {
} // throw new FileNotFoundException("Audio file " + file + " not found!");
// } catch(Exception e) {
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && !musicFlag) { // e.printStackTrace();
EaglercraftRandom rand = new EaglercraftRandom(); // }
int i = rand.nextInt(2); // }
// }
if(i == 0) { //
int i1 = rand.nextInt((music.length - 1) + 1) + 1; // public void onSoundOptionsChanged() {
String songToPlay = music[i1 - 1]; //// for (Map.Entry<Integer, GL11.AudioBufferSourceNodeX> entry : GL11.activeSoundEffects.entrySet()) {
if(songToPlay.equals(prevSong)) { //// int i = entry.getKey();
return; ////
} //// if(GL11.isPlaying(i)) {
prevSong = songToPlay; //// if(i != song) {
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F); //// GL11.setVolume(i, GL11.getVolume(i) * Minecraft.getMinecraft().gameSettings.soundVolume);
if(song == -1) { //// } else {
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!"); //// GL11.setVolume(i, 1.0F * Minecraft.getMinecraft().gameSettings.musicVolume);
} //// }
} else { //// }
int i1 = rand.nextInt((newMusic.length - 1) + 1) + 1; //// }
String songToPlay = newMusic[i1 - 1]; // }
if(songToPlay.equals(prevSong)) { //
return; // int ticks = 0;
} //
prevSong = songToPlay; // public void musicTick() throws FileNotFoundException {
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F); // if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) {
if(song == -1) { // if(GL11.EaglerAdapterImpl2.isPlaying(song)) {
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!"); // GL11.EaglerAdapterImpl2.endSound(song);
} // }
} // musicFlag = true;
musicFlag = true; // musicTimer = 0;
} // musicTimerSet = false;
} // song = 0;
} // return;
// }
//
// if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && !musicTimerSet) {
// EaglercraftRandom rand = new EaglercraftRandom();
// musicTimer = rand.nextInt(6 - 3 + 1) + 3;
// musicTimer = musicTimer * 60;
// musicTimer = musicTimer * 20;
// musicTimerSet = true;
// song = 0;
// ticks = Minecraft.getMinecraft().ticksRan + musicTimer;
// return;
// }
//
// if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && musicTimerSet) {
// if(Minecraft.getMinecraft().ticksRan >= ticks) {
// musicFlag = false;
// musicTimer = 0;
// musicTimerSet = false;
// song = 0;
// return;
// }
// }
//
// if(!GL11.EaglerAdapterImpl2.isPlaying(song) && !musicFlag) {
// EaglercraftRandom rand = new EaglercraftRandom();
// int i = rand.nextInt(2);
//
// if(i == 0) {
// int i1 = rand.nextInt((music.length - 1) + 1) + 1;
// String songToPlay = music[i1 - 1];
// if(songToPlay.equals(prevSong)) {
// return;
// }
// prevSong = songToPlay;
// song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
// if(song == -1) {
// throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
// }
// } else {
// int i1 = rand.nextInt((newMusic.length - 1) + 1) + 1;
// String songToPlay = newMusic[i1 - 1];
// if(songToPlay.equals(prevSong)) {
// return;
// }
// prevSong = songToPlay;
// song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
// if(song == -1) {
// throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
// }
// }
// musicFlag = true;
// }
// }
//}

View File

@ -15,7 +15,7 @@ public class Client {
GL11.EaglerAdapterImpl2.initializeContext(); GL11.EaglerAdapterImpl2.initializeContext();
Minecraft mc = new Minecraft(); Minecraft mc = new Minecraft();
mc.field_6320_i = new Session("Player"); mc.session = new Session("Player");
mc.run(); mc.run();
} }

View File

@ -0,0 +1,93 @@
package net.PeytonPlayz585.profile;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.PeytonPlayz585.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.NBTTagCompound;
public class Profile {
private static String username = "";
private static String server = "";
public static String getName() {
return username;
}
public static String getServer() {
return server.replaceAll("_", ":");
}
public static void setName(String str) {
username = str;
Minecraft mc = Minecraft.getMinecraft();
if(mc != null) {
mc.session.username = str;
}
}
public static void setServer(String str) {
server = str.replaceAll(":", "_");
}
public static void read() {
read(GL11.EaglerAdapterImpl2.loadLocalStorage("P"));
}
public static void read(byte[] profileStorage) {
if (profileStorage == null) {
return;
}
NBTTagCompound profile;
try {
profile = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(profileStorage));
}catch(IOException ex) {
return;
}
if (profile == null || profile.hasNoTags()) {
return;
}
String loadUsername = profile.getString("username").trim();
if(!loadUsername.isEmpty()) {
username = loadUsername.replaceAll("[^A-Za-z0-9]", "_");
}
String loadServer = profile.getString("server").trim();
if(!loadServer.isEmpty()) {
server = loadServer;
}
}
private static byte[] write() {
NBTTagCompound profile = new NBTTagCompound();
profile.setString("username", username);
profile.setString("server", server);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
CompressedStreamTools.writeGzippedCompoundToOutputStream(profile, baos);
} catch (IOException e) {
return null;
}
return baos.toByteArray();
}
public static void save() {
byte[] b = write();
if(b != null) {
GL11.EaglerAdapterImpl2.saveLocalStorage("P", b);
}
}
static {
read();
}
}

View File

@ -4,7 +4,6 @@ import net.PeytonPlayz585.input.Keyboard;
import net.PeytonPlayz585.input.Mouse; import net.PeytonPlayz585.input.Mouse;
import net.PeytonPlayz585.opengl.Display; import net.PeytonPlayz585.opengl.Display;
import net.PeytonPlayz585.opengl.GL11; import net.PeytonPlayz585.opengl.GL11;
import net.PeytonPlayz585.sound.SoundManager;
import net.PeytonPlayz585.util.glu.GLU; import net.PeytonPlayz585.util.glu.GLU;
import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block; import net.minecraft.src.Block;
@ -42,6 +41,7 @@ import net.minecraft.src.RenderGlobal;
import net.minecraft.src.RenderManager; import net.minecraft.src.RenderManager;
import net.minecraft.src.ScaledResolution; import net.minecraft.src.ScaledResolution;
import net.minecraft.src.Session; import net.minecraft.src.Session;
import net.minecraft.src.SoundManager;
import net.minecraft.src.Teleporter; import net.minecraft.src.Teleporter;
import net.minecraft.src.Tessellator; import net.minecraft.src.Tessellator;
import net.minecraft.src.TextureCompassFX; import net.minecraft.src.TextureCompassFX;
@ -73,7 +73,7 @@ public class Minecraft implements Runnable {
public RenderGlobal field_6323_f; public RenderGlobal field_6323_f;
public EntityPlayerSP thePlayer; public EntityPlayerSP thePlayer;
public EffectRenderer field_6321_h; public EffectRenderer field_6321_h;
public Session field_6320_i = null; public Session session = null;
public String field_6319_j; public String field_6319_j;
public boolean field_6317_l = true; public boolean field_6317_l = true;
public volatile boolean field_6316_m = false; public volatile boolean field_6316_m = false;
@ -123,6 +123,7 @@ public class Minecraft implements Runnable {
RenderManager.instance.field_4236_f = new ItemRenderer(this); RenderManager.instance.field_4236_f = new ItemRenderer(this);
this.gameSettings = new GameSettings(this); this.gameSettings = new GameSettings(this);
this.sndManager.func_340_a(gameSettings);
this.texturePackList = new TexturePackList(this); this.texturePackList = new TexturePackList(this);
this.renderEngine = new RenderEngine(texturePackList, this.gameSettings); this.renderEngine = new RenderEngine(texturePackList, this.gameSettings);
this.fontRenderer = new FontRenderer(this.gameSettings, "/font/default.png", this.renderEngine); this.fontRenderer = new FontRenderer(this.gameSettings, "/font/default.png", this.renderEngine);
@ -597,11 +598,7 @@ public class Minecraft implements Runnable {
this.thePlayer.func_6420_o(); this.thePlayer.func_6420_o();
} }
try { this.sndManager.func_4033_c();
this.sndManager.musicTick();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if(!this.field_6316_m && this.theWorld != null) { if(!this.field_6316_m && this.theWorld != null) {
this.field_6327_b.func_6474_c(); this.field_6327_b.func_6474_c();

View File

@ -14,12 +14,12 @@ public class EntityPlayerSP extends EntityPlayer {
super(var2); super(var2);
this.mc = var1; this.mc = var1;
this.dimension = var4; this.dimension = var4;
if(var3 != null && var3.inventory != null && var3.inventory.length() > 0) { if(var3 != null && var3.username != null && var3.username.length() > 0) {
this.skinUrl = "http://www.minecraft.net/skin/" + var3.inventory + ".png"; this.skinUrl = "http://www.minecraft.net/skin/" + var3.username + ".png";
System.out.println("Loading texture " + this.skinUrl); System.out.println("Loading texture " + this.skinUrl);
} }
this.field_771_i = var3.inventory; this.field_771_i = var3.username;
} }
public void func_418_b_() { public void func_418_b_() {

View File

@ -42,8 +42,6 @@ public class GameSettings {
public int numberOfOptions = 10; public int numberOfOptions = 10;
public int difficulty = 2; public int difficulty = 2;
public boolean thirdPersonView = false; public boolean thirdPersonView = false;
public String field_12259_z = "";
public String username = "";
public boolean ofZoom = false; public boolean ofZoom = false;
public GameSettings(Minecraft var1) { public GameSettings(Minecraft var1) {
@ -126,8 +124,6 @@ public class GameSettings {
return var1 == 0 ? "Music: " + (this.musicVolume > 0.0F ? (int)(this.musicVolume * 100.0F) + "%" : "OFF") : (var1 == 1 ? "Sound: " + (this.soundVolume > 0.0F ? (int)(this.soundVolume * 100.0F) + "%" : "OFF") : (var1 == 2 ? "Invert mouse: " + (this.invertMouse ? "ON" : "OFF") : (var1 == 3 ? (this.mouseSensitivity == 0.0F ? "Sensitivity: *yawn*" : (this.mouseSensitivity == 1.0F ? "Sensitivity: HYPERSPEED!!!" : "Sensitivity: " + (int)(this.mouseSensitivity * 200.0F) + "%")) : (var1 == 4 ? "Render distance: " + RENDER_DISTANCES[this.renderDistance] : (var1 == 5 ? "View bobbing: " + (this.viewBobbing ? "ON" : "OFF") : (var1 == 6 ? "3d anaglyph: " + (this.anaglyph ? "ON" : "OFF") : (var1 == 7 ? "Show FPS: " + (this.showFPS ? "ON" : "OFF") : (var1 == 8 ? "Difficulty: " + DIFFICULTY_LEVELS[this.difficulty] : (var1 == 9 ? "Graphics: " + (this.fancyGraphics ? "FANCY" : "FAST") : ""))))))))); return var1 == 0 ? "Music: " + (this.musicVolume > 0.0F ? (int)(this.musicVolume * 100.0F) + "%" : "OFF") : (var1 == 1 ? "Sound: " + (this.soundVolume > 0.0F ? (int)(this.soundVolume * 100.0F) + "%" : "OFF") : (var1 == 2 ? "Invert mouse: " + (this.invertMouse ? "ON" : "OFF") : (var1 == 3 ? (this.mouseSensitivity == 0.0F ? "Sensitivity: *yawn*" : (this.mouseSensitivity == 1.0F ? "Sensitivity: HYPERSPEED!!!" : "Sensitivity: " + (int)(this.mouseSensitivity * 200.0F) + "%")) : (var1 == 4 ? "Render distance: " + RENDER_DISTANCES[this.renderDistance] : (var1 == 5 ? "View bobbing: " + (this.viewBobbing ? "ON" : "OFF") : (var1 == 6 ? "3d anaglyph: " + (this.anaglyph ? "ON" : "OFF") : (var1 == 7 ? "Show FPS: " + (this.showFPS ? "ON" : "OFF") : (var1 == 8 ? "Difficulty: " + DIFFICULTY_LEVELS[this.difficulty] : (var1 == 9 ? "Graphics: " + (this.fancyGraphics ? "FANCY" : "FAST") : "")))))))));
} }
private boolean loadOptionsFuckedUp = false;
public void loadOptions() { public void loadOptions() {
if(!GL11.isWebGL) { if(!GL11.isWebGL) {
net.PeytonPlayz585.minecraft.GameSettings.loadOptions(); net.PeytonPlayz585.minecraft.GameSettings.loadOptions();
@ -197,40 +193,15 @@ public class GameSettings {
this.skin = var3[1]; this.skin = var3[1];
} }
if(!loadOptionsFuckedUp) {
if(var3[0].equals("username")) {
this.username = var3[1];
}
if(var3[0].equals("lastServer")) {
this.field_12259_z = var3[1];
}
} else {
this.username = "";
this.field_12259_z = "";
}
for(int var4 = 0; var4 < this.keyBindings.length; ++var4) { for(int var4 = 0; var4 < this.keyBindings.length; ++var4) {
if(var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) { if(var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) {
this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]); this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
} }
} }
if(loadOptionsFuckedUp) {
this.saveOptions();
}
} }
} catch (Exception var5) { } catch (Exception var5) {
//What the fuck -_- System.out.println("Failed to load options");
if(!loadOptionsFuckedUp) { var5.printStackTrace();
loadOptionsFuckedUp = true;
this.loadOptions();
return;
} else {
//womp womp
System.out.println("Failed to load options");
var5.printStackTrace();
}
} }
} }
@ -258,13 +229,6 @@ public class GameSettings {
var1.println("difficulty:" + this.difficulty); var1.println("difficulty:" + this.difficulty);
var1.println("fancyGraphics:" + this.fancyGraphics); var1.println("fancyGraphics:" + this.fancyGraphics);
var1.println("skin:" + this.skin); var1.println("skin:" + this.skin);
if(!this.field_12259_z.isEmpty() && !this.field_12259_z.isBlank()) {
var1.println("lastServer:" + this.field_12259_z);
}
if(!this.username.isEmpty() && !this.username.isBlank()) {
var1.println("username:" + this.username);
}
for(int var2 = 0; var2 < this.keyBindings.length; ++var2) { for(int var2 = 0; var2 < this.keyBindings.length; ++var2) {
var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode); var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);

View File

@ -7,7 +7,7 @@ public class GuiGameOver extends GuiScreen {
this.controlList.clear(); this.controlList.clear();
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, "Respawn")); this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, "Respawn"));
this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96, "Title menu")); this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96, "Title menu"));
if(this.mc.field_6320_i == null) { if(this.mc.session == null) {
((GuiButton)this.controlList.get(1)).enabled = false; ((GuiButton)this.controlList.get(1)).enabled = false;
} }

View File

@ -75,7 +75,7 @@ public class GuiMainMenu extends GuiScreen {
this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, "Multiplayer")); this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, "Multiplayer"));
this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 96, "Mods and Texture Packs")); this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 96, "Mods and Texture Packs"));
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Options...")); this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Options..."));
if(this.mc.field_6320_i == null) { if(this.mc.session == null) {
((GuiButton)this.controlList.get(1)).enabled = false; ((GuiButton)this.controlList.get(1)).enabled = false;
} }
} }
@ -90,15 +90,7 @@ public class GuiMainMenu extends GuiScreen {
} }
if(var1.id == 2) { if(var1.id == 2) {
try { this.mc.displayGuiScreen(new GuiMultiplayer(this));
this.mc.displayGuiScreen(new GuiMultiplayer(this));
} catch(Exception e) {
//Shit
this.mc.gameSettings.field_12259_z = "";
this.mc.gameSettings.username = "";
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiMultiplayer(this));
}
} }
if(var1.id == 3) { if(var1.id == 3) {

View File

@ -1,7 +1,7 @@
package net.minecraft.src; package net.minecraft.src;
import net.PeytonPlayz585.input.Keyboard; import net.PeytonPlayz585.input.Keyboard;
import net.minecraft.client.Minecraft; import net.PeytonPlayz585.profile.Profile;
public class GuiMultiplayer extends GuiScreen { public class GuiMultiplayer extends GuiScreen {
private GuiScreen updateCounter; private GuiScreen updateCounter;
@ -26,8 +26,8 @@ public class GuiMultiplayer extends GuiScreen {
this.controlList.clear(); this.controlList.clear();
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Connect")); this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Connect"));
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel")); this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel"));
this.serverAddress = this.mc.gameSettings.field_12259_z.replaceAll("_", ":"); this.serverAddress = Profile.getServer();
this.username = this.mc.gameSettings.username; this.username = Profile.getName();
((GuiButton)this.controlList.get(0)).enabled = this.serverAddress.length() > 0 && this.username.length() > 0 && !this.serverAddress.isBlank() && !this.username.isBlank() && !this.serverAddress.isEmpty() && !this.username.isEmpty(); ((GuiButton)this.controlList.get(0)).enabled = this.serverAddress.length() > 0 && this.username.length() > 0 && !this.serverAddress.isBlank() && !this.username.isBlank() && !this.serverAddress.isEmpty() && !this.username.isEmpty();
} }
@ -36,11 +36,9 @@ public class GuiMultiplayer extends GuiScreen {
if(var1.id == 1) { if(var1.id == 1) {
this.mc.displayGuiScreen(this.updateCounter); this.mc.displayGuiScreen(this.updateCounter);
} else if(var1.id == 0) { } else if(var1.id == 0) {
Minecraft.getMinecraft().field_6320_i = new Session(this.username); Profile.setServer(this.serverAddress);
this.mc.gameSettings.field_12259_z = this.serverAddress.replaceAll(":", "_"); Profile.setName(this.username);
this.mc.gameSettings.username = this.username; Profile.save();
this.mc.gameSettings.saveOptions();
String[] var2 = this.serverAddress.split(":");
this.mc.displayGuiScreen(new GuiConnecting(this.mc, serverAddress)); this.mc.displayGuiScreen(new GuiConnecting(this.mc, serverAddress));
} }

View File

@ -133,4 +133,8 @@ public class NBTTagCompound extends NBTBase {
public String toString() { public String toString() {
return "" + this.tagMap.size() + " entries"; return "" + this.tagMap.size() + " entries";
} }
public boolean hasNoTags() {
return this.tagMap.isEmpty();
}
} }

View File

@ -313,7 +313,7 @@ public class NetClientHandler extends NetHandler {
} }
public void handleHandshake(Packet2Handshake var1) { public void handleHandshake(Packet2Handshake var1) {
this.addToSendQueue(new Packet1Login(this.mc.field_6320_i.inventory, "Password", 6)); this.addToSendQueue(new Packet1Login(this.mc.session.username, "Password", 6));
} }
public void disconnect() { public void disconnect() {

View File

@ -78,7 +78,7 @@ public class PlayerController {
} }
public EntityPlayer func_4087_b(World var1) { public EntityPlayer func_4087_b(World var1) {
return new EntityPlayerSP(this.mc, var1, this.mc.field_6320_i, var1.worldProvider.field_4218_e); return new EntityPlayerSP(this.mc, var1, this.mc.session, var1.worldProvider.field_4218_e);
} }
public void func_6475_a(EntityPlayer var1, Entity var2) { public void func_6475_a(EntityPlayer var1, Entity var2) {

View File

@ -155,7 +155,7 @@ public class PlayerControllerMP extends PlayerController {
} }
public EntityPlayer func_4087_b(World var1) { public EntityPlayer func_4087_b(World var1) {
return new EntityClientPlayerMP(this.mc, var1, this.mc.field_6320_i, this.field_9438_k); return new EntityClientPlayerMP(this.mc, var1, this.mc.session, this.field_9438_k);
} }
public void func_6472_b(EntityPlayer var1, Entity var2) { public void func_6472_b(EntityPlayer var1, Entity var2) {

View File

@ -5,11 +5,10 @@ import java.util.List;
public class Session { public class Session {
public static List registeredBlocksList = new ArrayList(); public static List registeredBlocksList = new ArrayList();
public String inventory; public String username;
public String field_6542_d;
public Session(String var1) { public Session(String var1) {
this.inventory = var1; this.username = var1;
} }
static { static {

View File

@ -0,0 +1,227 @@
package net.minecraft.src;
import net.PeytonPlayz585.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import net.PeytonPlayz585.EaglercraftRandom;
public class SoundManager {
private int field_587_e = 0;
private GameSettings options;
private static boolean loaded = false;
private EaglercraftRandom rand = new EaglercraftRandom();
private int field_583_i = this.rand.nextInt(12000);
private static List<Integer> sounds = new ArrayList<Integer>();
private static int BgMusic = -1;
static String[] music = new String[] {"music.calm1_mp3", "music.calm2_mp3", "music.calm3_mp3", "newMusic.hal1_mp3", "newMusic.hal2_mp3", "newMusic.hal3_mp3", "newMusic.hal4_mp3", "newMusic.nuance1_mp3", "newMusic.nuance2_mp3", "newMusic.piano1_mp3", "newMusic.piano2_mp3", "newMusic.piano3_mp3"};
public void func_340_a(GameSettings var1) {
this.options = var1;
loaded = true;
}
public void onSoundOptionsChanged() {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded) {
if(this.options.musicVolume == 0.0F) {
if(BgMusic != -1) {
GL11.EaglerAdapterImpl2.endSound(BgMusic);
}
} else {
if(BgMusic != -1) {
GL11.EaglerAdapterImpl2.setVolume(BgMusic, this.options.musicVolume);
}
}
if(this.options.soundVolume == 0.0F) {
for(Integer i : sounds) {
if(i != -1) {
GL11.EaglerAdapterImpl2.endSound(i);
}
}
} else {
for(Integer i : sounds) {
if(i != -1) {
GL11.EaglerAdapterImpl2.setVolume(i, this.options.soundVolume);
}
}
}
}
}
public void closeMinecraft() {
/*
* Already handled by the EaglerAdapter
*/
}
public void func_4033_c() {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.musicVolume != 0.0F) {
if(!GL11.EaglerAdapterImpl2.isPlaying(BgMusic)) {
try {
if(this.field_583_i > 0) {
--this.field_583_i;
return;
}
//Apparently I DO NOT know how to use random.nextInt
int var1 = rand.nextInt(music.length);
BgMusic = GL11.EaglerAdapterImpl2.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F);
if(BgMusic != -1) {
this.field_583_i = this.rand.nextInt(12000) + 12000;
}
} catch(Exception e) {
BgMusic = -1;
return;
}
}
}
}
public void func_338_a(EntityLiving var1, float var2) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
if(var1 != null) {
float var9 = var1.prevRotationPitch + (var1.rotationPitch - var1.prevRotationPitch) * var2;
float var3 = var1.prevRotationYaw + (var1.rotationYaw - var1.prevRotationYaw) * var2;
double var4 = var1.prevPosX + (var1.posX - var1.prevPosX) * (double)var2;
double var6 = var1.prevPosY + (var1.posY - var1.prevPosY) * (double)var2;
double var8 = var1.prevPosZ + (var1.posZ - var1.prevPosZ) * (double)var2;
try {
GL11.EaglerAdapterImpl2.setListenerPos((float)var4, (float)var6, (float)var8, (float)var1.motionX, (float)var1.motionY, (float)var1.motionZ, (float)var9, (float)var3);
} catch(Exception e) {
// ???
}
}
}
}
public void func_331_a(String var1, float var2, float var3, float var4, float var5, float var6) {
func_331_a(var1, var2, var3, var4, var5, var6, rand.nextInt((4 - 1) + 1) + 1);
}
public void func_331_a(String var1, float var2, float var3, float var4, float var5, float var6, int number) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
if(var1 == null) {
return;
}
String var7;
var7 = "sounds/" + var1.replace(".", "/") + number + ".mp3";
if(var7 != null && var5 > 0.0F) {
if(var5 > 1.0F) {
var5 = 1.0F;
}
int i = GL11.EaglerAdapterImpl2.beginPlayback(var7.replace("0", ""), var2, var3, var4, var5 * this.options.soundVolume, var6);
if(i != -1) {
sounds.add(i);
} else {
if(number != 0) {
func_331_a(var1, var2, var3, var4, var5, var6, number - 1);
} else {
System.err.println("Unknown sound: " + var7.replace("0", ""));
}
}
}
}
}
public void func_336_b(String var1, float var2, float var3, float var4, float var5, float var6) {
func_336_b(var1, var2, var3, var4, var5, var6, rand.nextInt((4 - 1) + 1) + 1);
}
public void func_336_b(String var1, float var2, float var3, float var4, float var5, float var6, int number) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
if(var1 == null) {
return;
}
String var7;
var7 = "sounds/" + var1.replace(".", "/") + number + ".mp3";
if(var7 != null && var5 > 0.0F) {
if(var5 > 1.0F) {
var5 = 1.0F;
}
int i = GL11.EaglerAdapterImpl2.beginPlayback(var7.replace("0", ""), var2, var3, var4, var5 * this.options.soundVolume, var6);
if(i != -1) {
sounds.add(i);
} else {
if(number != 0) {
func_336_b(var1, var2, var3, var4, var5, var6, number - 1);
} else {
System.err.println("Unknown sound: " + var7.replace("0", ""));
}
}
}
}
}
public void func_337_a(String var1, float var2, float var3) {
func_337_a(var1, var2, var3, rand.nextInt((4 - 1) + 1) + 1);
}
public void func_337_a(String var1, float var2, float var3, int number) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
String var4 = "sounds/" + var1.replace(".", "/") + number + ".mp3";
if(var4 != null) {
if(var2 > 1.0F) {
var2 = 1.0F;
}
int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(var4.replace("0", ""), var2 * this.options.soundVolume, var3);
if(i != -1) {
sounds.add(i);
} else {
if(number != 0) {
func_337_a(var1, var2, var3, number - 1);
} else {
System.err.println("Unknown sound: " + var4.replace("0", ""));
}
}
}
}
}
}

View File

@ -2,7 +2,7 @@ package net.minecraft.src;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
class ThreadConnectToServer extends Thread { class ThreadConnectToServer {
final Minecraft mc; final Minecraft mc;
final String uri; final String uri;
final GuiConnecting connectingGui; final GuiConnecting connectingGui;
@ -13,14 +13,14 @@ class ThreadConnectToServer extends Thread {
this.uri = var3; this.uri = var3;
} }
public void run() { public void start() {
try { try {
GuiConnecting.setNetClientHandler(this.connectingGui, new NetClientHandler(this.mc, this.uri)); GuiConnecting.setNetClientHandler(this.connectingGui, new NetClientHandler(this.mc, this.uri));
if(GuiConnecting.isCancelled(this.connectingGui)) { if(GuiConnecting.isCancelled(this.connectingGui)) {
return; return;
} }
GuiConnecting.getNetClientHandler(this.connectingGui).addToSendQueue(new Packet2Handshake(this.mc.field_6320_i.inventory)); GuiConnecting.getNetClientHandler(this.connectingGui).addToSendQueue(new Packet2Handshake(this.mc.session.username));
} catch (Exception var4) { } catch (Exception var4) {
if(GuiConnecting.isCancelled(this.connectingGui)) { if(GuiConnecting.isCancelled(this.connectingGui)) {
return; return;