Add sound/music, performance fixes

This commit is contained in:
PeytonPlayz595 2024-06-09 14:23:19 -04:00
parent 7095e0be52
commit 9205b4d267
9 changed files with 266 additions and 301 deletions

View File

@ -145,7 +145,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
private static float fogColorA = 1.0f; private static float fogColorA = 1.0f;
private static int fogMode = 1; private static int fogMode = 1;
private static boolean fogEnabled = false; private static boolean fogEnabled = false;
private static boolean fogPremultiply = false; //private static boolean fogPremultiply = false;
private static float fogStart = 1.0f; private static float fogStart = 1.0f;
private static float fogEnd = 1.0f; private static float fogEnd = 1.0f;
private static float fogDensity = 1.0f; private static float fogDensity = 1.0f;
@ -288,8 +288,12 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
alphaThresh = p2; alphaThresh = p2;
} }
private static int stateCullFace = -1;
public static final void glCullFace(int p1) { public static final void glCullFace(int p1) {
_wglCullFace(p1); if(p1 != stateCullFace) {
stateCullFace = p1;
_wglCullFace(p1);
}
} }
public static final void glMatrixMode(int p1) { public static final void glMatrixMode(int p1) {
@ -428,7 +432,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
} }
public static final void glLineWidth(float p1) { public static final void glLineWidth(float p1) {
webgl.lineWidth(p1);
} }
public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
@ -568,12 +572,25 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
} }
} }
static int stateBlendSRC = -1;
static int stateBlendDST = -1;
public static final void glBlendFunc(int p1, int p2) { public static final void glBlendFunc(int p1, int p2) {
fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA); // fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA);
// if(overlayFBOBlending) {
// _wglBlendFuncSeparate(p1, p2, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
// }else {
// _wglBlendFunc(p1, p2);
// }
if(overlayFBOBlending) { if(overlayFBOBlending) {
_wglBlendFuncSeparate(p1, p2, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparate(p1, p2, 0, 1);
}else { return;
}
int srcBits = (p1 | (p1 << 16));
int dstBits = (p2 | (p2 << 16));
if(srcBits != stateBlendSRC || dstBits != stateBlendDST) {
_wglBlendFunc(p1, p2); _wglBlendFunc(p1, p2);
stateBlendSRC = srcBits;
stateBlendDST = dstBits;
} }
} }
@ -584,12 +601,27 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
} }
public static final void glBlendFuncSeparate(int p1, int p2, int p3, int p4) { public static final void glBlendFuncSeparate(int p1, int p2, int p3, int p4) {
fogPremultiply = (p3 == GL_ONE && p4 == GL_ONE_MINUS_SRC_ALPHA); // fogPremultiply = (p3 == GL_ONE && p4 == GL_ONE_MINUS_SRC_ALPHA);
_wglBlendFuncSeparate(p1, p2, p3, p4); // _wglBlendFuncSeparate(p1, p2, p3, p4);
if(overlayFBOBlending) { // game overlay framebuffer in EntityRenderer.java
p3 = GL_ONE;
p4 = GL_ONE_MINUS_SRC_ALPHA;
}
int srcBits = (p1 | (p3 << 16));
int dstBits = (p2 | (p4 << 16));
if(srcBits != stateBlendSRC || dstBits != stateBlendDST) {
_wglBlendFuncSeparate(p1, p2, p3, p4);
stateBlendSRC = srcBits;
stateBlendDST = dstBits;
}
} }
private static boolean stateDepthMask = true;
public static final void glDepthMask(boolean p1) { public static final void glDepthMask(boolean p1) {
_wglDepthMask(p1); if(p1 != stateDepthMask) {
stateDepthMask = p1;
_wglDepthMask(p1);
}
} }
public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) {
@ -645,10 +677,10 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
} }
public static final void glNormal3f(float p1, float p2, float p3) { public static final void glNormal3f(float p1, float p2, float p3) {
float len = (float) Math.sqrt(p1 * p1 + p2 * p2 + p3 * p3); //float len = (float) Math.sqrt(p1 * p1 + p2 * p2 + p3 * p3);
normalX = p1 / len; normalX = p1 /*/ len*/;
normalY = p2 / len; normalY = p2 /*/ len*/;
normalZ = p3 / len; normalZ = p3 /*/ len*/;
} }
public static final int glGenLists(int p1) { public static final int glGenLists(int p1) {
@ -857,7 +889,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
} }
s.setColor(colorR, colorG, colorB, colorA); s.setColor(colorR, colorG, colorB, colorA);
if (fogEnabled) { if (fogEnabled) {
s.setFogMode((fogPremultiply ? 2 : 0) + fogMode); s.setFogMode(fogMode);
s.setFogColor(fogColorR, fogColorG, fogColorB, fogColorA); s.setFogColor(fogColorR, fogColorG, fogColorB, fogColorA);
s.setFogDensity(fogDensity); s.setFogDensity(fogDensity);
s.setFogStartEnd(fogStart, fogEnd); s.setFogStartEnd(fogStart, fogEnd);

View File

@ -2,10 +2,10 @@ package net.lax1dude.eaglercraft;
public class BufferedImage { public class BufferedImage {
public final int[] data; private final int[] data;
public final int w; public final int w;
public final int h; public final int h;
public final boolean alpha; private final boolean alpha;
public BufferedImage(int width, int height, int[] pixels, boolean alpha) { public BufferedImage(int width, int height, int[] pixels, boolean alpha) {
this.w = width; this.w = width;
@ -36,55 +36,51 @@ public class BufferedImage {
return new BufferedImage(pw, ph, img, alpha); return new BufferedImage(pw, ph, img, alpha);
} }
public int[] data() { public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
return this.data; if (startX < 0 || startY < 0 || w <= 0 || h <= 0 ||
} startX + w > this.w || startY + h > this.h ||
rgbArray.length < offset + w * h) {
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { throw new IllegalArgumentException("Invalid input parameters");
if (startX < 0 || startY < 0 || w <= 0 || h <= 0 || }
startX + w > this.w || startY + h > this.h ||
rgbArray.length < offset + w * h) {
throw new IllegalArgumentException("Suck my dick nigga");
}
for (int y = startY; y < startY + h; y++) { for (int y = startY; y < startY + h; y++) {
for (int x = startX; x < startX + w; x++) { for (int x = startX; x < startX + w; x++) {
int imageDataIndex = y * this.w + x; int imageDataIndex = y * this.w + x;
int argb = data[imageDataIndex]; int argb = data[imageDataIndex];
int alpha = (argb >> 24) & 0xff; int alpha = (argb >> 24) & 0xff;
int red = (argb >> 16) & 0xff; int red = (argb >> 16) & 0xff;
int green = (argb >> 8) & 0xff; int green = (argb >> 8) & 0xff;
int blue = argb & 0xff; int blue = argb & 0xff;
int rgb = (alpha << 24) | (red << 16) | (green << 8) | blue; int rgb = (alpha << 24) | (red << 16) | (green << 8) | blue;
rgbArray[offset + (y - startY) * scansize + (x - startX)] = rgb;
}
}
return rgbArray; rgbArray[offset + (y - startY) * scansize + (x - startX)] = rgb;
}
}
return rgbArray;
} }
public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
if (startX < 0 || startY < 0 || w <= 0 || h <= 0 || if (startX < 0 || startY < 0 || w <= 0 || h <= 0 ||
startX + w > this.w || startY + h > this.h || startX + w > this.w || startY + h > this.h ||
rgbArray.length < offset + w * h) { rgbArray.length < offset + w * h) {
throw new IllegalArgumentException("Big black oily men"); throw new IllegalArgumentException("Invalid input parameters");
} }
for (int y = startY; y < startY + h; y++) { for (int y = startY; y < startY + h; y++) {
for (int x = startX; x < startX + w; x++) { for (int x = startX; x < startX + w; x++) {
int imageDataIndex = y * this.w + x; int imageDataIndex = y * this.w + x;
int rgb = rgbArray[offset + (y - startY) * scansize + (x - startX)]; int rgb = rgbArray[offset + (y - startY) * scansize + (x - startX)];
int alpha = (rgb >> 24) & 0xff; int alpha = (rgb >> 24) & 0xff;
int red = (rgb >> 16) & 0xff; int red = (rgb >> 16) & 0xff;
int green = (rgb >> 8) & 0xff; int green = (rgb >> 8) & 0xff;
int blue = rgb & 0xff; int blue = rgb & 0xff;
int argb = (alpha << 24) | (red << 16) | (green << 8) | blue; int argb = (alpha << 24) | (red << 16) | (green << 8) | blue;
data[imageDataIndex] = argb; data[imageDataIndex] = argb;
} }
} }
} }
public int getWidth() { public int getWidth() {
return w; return w;

View File

@ -42,7 +42,7 @@ public class IndexedDBFilesystem {
System.out.println("Setting custom database name to " + GL11.dataBaseName); System.out.println("Setting custom database name to " + GL11.dataBaseName);
dbo = AsyncHandlers.openDB(GL11.dataBaseName); dbo = AsyncHandlers.openDB(GL11.dataBaseName);
} else { } else {
dbo = AsyncHandlers.openDB("_net_lax1dude_eaglercraft_beta_IndexedDBFilesystem_1_3"); dbo = AsyncHandlers.openDB("_net_PeytonPlayz585_eaglercraft_beta_IndexedDBFilesystem_1_7_3");
} }
if(dbo == null) { if(dbo == null) {
err = "Unknown Error"; err = "Unknown Error";

View File

@ -57,6 +57,7 @@ public class GuiIngameMenu extends GuiScreen {
public void drawScreen(int var1, int var2, float var3) { public void drawScreen(int var1, int var2, float var3) {
this.drawDefaultBackground(); this.drawDefaultBackground();
boolean var4 = !this.mc.theWorld.func_650_a(this.updateCounter2++); boolean var4 = !this.mc.theWorld.func_650_a(this.updateCounter2++);
this.mc.setIngameNotInFocus();
if(var4 || this.updateCounter < 20) { if(var4 || this.updateCounter < 20) {
float var5 = ((float)(this.updateCounter % 10) + var3) / 10.0F; float var5 = ((float)(this.updateCounter % 10) + var3) / 10.0F;
var5 = MathHelper.sin(var5 * (float)Math.PI * 2.0F) * 0.2F + 0.8F; var5 = MathHelper.sin(var5 * (float)Math.PI * 2.0F) * 0.2F + 0.8F;

View File

@ -1148,6 +1148,9 @@ public class RenderGlobal implements IWorldAccess {
public void spawnParticle(String var1, double var2, double var4, double var6, double var8, double var10, double var12) { public void spawnParticle(String var1, double var2, double var4, double var6, double var8, double var10, double var12) {
if(this.mc != null && this.mc.renderViewEntity != null && this.mc.effectRenderer != null) { if(this.mc != null && this.mc.renderViewEntity != null && this.mc.effectRenderer != null) {
if(isBehindPlayer(var2, var4, var6)) {
return;
}
double var14 = this.mc.renderViewEntity.posX - var2; double var14 = this.mc.renderViewEntity.posX - var2;
double var16 = this.mc.renderViewEntity.posY - var4; double var16 = this.mc.renderViewEntity.posY - var4;
double var18 = this.mc.renderViewEntity.posZ - var6; double var18 = this.mc.renderViewEntity.posZ - var6;
@ -1188,6 +1191,12 @@ public class RenderGlobal implements IWorldAccess {
} }
} }
} }
private boolean isBehindPlayer(double x, double y, double z) {
final Vec3D playerToBlock = new Vec3D(x - this.mc.thePlayer.posX, y - this.mc.thePlayer.posY, z - this.mc.thePlayer.posZ).normalize();
final Vec3D direction = (this.mc.thePlayer.getLookVec()).normalize();
return playerToBlock.dotProduct(direction) > 0.5;
}
public void obtainEntitySkin(Entity var1) { public void obtainEntitySkin(Entity var1) {
var1.updateCloak(); var1.updateCloak();

View File

@ -1,196 +1,183 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.File; import java.util.ArrayList;
//import java.util.Random; import java.util.List;
//import paulscode.sound.SoundSystem;
//import paulscode.sound.SoundSystemConfig; import net.PeytonPlayz585.opengl.GL11;
//import paulscode.sound.codecs.CodecJOrbis;
//import paulscode.sound.codecs.CodecWav;
//import paulscode.sound.libraries.LibraryLWJGLOpenAL;
public class SoundManager { public class SoundManager {
// private static SoundSystem sndSystem;
// private SoundPool soundPoolSounds = new SoundPool(); private GameSettings options;
// private SoundPool soundPoolStreaming = new SoundPool(); private static boolean loaded = false;
// private SoundPool soundPoolMusic = new SoundPool(); private Random rand = new Random();
// private int field_587_e = 0; private int ticksBeforeMusic = this.rand.nextInt(12000);
// private GameSettings options;
// private static boolean loaded = false; private static List<Integer> sounds = new ArrayList<Integer>();
// private Random rand = new Random(); private static int BgMusic = -1;
// private int ticksBeforeMusic = this.rand.nextInt(12000);
static String[] music = new String[] {"music.calm1_ogg", "music.calm2_ogg", "music.calm3_ogg", "newMusic.hal1_ogg", "newMusic.hal2_ogg", "newMusic.hal3_ogg", "newMusic.hal4_ogg", "newMusic.nuance1_ogg", "newMusic.nuance2_ogg", "newMusic.piano1_ogg", "newMusic.piano2_ogg", "newMusic.piano3_ogg"};
public void loadSoundSettings(GameSettings var1) { public void loadSoundSettings(GameSettings var1) {
// this.soundPoolStreaming.field_1657_b = false; this.options = var1;
// this.options = var1; loaded = true;
// if(!loaded && (var1 == null || var1.soundVolume != 0.0F || var1.musicVolume != 0.0F)) {
// this.tryToSetLibraryAndCodecs();
// }
} }
private void tryToSetLibraryAndCodecs() {
// try {
// float var1 = this.options.soundVolume;
// float var2 = this.options.musicVolume;
// this.options.soundVolume = 0.0F;
// this.options.musicVolume = 0.0F;
// this.options.saveOptions();
// SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
// SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
// SoundSystemConfig.setCodec("mus", CodecMus.class);
// SoundSystemConfig.setCodec("wav", CodecWav.class);
// sndSystem = new SoundSystem();
// this.options.soundVolume = var1;
// this.options.musicVolume = var2;
// this.options.saveOptions();
// } catch (Throwable var3) {
// var3.printStackTrace();
// System.err.println("error linking with the LibraryJavaSound plug-in");
// }
//
// loaded = true;
}
public void onSoundOptionsChanged() { public void onSoundOptionsChanged() {
// if(!loaded && (this.options.soundVolume != 0.0F || this.options.musicVolume != 0.0F)) { for(int i = 0; i < sounds.size(); i++) {
// this.tryToSetLibraryAndCodecs(); if(!GL11.isPlaying(sounds.get(i))) {
// } sounds.remove(i);
// }
// if(loaded) { }
// if(this.options.musicVolume == 0.0F) {
// sndSystem.stop("BgMusic"); if(loaded) {
// } else { if(this.options.musicVolume == 0.0F) {
// sndSystem.setVolume("BgMusic", this.options.musicVolume); if(BgMusic != -1) {
// } GL11.endSound(BgMusic);
// } }
} else {
if(BgMusic != -1) {
GL11.setVolume(BgMusic, this.options.musicVolume);
}
}
if(this.options.soundVolume == 0.0F) {
for(Integer i : sounds) {
if(i != -1) {
GL11.endSound(i);
}
}
} else {
for(Integer i : sounds) {
if(i != -1) {
GL11.setVolume(i, this.options.soundVolume);
}
}
}
}
} }
public void closeMinecraft() { public void closeMinecraft() {
//if(loaded) { // Do nothing
//sndSystem.cleanup(); }
//}
public void addSound(String var1) {
// Do nothing
} }
public void addSound(String var1, File var2) { public void addMusic(String var1) {
//this.soundPoolSounds.addSound(var1, var2); // Do nothing
} }
public void addStreaming(String var1, File var2) {
//this.soundPoolStreaming.addSound(var1, var2);
}
public void addMusic(String var1, File var2) {
//this.soundPoolMusic.addSound(var1, var2);
}
public void playRandomMusicIfReady() { public void playRandomMusicIfReady() {
// if(loaded && this.options.musicVolume != 0.0F) { for(int i = 0; i < sounds.size(); i++) {
// if(!sndSystem.playing("BgMusic") && !sndSystem.playing("streaming")) { if(!GL11.isPlaying(sounds.get(i))) {
// if(this.ticksBeforeMusic > 0) { sounds.remove(i);
// --this.ticksBeforeMusic; }
// return; }
// }
// if(loaded && this.options.musicVolume != 0.0F) {
// SoundPoolEntry var1 = this.soundPoolMusic.getRandomSound(); if(!GL11.isPlaying(BgMusic)) {
// if(var1 != null) { if(this.ticksBeforeMusic > 0) {
// this.ticksBeforeMusic = this.rand.nextInt(12000) + 12000; --this.ticksBeforeMusic;
// sndSystem.backgroundMusic("BgMusic", var1.soundUrl, var1.soundName, false); return;
// sndSystem.setVolume("BgMusic", this.options.musicVolume); }
// sndSystem.play("BgMusic");
// } int var1 = rand.nextInt((music.length - 1) + 1) + 1;
// } this.ticksBeforeMusic = this.rand.nextInt(12000) + 12000;
// BgMusic = GL11.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F);
// } }
}
} }
public void func_338_a(EntityLiving var1, float var2) { public void func_338_a(EntityLiving var1, float var2) {
// if(loaded && this.options.soundVolume != 0.0F) { for(int i = 0; i < sounds.size(); i++) {
// if(var1 != null) { if(!GL11.isPlaying(sounds.get(i))) {
// float var3 = var1.prevRotationYaw + (var1.rotationYaw - var1.prevRotationYaw) * var2; sounds.remove(i);
// 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;
// float var10 = MathHelper.cos(-var3 * ((float)Math.PI / 180.0F) - (float)Math.PI); if(loaded && this.options.soundVolume != 0.0F) {
// float var11 = MathHelper.sin(-var3 * ((float)Math.PI / 180.0F) - (float)Math.PI); if(var1 != null) {
// float var12 = -var11; float var9 = var1.prevRotationPitch + (var1.rotationPitch - var1.prevRotationPitch) * var2;
// float var13 = 0.0F; float var3 = var1.prevRotationYaw + (var1.rotationYaw - var1.prevRotationYaw) * var2;
// float var14 = -var10; double var4 = var1.prevPosX + (var1.posX - var1.prevPosX) * (double)var2;
// float var15 = 0.0F; double var6 = var1.prevPosY + (var1.posY - var1.prevPosY) * (double)var2;
// float var16 = 1.0F; double var8 = var1.prevPosZ + (var1.posZ - var1.prevPosZ) * (double)var2;
// float var17 = 0.0F; GL11.setListenerPos((float)var4, (float)var6, (float)var8, (float)var1.motionX, (float)var1.motionY, (float)var1.motionZ, (float)var9, (float)var3);
// sndSystem.setListenerPosition((float)var4, (float)var6, (float)var8); }
// sndSystem.setListenerOrientation(var12, var13, var14, var15, var16, var17); }
// }
// }
} }
public void playStreaming(String var1, float var2, float var3, float var4, float var5, float var6) {
// if(loaded && this.options.soundVolume != 0.0F) {
// String var7 = "streaming";
// if(sndSystem.playing("streaming")) {
// sndSystem.stop("streaming");
// }
//
// if(var1 != null) {
// SoundPoolEntry var8 = this.soundPoolStreaming.getRandomSoundFromSoundPool(var1);
// if(var8 != null && var5 > 0.0F) {
// if(sndSystem.playing("BgMusic")) {
// sndSystem.stop("BgMusic");
// }
//
// float var9 = 16.0F;
// sndSystem.newStreamingSource(true, var7, var8.soundUrl, var8.soundName, false, var2, var3, var4, 2, var9 * 4.0F);
// sndSystem.setVolume(var7, 0.5F * this.options.soundVolume);
// sndSystem.play(var7);
// }
//
// }
// }
}
public void playSound(String var1, float var2, float var3, float var4, float var5, float var6) { public void playSound(String var1, float var2, float var3, float var4, float var5, float var6) {
// if(loaded && this.options.soundVolume != 0.0F) { playSound(var1, var2, var3, var4, var5, var6, rand.nextInt((4 - 1) + 1) + 1);
// SoundPoolEntry var7 = this.soundPoolSounds.getRandomSoundFromSoundPool(var1);
// if(var7 != null && var5 > 0.0F) {
// this.field_587_e = (this.field_587_e + 1) % 256;
// String var8 = "sound_" + this.field_587_e;
// float var9 = 16.0F;
// if(var5 > 1.0F) {
// var9 *= var5;
// }
//
// sndSystem.newSource(var5 > 1.0F, var8, var7.soundUrl, var7.soundName, false, var2, var3, var4, 2, var9);
// sndSystem.setPitch(var8, var6);
// if(var5 > 1.0F) {
// var5 = 1.0F;
// }
//
// sndSystem.setVolume(var8, var5 * this.options.soundVolume);
// sndSystem.play(var8);
// }
//
// }
} }
public void playSound(String var1, float var2, float var3, float var4, float var5, float var6, int number) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
String var7 = "sounds/" + var1.replace(".", "/") + number + ".ogg";
if(var7 != null && var5 > 0.0F) {
if(var5 > 1.0F) {
var5 = 1.0F;
}
public void playSoundFX(String var1, float var2, float var3) { int i = GL11.beginPlayback(var7.replace("0", ""), var2, var3, var4, var5 * this.options.soundVolume, var6);
// if(loaded && this.options.soundVolume != 0.0F) { if(i != -1) {
// SoundPoolEntry var4 = this.soundPoolSounds.getRandomSoundFromSoundPool(var1); sounds.add(i);
// if(var4 != null) { } else {
// this.field_587_e = (this.field_587_e + 1) % 256; if(number != 0) {
// String var5 = "sound_" + this.field_587_e; playSound(var1, var2, var3, var4, var5, var6, number - 1);
// sndSystem.newSource(false, var5, var4.soundUrl, var4.soundName, false, 0.0F, 0.0F, 0.0F, 0, 0.0F); } else {
// if(var2 > 1.0F) { System.err.println("Unknown sound: " + var7.replace("0", ""));
// var2 = 1.0F; }
// } }
// }
// var2 *= 0.25F; }
// sndSystem.setPitch(var5, var3);
// sndSystem.setVolume(var5, var2 * this.options.soundVolume);
// sndSystem.play(var5);
// }
//
// }
} }
public void playSoundFX(String var1, float var2, float var3) {
playSoundFX(var1, var2, var3, rand.nextInt((4 - 1) + 1) + 1);
}
public void playSoundFX(String var1, float var2, float var3, int number) {
for(int i = 0; i < sounds.size(); i++) {
if(!GL11.isPlaying(sounds.get(i))) {
sounds.remove(i);
}
}
if(loaded && this.options.soundVolume != 0.0F) {
String var4 = "sounds/" + var1.replace(".", "/") + number + ".ogg";
if(var4 != null) {
if(var2 > 1.0F) {
var2 = 1.0F;
}
int i = GL11.beginPlaybackStatic(var4.replace("0", ""), var2 * this.options.soundVolume, var3);
if(i != -1) {
sounds.add(i);
} else {
if(number != 0) {
playSoundFX(var1, var2, var3, number - 1);
} else {
System.err.println("Unknown sound: " + var4.replace("0", ""));
}
}
}
}
}
//Uhm...
public void playStreaming(String string, float f, float g, float h, float i, float j) {
// TODO Auto-generated method stub
}
} }

View File

@ -1,51 +0,0 @@
package net.minecraft.src;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SoundPool {
private Random rand = new Random();
private Map nameToSoundPoolEntriesMapping = new HashMap();
private List allSoundPoolEntries = new ArrayList();
public int numberOfSoundPoolEntries = 0;
public boolean field_1657_b = true;
public SoundPoolEntry addSound(String var1, File var2) {
try {
String var3 = var1;
var1 = var1.substring(0, var1.indexOf("."));
if(this.field_1657_b) {
while(Character.isDigit(var1.charAt(var1.length() - 1))) {
var1 = var1.substring(0, var1.length() - 1);
}
}
var1 = var1.replaceAll("/", ".");
if(!this.nameToSoundPoolEntriesMapping.containsKey(var1)) {
this.nameToSoundPoolEntriesMapping.put(var1, new ArrayList());
}
SoundPoolEntry var4 = new SoundPoolEntry(var3, var2.toURI().toURL());
((List)this.nameToSoundPoolEntriesMapping.get(var1)).add(var4);
this.allSoundPoolEntries.add(var4);
++this.numberOfSoundPoolEntries;
return var4;
} catch (MalformedURLException var5) {
var5.printStackTrace();
throw new RuntimeException(var5);
}
}
public SoundPoolEntry getRandomSoundFromSoundPool(String var1) {
List var2 = (List)this.nameToSoundPoolEntriesMapping.get(var1);
return var2 == null ? null : (SoundPoolEntry)var2.get(this.rand.nextInt(var2.size()));
}
public SoundPoolEntry getRandomSound() {
return this.allSoundPoolEntries.size() == 0 ? null : (SoundPoolEntry)this.allSoundPoolEntries.get(this.rand.nextInt(this.allSoundPoolEntries.size()));
}
}

View File

@ -1,13 +0,0 @@
package net.minecraft.src;
import java.net.URL;
public class SoundPoolEntry {
public String soundName;
public URL soundUrl;
public SoundPoolEntry(String var1, URL var2) {
this.soundName = var1;
this.soundUrl = var2;
}
}

View File

@ -31,7 +31,7 @@ public class Vec3D {
return ((Vec3D)vectorList.get(nextVector++)).setComponents(var0, var2, var4); return ((Vec3D)vectorList.get(nextVector++)).setComponents(var0, var2, var4);
} }
private Vec3D(double var1, double var3, double var5) { public Vec3D(double var1, double var3, double var5) {
if(var1 == -0D) { if(var1 == -0D) {
var1 = 0.0D; var1 = 0.0D;
} }
@ -64,6 +64,10 @@ public class Vec3D {
double var1 = (double)MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); double var1 = (double)MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord);
return var1 < 1.0E-4D ? createVector(0.0D, 0.0D, 0.0D) : createVector(this.xCoord / var1, this.yCoord / var1, this.zCoord / var1); return var1 < 1.0E-4D ? createVector(0.0D, 0.0D, 0.0D) : createVector(this.xCoord / var1, this.yCoord / var1, this.zCoord / var1);
} }
public double dotProduct(Vec3D vec) {
return this.xCoord * vec.xCoord + this.yCoord * vec.yCoord + this.zCoord * vec.zCoord;
}
public Vec3D crossProduct(Vec3D var1) { public Vec3D crossProduct(Vec3D var1) {
return createVector(this.yCoord * var1.zCoord - this.zCoord * var1.yCoord, this.zCoord * var1.xCoord - this.xCoord * var1.zCoord, this.xCoord * var1.yCoord - this.yCoord * var1.xCoord); return createVector(this.yCoord * var1.zCoord - this.zCoord * var1.yCoord, this.zCoord * var1.xCoord - this.xCoord * var1.zCoord, this.xCoord * var1.yCoord - this.yCoord * var1.xCoord);