Added step sounds and fix lighting
This commit is contained in:
parent
1a498516da
commit
665a385aab
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Shadow Client Classic</title>
|
||||
<title>0.30 Classic</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="app.js"></script>
|
||||
<script type = text/javascript>
|
||||
if(document.location.href.startsWith("file:")) {
|
||||
alert("Offline Download is not yet supported, please upload all the game files to a HTTP(s) server");
|
||||
alert("Offline Download is not supported yet, please upload all the game files to a HTTP(s) server");
|
||||
} else {
|
||||
window.addEventListener("load", function() {
|
||||
window.classicConfig = ["game","resources.mc"];
|
||||
|
|
BIN
js/resources.mc
BIN
js/resources.mc
Binary file not shown.
|
@ -32,6 +32,9 @@ out vec4 v_position;
|
|||
#ifdef CC_a_color
|
||||
out vec4 v_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
out vec4 v_normal;
|
||||
#endif
|
||||
#ifdef CC_a_texture0
|
||||
out vec2 v_texture0;
|
||||
#endif
|
||||
|
@ -44,6 +47,9 @@ void main(){
|
|||
#ifdef CC_a_color
|
||||
v_color = a_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
v_normal = a_normal;
|
||||
#endif
|
||||
#ifdef CC_a_texture0
|
||||
v_texture0 = a_texture0;
|
||||
#endif
|
||||
|
|
|
@ -52,7 +52,7 @@ public class GameMode
|
|||
|
||||
if(block.stepsound != Tile$SoundType.none && minecraft.settings.sound)
|
||||
{
|
||||
level.playSound(block.stepsound.name, (float)x, (float)y, (float)z, (block.stepsound.getVolume() + 1.0F) / 2.0F,block.stepsound.getPitch());
|
||||
level.playSound(block.stepsound.name);
|
||||
}
|
||||
|
||||
if(block != null && success)
|
||||
|
|
|
@ -146,9 +146,12 @@ public final class HUDScreen extends Screen {
|
|||
}
|
||||
}
|
||||
|
||||
var5.drawString("0.30 WebGL", 2, 2, 16777215);
|
||||
byte[] text = new byte[] {48, 46, 51, 48, 32, 67, 108, 97, 115, 115, 105, 99};
|
||||
byte[] text1 = new byte[] {40, 77, 97, 100, 101, 32, 98, 121, 32, 80, 101, 121, 116, 111, 110, 80, 108, 97, 121, 122, 53, 56, 53, 41};
|
||||
var5.drawString(new String(text), 2, 2, 16777215);
|
||||
var5.drawString(new String(text1), 2, 12, 16777215);
|
||||
if(this.mc.settings.showFrameRate) {
|
||||
var5.drawString(this.mc.debug, 2, 12, 16777215);
|
||||
var5.drawString(this.mc.debug, 2, 22, 16777215);
|
||||
}
|
||||
|
||||
if(this.mc.gamemode instanceof SurvivalGameMode) {
|
||||
|
|
|
@ -980,7 +980,7 @@ public class Level implements Serializable {
|
|||
this.blockMap.removeAllNonCreativeModeEntities();
|
||||
}
|
||||
|
||||
public void playSound(String name, float x, float y, float z, float f, float g) {
|
||||
public void playSound(String name) {
|
||||
if(name == "grass" || name == "cloth") {
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
|
@ -1005,4 +1005,30 @@ public class Level implements Serializable {
|
|||
GL11.beginPlayback("sounds/blocks/stone" + randNum + ".mp3");
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound(String name, float volume) {
|
||||
if(name == "grass" || name == "cloth") {
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
if(randNum == 3) {
|
||||
randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
}
|
||||
if(randNum == 3) {
|
||||
randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
}
|
||||
GL11.beginPlayback("sounds/blocks/grass" + randNum + ".mp3", volume);
|
||||
} else if(name == "wood") {
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
GL11.beginPlayback("sounds/blocks/wood" + randNum + ".mp3", 1.0F);
|
||||
} else if(name == "gravel") {
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
GL11.beginPlayback("sounds/blocks/gravel" + randNum + ".mp3", volume);
|
||||
} else if(name == "metal" || name == "stone") {
|
||||
Random rand = new Random();
|
||||
int randNum = rand.nextInt((4 - 1) + 1) + 1;
|
||||
GL11.beginPlayback("sounds/blocks/stone" + randNum + ".mp3", 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mojang.minecraft.mob;
|
|||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.mob.ai.AI;
|
||||
import com.mojang.minecraft.mob.ai.BasicAI;
|
||||
import com.mojang.minecraft.model.ModelManager;
|
||||
|
@ -73,12 +74,28 @@ public class Mob extends Entity {
|
|||
}
|
||||
|
||||
private int prevHealth = this.health;
|
||||
private int prevX = (int)this.x;
|
||||
private int prevZ = (int)this.z;
|
||||
private int ticks = 0;
|
||||
private int prevSoundPlayed = 0;
|
||||
|
||||
public final void tick() {
|
||||
super.tick();
|
||||
ticks++;
|
||||
if(this instanceof Player) {
|
||||
if(this.health < this.prevHealth && Minecraft.settings.sound) {
|
||||
GL11.beginPlayback("sounds/player/oof.mp3");
|
||||
}
|
||||
if((prevX != (int)this.x || prevZ != (int)this.z) && this.onGround && ticks > (prevSoundPlayed + 8) && (!this.isInWater() || !this.isUnderWater())) {
|
||||
int var19 = this.level.getTile((int)this.x, (int)(this.y - 0.2F - this.heightOffset), (int)this.z);
|
||||
Block block = Block.blocks[var19];
|
||||
if(block != null) {
|
||||
Minecraft.getMinecraft().level.playSound(block.stepsound.name, 0.1F);
|
||||
prevSoundPlayed = ticks;
|
||||
}
|
||||
prevX = (int)this.x;
|
||||
prevZ = (int)this.z;
|
||||
}
|
||||
}
|
||||
this.prevHealth = this.health;
|
||||
this.oTilt = this.tilt;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mojang.minecraft.player;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.mob.Mob;
|
||||
import com.mojang.minecraft.model.HumanoidModel;
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.mojang.minecraft.render;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
|
||||
public class TextureLocation {
|
||||
|
||||
private String path;
|
||||
|
@ -31,11 +33,13 @@ public class TextureLocation {
|
|||
}
|
||||
|
||||
public int bindTexture() {
|
||||
Minecraft.getMinecraft().renderer.setLighting(true);
|
||||
RenderEngine r = new RenderEngine();
|
||||
int i = getTexturePointer();
|
||||
if(i != -1) {
|
||||
r.bindTexture(i);
|
||||
}
|
||||
Minecraft.getMinecraft().renderer.setLighting(false);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class FixedFunctionShader {
|
|||
}
|
||||
|
||||
public static final int COLOR = 1;
|
||||
//public static final int NORMAL = 2;
|
||||
public static final int NORMAL = 2;
|
||||
public static final int TEXTURE0 = 4;
|
||||
public static final int LIGHTING = 8;
|
||||
public static final int FOG = 16;
|
||||
|
@ -30,7 +30,7 @@ public class FixedFunctionShader {
|
|||
FixedFunctionShader s = instances[i];
|
||||
if (s == null) {
|
||||
boolean CC_a_color = false;
|
||||
// boolean CC_a_normal = false;
|
||||
boolean CC_a_normal = false;
|
||||
boolean CC_a_texture0 = false;
|
||||
boolean CC_lighting = false;
|
||||
boolean CC_fog = false;
|
||||
|
@ -39,9 +39,9 @@ public class FixedFunctionShader {
|
|||
if ((i & COLOR) == COLOR) {
|
||||
CC_a_color = true;
|
||||
}
|
||||
// if ((i & NORMAL) == NORMAL) {
|
||||
// CC_a_normal = true;
|
||||
// }
|
||||
if ((i & NORMAL) == NORMAL) {
|
||||
CC_a_normal = true;
|
||||
}
|
||||
if ((i & TEXTURE0) == TEXTURE0) {
|
||||
CC_a_texture0 = true;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class FixedFunctionShader {
|
|||
if ((i & UNIT0) == UNIT0) {
|
||||
CC_unit0 = true;
|
||||
}
|
||||
s = new FixedFunctionShader(i, CC_a_color, CC_a_texture0, CC_lighting, CC_fog, CC_alphatest, CC_unit0);
|
||||
s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_lighting, CC_fog, CC_alphatest, CC_unit0);
|
||||
instances[i] = s;
|
||||
}
|
||||
return s;
|
||||
|
@ -66,7 +66,7 @@ public class FixedFunctionShader {
|
|||
private static String shaderSource = null;
|
||||
|
||||
private final boolean enable_color;
|
||||
// private final boolean enable_normal;
|
||||
private final boolean enable_normal;
|
||||
private final boolean enable_texture0;
|
||||
private final boolean enable_lighting;
|
||||
private final boolean enable_fog;
|
||||
|
@ -106,10 +106,10 @@ public class FixedFunctionShader {
|
|||
public final BufferGL genericBuffer;
|
||||
public boolean bufferIsInitialized = false;
|
||||
|
||||
private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_texture0,
|
||||
private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0,
|
||||
boolean CC_lighting, boolean CC_fog, boolean CC_alphatest, boolean CC_unit0) {
|
||||
enable_color = CC_a_color;
|
||||
// enable_normal = CC_a_normal;
|
||||
enable_normal = CC_a_normal;
|
||||
enable_texture0 = CC_a_texture0;
|
||||
enable_lighting = CC_lighting;
|
||||
enable_fog = CC_fog;
|
||||
|
@ -123,8 +123,8 @@ public class FixedFunctionShader {
|
|||
String source = "";
|
||||
if (enable_color)
|
||||
source += "\n#define CC_a_color\n";
|
||||
//if (enable_normal)
|
||||
//source += "#define CC_a_normal\n";
|
||||
if (enable_normal)
|
||||
source += "#define CC_a_normal\n";
|
||||
if (enable_texture0)
|
||||
source += "#define CC_a_texture0\n";
|
||||
if (enable_lighting)
|
||||
|
@ -175,12 +175,12 @@ public class FixedFunctionShader {
|
|||
} else {
|
||||
a_color = -1;
|
||||
}
|
||||
//if (enable_normal) {
|
||||
//a_normal = i++;
|
||||
//_wglBindAttributeLocation(globject, a_normal, "a_normal");
|
||||
//} else {
|
||||
if (enable_normal) {
|
||||
a_normal = i++;
|
||||
_wglBindAttributeLocation(globject, a_normal, "a_normal");
|
||||
} else {
|
||||
a_normal = -1;
|
||||
//}
|
||||
}
|
||||
|
||||
attributeIndexesToEnable = i;
|
||||
|
||||
|
@ -206,7 +206,6 @@ public class FixedFunctionShader {
|
|||
|
||||
if (enable_lighting) {
|
||||
u_normalUniform = _wglGetUniformLocation(globject, "normalUniform");
|
||||
// u_invertNormals = _wglGetUniformLocation(globject, "invertNormals");
|
||||
u_light0Pos = _wglGetUniformLocation(globject, "light0Pos");
|
||||
u_light1Pos = _wglGetUniformLocation(globject, "light1Pos");
|
||||
}
|
||||
|
@ -246,10 +245,10 @@ public class FixedFunctionShader {
|
|||
_wglEnableVertexAttribArray(a_color);
|
||||
_wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 28, 20);
|
||||
}
|
||||
//if (enable_normal) {
|
||||
//_wglEnableVertexAttribArray(a_normal);
|
||||
//_wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 28, 24);
|
||||
//}
|
||||
if (enable_normal) {
|
||||
_wglEnableVertexAttribArray(a_normal);
|
||||
_wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 28, 24);
|
||||
}
|
||||
}
|
||||
|
||||
public void useProgram() {
|
||||
|
|
|
@ -1467,9 +1467,9 @@ public class EaglerAdapterImpl2 {
|
|||
return ret.buffer;
|
||||
}
|
||||
|
||||
public static void beginPlayback(String fileName) {
|
||||
public static int beginPlayback(String fileName) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return;
|
||||
if(b == null) return -1;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
PannerNode p = audioctx.createPanner();
|
||||
|
@ -1479,8 +1479,31 @@ public class EaglerAdapterImpl2 {
|
|||
g.connect(p);
|
||||
p.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
final int theId = ++playbackId;
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
|
||||
s.setOnEnded(new EventListener<MediaEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(MediaEvent evt) {
|
||||
activeSoundEffects.remove(theId);
|
||||
}
|
||||
|
||||
});
|
||||
return theId;
|
||||
}
|
||||
public static void beginPlayback(String fileName, float volume) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
PannerNode p = audioctx.createPanner();
|
||||
GainNode g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(p);
|
||||
p.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
}
|
||||
public static final int beginPlayback(String fileName, float x, float y, float z, float volume) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
|
|
|
@ -36,6 +36,11 @@ public class Tessellator {
|
|||
*/
|
||||
private boolean hasTexture = false;
|
||||
|
||||
/**
|
||||
* Whether the current draw object for this tessellator has normal values.
|
||||
*/
|
||||
private boolean hasNormals = false;
|
||||
|
||||
/** The index into the raw buffer to be used for the next data. */
|
||||
private int rawBufferIndex = 0;
|
||||
|
||||
|
@ -64,6 +69,9 @@ public class Tessellator {
|
|||
*/
|
||||
private double zOffset;
|
||||
|
||||
/** The normal to be applied to the face being drawn. */
|
||||
private int normal;
|
||||
|
||||
/** The static instance of the Tessellator. */
|
||||
public static final Tessellator instance = new Tessellator(525000);
|
||||
|
||||
|
@ -105,9 +113,9 @@ public class Tessellator {
|
|||
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
// if (this.hasNormals) {
|
||||
// GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
// }
|
||||
if (this.hasNormals) {
|
||||
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
GL11.glDrawArrays(drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
|
||||
|
||||
|
@ -119,9 +127,9 @@ public class Tessellator {
|
|||
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
// if (this.hasNormals) {
|
||||
// GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
// }
|
||||
if (this.hasNormals) {
|
||||
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
int var1 = this.rawBufferIndex * 4;
|
||||
|
@ -145,12 +153,10 @@ public class Tessellator {
|
|||
* mode).
|
||||
*/
|
||||
public void startDrawing(int drawMode) {
|
||||
// if (this.isDrawing) {
|
||||
// this.draw();
|
||||
// }
|
||||
this.drawMode = drawMode;
|
||||
this.isDrawing = true;
|
||||
this.reset();
|
||||
this.hasNormals = false;
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
this.isColorDisabled = false;
|
||||
|
@ -264,6 +270,10 @@ public class Tessellator {
|
|||
intBuffer0.set(bufferIndex + 5, this.color);
|
||||
}
|
||||
|
||||
if (this.hasNormals) {
|
||||
intBuffer0.set(bufferIndex + 6, this.normal);
|
||||
}
|
||||
|
||||
this.rawBufferIndex += 7;
|
||||
}
|
||||
|
||||
|
@ -300,6 +310,12 @@ public class Tessellator {
|
|||
* Sets the normal for the current draw call.
|
||||
*/
|
||||
public void setNormal(float par1, float par2, float par3) {
|
||||
this.hasNormals = true;
|
||||
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
|
||||
int var4 = (int)((par1 / len) * 125.0F) + 125;
|
||||
int var5 = (int)((par2 / len) * 125.0F) + 125;
|
||||
int var6 = (int)((par3 / len) * 125.0F) + 125;
|
||||
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
|
||||
GL11.glNormal3f(par1, par2, par3);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
private static DisplayList compilingDisplayList = null;
|
||||
|
||||
private static boolean enableColorArray = false;
|
||||
//private static boolean enableNormalArray = false;
|
||||
private static boolean enableNormalArray = false;
|
||||
private static boolean enableTex0Array = false;
|
||||
|
||||
private static float colorR = 1.0f;
|
||||
|
@ -745,9 +745,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
case GL_COLOR_ARRAY:
|
||||
enableColorArray = true;
|
||||
break;
|
||||
// case GL_NORMAL_ARRAY:
|
||||
// enableNormalArray = true;
|
||||
// break;
|
||||
case GL_NORMAL_ARRAY:
|
||||
enableNormalArray = true;
|
||||
break;
|
||||
case GL_TEXTURE_COORD_ARRAY:
|
||||
enableTex0Array = true;
|
||||
break;
|
||||
|
@ -761,9 +761,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
case GL_COLOR_ARRAY:
|
||||
enableColorArray = false;
|
||||
break;
|
||||
// case GL_NORMAL_ARRAY:
|
||||
// enableNormalArray = false;
|
||||
// break;
|
||||
case GL_NORMAL_ARRAY:
|
||||
enableNormalArray = false;
|
||||
break;
|
||||
case GL_TEXTURE_COORD_ARRAY:
|
||||
enableTex0Array = false;
|
||||
break;
|
||||
|
@ -775,7 +775,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
private static final int getShaderModeFlag0() {
|
||||
int mode = 0;
|
||||
mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0));
|
||||
//mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0));
|
||||
mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0));
|
||||
mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0));
|
||||
return mode;
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
private static final int getShaderModeFlag() {
|
||||
int mode = 0;
|
||||
mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0));
|
||||
//mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0));
|
||||
mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0));
|
||||
mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0));
|
||||
mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0));
|
||||
mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0));
|
||||
|
|
Loading…
Reference in New Issue
Block a user