Performance patch part 2
This commit is contained in:
parent
484b7b9e9b
commit
33ba016e56
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
gradle/
|
gradle/
|
||||||
desktopRuntime/
|
.gradle/
|
||||||
|
desktopRuntime/
|
||||||
|
build/
|
|
@ -25,13 +25,13 @@ sourceSets {
|
||||||
|
|
||||||
teavm.js {
|
teavm.js {
|
||||||
addedToWebApp = true;
|
addedToWebApp = true;
|
||||||
mainClass = "net.lax1dude.eaglercraft.Client"
|
mainClass = "net.PeytonPlayz585.Client"
|
||||||
outputDir = file("web");
|
outputDir = file("web");
|
||||||
targetFileName = "app.js";
|
targetFileName = "app.js";
|
||||||
obfuscated = true;
|
obfuscated = true;
|
||||||
sourceMap = true;
|
sourceMap = true;
|
||||||
entryPointName = 'main';
|
entryPointName = 'main';
|
||||||
properties = null;
|
properties = null;
|
||||||
optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE;
|
optimization = org.teavm.gradle.api.OptimizationLevel.BALANCED;
|
||||||
processMemory = 512;
|
processMemory = 512;
|
||||||
}
|
}
|
|
@ -12,5 +12,8 @@
|
||||||
<classpathentry kind="lib" path="jars/lwjgl.jar"/>
|
<classpathentry kind="lib" path="jars/lwjgl.jar"/>
|
||||||
<classpathentry kind="lib" path="jars/lwjgl-opengles.jar"/>
|
<classpathentry kind="lib" path="jars/lwjgl-opengles.jar"/>
|
||||||
<classpathentry kind="lib" path="jars/Java-WebSocket-1.5.1-with-dependencies.jar"/>
|
<classpathentry kind="lib" path="jars/Java-WebSocket-1.5.1-with-dependencies.jar"/>
|
||||||
|
<classpathentry kind="lib" path="jars/teavm-interop-0.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="jars/teavm-jso-0.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="jars/teavm-jso-apis-0.6.1.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
|
<link>
|
||||||
|
<name>src_teavm_java</name>
|
||||||
|
<type>2</type>
|
||||||
|
<locationURI>PARENT-2-PROJECT_LOC../src/teavm/java</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>src_lwjgl_java</name>
|
<name>src_lwjgl_java</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -23,10 +23,14 @@ in vec4 a_color;
|
||||||
#ifdef CC_a_normal
|
#ifdef CC_a_normal
|
||||||
in vec4 a_normal;
|
in vec4 a_normal;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_a_texture1
|
||||||
#ifdef CC_fog
|
in vec2 a_texture1;
|
||||||
out vec4 v_position;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_TEX_GEN_STRQ
|
||||||
|
out vec4 v_object_pos;
|
||||||
|
#endif
|
||||||
|
out vec4 v_position;
|
||||||
#ifdef CC_a_color
|
#ifdef CC_a_color
|
||||||
out vec4 v_color;
|
out vec4 v_color;
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,11 +40,20 @@ out vec4 v_normal;
|
||||||
#ifdef CC_a_texture0
|
#ifdef CC_a_texture0
|
||||||
out vec2 v_texture0;
|
out vec2 v_texture0;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_a_texture1
|
||||||
|
out vec2 v_texture1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CC_VERT
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
vec4 pos = matrix_m * vec4(a_position, 1.0);
|
vec4 pos = matrix_m * vec4(a_position, 1.0);
|
||||||
#ifdef CC_fog
|
|
||||||
v_position = pos;
|
v_position = pos;
|
||||||
|
#ifdef CC_TEX_GEN_STRQ
|
||||||
|
v_object_pos = vec4(a_position, 1.0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_a_color
|
#ifdef CC_a_color
|
||||||
v_color = a_color;
|
v_color = a_color;
|
||||||
|
@ -50,6 +63,9 @@ void main(){
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_a_texture0
|
#ifdef CC_a_texture0
|
||||||
v_texture0 = a_texture0;
|
v_texture0 = a_texture0;
|
||||||
|
#endif
|
||||||
|
#ifdef CC_a_texture1
|
||||||
|
v_texture1 = a_texture1;
|
||||||
#endif
|
#endif
|
||||||
gl_Position = matrix_p * pos;
|
gl_Position = matrix_p * pos;
|
||||||
}
|
}
|
||||||
|
@ -58,12 +74,10 @@ void main(){
|
||||||
|
|
||||||
#ifdef CC_FRAG
|
#ifdef CC_FRAG
|
||||||
|
|
||||||
#ifdef CC_unit0
|
|
||||||
uniform sampler2D tex0;
|
uniform sampler2D tex0;
|
||||||
#ifndef CC_a_texture0
|
uniform sampler2D tex1;
|
||||||
uniform vec2 texCoordV0;
|
uniform vec2 texCoordV0;
|
||||||
#endif
|
uniform vec2 texCoordV1;
|
||||||
#endif
|
|
||||||
#ifdef CC_lighting
|
#ifdef CC_lighting
|
||||||
uniform vec3 light0Pos;
|
uniform vec3 light0Pos;
|
||||||
uniform vec3 light1Pos;
|
uniform vec3 light1Pos;
|
||||||
|
@ -71,20 +85,35 @@ uniform vec3 normalUniform;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_fog
|
#ifdef CC_fog
|
||||||
uniform vec4 fogColor;
|
uniform vec4 fogColor;
|
||||||
uniform int fogMode;
|
//X = uniform float fogMode;
|
||||||
uniform float fogStart;
|
//Y = uniform float fogStart;
|
||||||
uniform float fogEnd;
|
//Z = uniform float fogEnd - fogStart;
|
||||||
uniform float fogDensity;
|
//W = uniform float fogDensity;
|
||||||
uniform float fogPremultiply;
|
uniform vec4 fogParam;
|
||||||
#endif
|
#endif
|
||||||
uniform vec4 colorUniform;
|
uniform vec4 colorUniform;
|
||||||
#ifdef CC_alphatest
|
#ifdef CC_alphatest
|
||||||
uniform float alphaTestF;
|
uniform float alphaTestF;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_TEX_GEN_STRQ
|
||||||
#ifdef CC_fog
|
//uniform int textureGenS_M;
|
||||||
in vec4 v_position;
|
//uniform int textureGenT_M;
|
||||||
|
//uniform int textureGenR_M;
|
||||||
|
//uniform int textureGenQ_M;
|
||||||
|
uniform ivec4 textureGen_M;
|
||||||
|
uniform vec4 textureGenS_V;
|
||||||
|
uniform vec4 textureGenT_V;
|
||||||
|
uniform vec4 textureGenR_V;
|
||||||
|
uniform vec4 textureGenQ_V;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_patch_anisotropic
|
||||||
|
uniform vec2 anisotropic_fix;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_TEX_GEN_STRQ
|
||||||
|
in vec4 v_object_pos;
|
||||||
|
#endif
|
||||||
|
in vec4 v_position;
|
||||||
#ifdef CC_a_color
|
#ifdef CC_a_color
|
||||||
in vec4 v_color;
|
in vec4 v_color;
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,10 +123,14 @@ in vec4 v_normal;
|
||||||
#ifdef CC_a_texture0
|
#ifdef CC_a_texture0
|
||||||
in vec2 v_texture0;
|
in vec2 v_texture0;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_a_texture1
|
||||||
|
in vec2 v_texture1;
|
||||||
|
#endif
|
||||||
|
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
#define TEX_MAT3x2(mat4In) mat3x2(mat4In[0].xy,mat4In[1].xy,mat4In[3].xy)
|
#define TEX_MAT3x2(mat4In) mat3x2(mat4In[0].xy,mat4In[1].xy,mat4In[3].xy)
|
||||||
|
#define TEX_MAT4x3(mat4In) mat4x3(mat4In[0].xyw,mat4In[1].xyw,mat4In[2].xyw,mat4In[3].xyw)
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
#ifdef CC_a_color
|
#ifdef CC_a_color
|
||||||
|
@ -106,12 +139,48 @@ void main(){
|
||||||
vec4 color = colorUniform;
|
vec4 color = colorUniform;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_TEX_GEN_STRQ
|
||||||
|
vec4 texSrc[2];
|
||||||
|
texSrc[0] = v_object_pos;
|
||||||
|
texSrc[1] = v_position;
|
||||||
|
|
||||||
|
vec4 texPos;
|
||||||
|
texPos.x = dot(texSrc[textureGen_M.x], textureGenS_V);
|
||||||
|
texPos.y = dot(texSrc[textureGen_M.y], textureGenT_V);
|
||||||
|
texPos.z = dot(texSrc[textureGen_M.z], textureGenR_V);
|
||||||
|
texPos.w = dot(texSrc[textureGen_M.w], textureGenQ_V);
|
||||||
|
texPos.xyz = TEX_MAT4x3(matrix_t) * texPos;
|
||||||
|
color *= texture(tex0, texPos.xy / texPos.z).bgra;
|
||||||
|
#ifdef CC_alphatest
|
||||||
|
if(color.a < alphaTestF){
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
#ifdef CC_unit0
|
#ifdef CC_unit0
|
||||||
#ifdef CC_a_texture0
|
#ifdef CC_a_texture0
|
||||||
color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(v_texture0, 1.0)).xy).rgba;
|
|
||||||
|
#ifdef CC_patch_anisotropic
|
||||||
|
vec2 uv = TEX_MAT3x2(matrix_t) * vec3(v_texture0, 1.0);
|
||||||
|
|
||||||
|
/* https://bugs.chromium.org/p/angleproject/issues/detail?id=4994 */
|
||||||
|
uv = ((uv * anisotropic_fix) - fract(uv * anisotropic_fix) + 0.5) / anisotropic_fix;
|
||||||
|
|
||||||
|
vec4 texColor = texture(tex0, uv);
|
||||||
#else
|
#else
|
||||||
color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(texCoordV0, 1.0)).xy).rgba;
|
vec4 texColor = texture(tex0, TEX_MAT3x2(matrix_t) * vec3(v_texture0, 1.0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
vec4 texColor = texture(tex0, TEX_MAT3x2(matrix_t) * vec3(texCoordV0, 1.0));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_swap_rb
|
||||||
|
color *= texColor.rgba;
|
||||||
|
#else
|
||||||
|
color *= texColor.bgra;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CC_alphatest
|
#ifdef CC_alphatest
|
||||||
|
@ -120,6 +189,15 @@ void main(){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_unit1
|
||||||
|
#ifdef CC_a_texture1
|
||||||
|
color.rgb *= texture(tex1, (v_texture1 + 8.0) * 0.00390625).bgr;
|
||||||
|
#else
|
||||||
|
color.rgb *= texture(tex1, (texCoordV1 + 8.0) * 0.00390625).bgr;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CC_lighting
|
#ifdef CC_lighting
|
||||||
#ifdef CC_a_normal
|
#ifdef CC_a_normal
|
||||||
vec3 normal = ((v_normal.xyz - 0.5) * 2.0);
|
vec3 normal = ((v_normal.xyz - 0.5) * 2.0);
|
||||||
|
@ -133,11 +211,12 @@ void main(){
|
||||||
|
|
||||||
#ifdef CC_fog
|
#ifdef CC_fog
|
||||||
float dist = sqrt(dot(v_position, v_position));
|
float dist = sqrt(dot(v_position, v_position));
|
||||||
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - exp(-(fogDensity * dist)), 0.0, 1.0);
|
float i = fogParam.x == 1.0 ? (dist - fogParam.y) / fogParam.z : 1.0 - exp(-fogParam.w * dist);
|
||||||
color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a);
|
color.rgb = mix(color.rgb, fogColor.xyz, clamp(i, 0.0, 1.0) * fogColor.a);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fragColor = color;
|
fragColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,255 +0,0 @@
|
||||||
#line 0
|
|
||||||
|
|
||||||
precision lowp int;
|
|
||||||
precision lowp sampler2D;
|
|
||||||
precision lowp float;
|
|
||||||
|
|
||||||
in vec2 pos;
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
#define FXAA_PC 1
|
|
||||||
#define FXAA_GLSL_130 1
|
|
||||||
#define FXAA_FAST_PIXEL_OFFSET 0
|
|
||||||
#define FXAA_GATHER4_ALPHA 0
|
|
||||||
|
|
||||||
#ifndef FXAA_GREEN_AS_LUMA
|
|
||||||
// For those using non-linear color,
|
|
||||||
// and either not able to get luma in alpha, or not wanting to,
|
|
||||||
// this enables FXAA to run using green as a proxy for luma.
|
|
||||||
// So with this enabled, no need to pack luma in alpha.
|
|
||||||
//
|
|
||||||
// This will turn off AA on anything which lacks some amount of green.
|
|
||||||
// Pure red and blue or combination of only R and B, will get no AA.
|
|
||||||
//
|
|
||||||
// Might want to lower the settings for both,
|
|
||||||
// fxaaConsoleEdgeThresholdMin
|
|
||||||
// fxaaQualityEdgeThresholdMin
|
|
||||||
// In order to insure AA does not get turned off on colors
|
|
||||||
// which contain a minor amount of green.
|
|
||||||
//
|
|
||||||
// 1 = On.
|
|
||||||
// 0 = Off.
|
|
||||||
//
|
|
||||||
#define FXAA_GREEN_AS_LUMA 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FXAA_DISCARD
|
|
||||||
// 1 = Use discard on pixels which don't need AA.
|
|
||||||
// 0 = Return unchanged color on pixels which don't need AA.
|
|
||||||
#define FXAA_DISCARD 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*============================================================================
|
|
||||||
API PORTING
|
|
||||||
============================================================================*/
|
|
||||||
#define FxaaBool bool
|
|
||||||
#define FxaaDiscard discard
|
|
||||||
#define FxaaFloat float
|
|
||||||
#define FxaaFloat2 vec2
|
|
||||||
#define FxaaFloat3 vec3
|
|
||||||
#define FxaaFloat4 vec4
|
|
||||||
#define FxaaHalf float
|
|
||||||
#define FxaaHalf2 vec2
|
|
||||||
#define FxaaHalf3 vec3
|
|
||||||
#define FxaaHalf4 vec4
|
|
||||||
#define FxaaInt2 ivec2
|
|
||||||
#define FxaaSat(x) clamp(x, 0.0, 1.0)
|
|
||||||
#define FxaaTex sampler2D
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#define FxaaTexTop(t, p) texture(t, p)
|
|
||||||
|
|
||||||
/*============================================================================
|
|
||||||
GREEN AS LUMA OPTION SUPPORT FUNCTION
|
|
||||||
============================================================================*/
|
|
||||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
|
||||||
// TODO Luma
|
|
||||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz, vec3(0.299, 0.587, 0.114)); }
|
|
||||||
#else
|
|
||||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*============================================================================
|
|
||||||
FXAA3 CONSOLE - PC VERSION
|
|
||||||
============================================================================*/
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat4 FxaaPixelShader(
|
|
||||||
// See FXAA Quality FxaaPixelShader() source for docs on Inputs!
|
|
||||||
//
|
|
||||||
// Use noperspective interpolation here (turn off perspective interpolation).
|
|
||||||
// {xy} = center of pixel
|
|
||||||
FxaaFloat2 pos,
|
|
||||||
//
|
|
||||||
// Used only for FXAA Console, and not used on the 360 version.
|
|
||||||
// Use noperspective interpolation here (turn off perspective interpolation).
|
|
||||||
// {xy__} = upper left of pixel
|
|
||||||
// {__zw} = lower right of pixel
|
|
||||||
FxaaFloat4 fxaaConsolePosPos,
|
|
||||||
//
|
|
||||||
// Input color texture.
|
|
||||||
// {rgb_} = color in linear or perceptual color space
|
|
||||||
// if (FXAA_GREEN_AS_LUMA == 0)
|
|
||||||
// {___a} = luma in perceptual color space (not linear)
|
|
||||||
FxaaTex tex,
|
|
||||||
//
|
|
||||||
// Only used on FXAA Console.
|
|
||||||
// This must be from a constant/uniform.
|
|
||||||
// This effects sub-pixel AA quality and inversely sharpness.
|
|
||||||
// Where N ranges between,
|
|
||||||
// N = 0.50 (default)
|
|
||||||
// N = 0.33 (sharper)
|
|
||||||
// {x___} = -N/screenWidthInPixels
|
|
||||||
// {_y__} = -N/screenHeightInPixels
|
|
||||||
// {__z_} = N/screenWidthInPixels
|
|
||||||
// {___w} = N/screenHeightInPixels
|
|
||||||
FxaaFloat4 fxaaConsoleRcpFrameOpt,
|
|
||||||
//
|
|
||||||
// Only used on FXAA Console.
|
|
||||||
// Not used on 360, but used on PS3 and PC.
|
|
||||||
// This must be from a constant/uniform.
|
|
||||||
// {x___} = -2.0/screenWidthInPixels
|
|
||||||
// {_y__} = -2.0/screenHeightInPixels
|
|
||||||
// {__z_} = 2.0/screenWidthInPixels
|
|
||||||
// {___w} = 2.0/screenHeightInPixels
|
|
||||||
FxaaFloat4 fxaaConsoleRcpFrameOpt2,
|
|
||||||
//
|
|
||||||
// Only used on FXAA Console.
|
|
||||||
// This used to be the FXAA_CONSOLE__EDGE_SHARPNESS define.
|
|
||||||
// It is here now to allow easier tuning.
|
|
||||||
// This does not effect PS3, as this needs to be compiled in.
|
|
||||||
// Use FXAA_CONSOLE__PS3_EDGE_SHARPNESS for PS3.
|
|
||||||
// Due to the PS3 being ALU bound,
|
|
||||||
// there are only three safe values here: 2 and 4 and 8.
|
|
||||||
// These options use the shaders ability to a free *|/ by 2|4|8.
|
|
||||||
// For all other platforms can be a non-power of two.
|
|
||||||
// 8.0 is sharper (default!!!)
|
|
||||||
// 4.0 is softer
|
|
||||||
// 2.0 is really soft (good only for vector graphics inputs)
|
|
||||||
FxaaFloat fxaaConsoleEdgeSharpness,
|
|
||||||
//
|
|
||||||
// Only used on FXAA Console.
|
|
||||||
// This used to be the FXAA_CONSOLE__EDGE_THRESHOLD define.
|
|
||||||
// It is here now to allow easier tuning.
|
|
||||||
// This does not effect PS3, as this needs to be compiled in.
|
|
||||||
// Use FXAA_CONSOLE__PS3_EDGE_THRESHOLD for PS3.
|
|
||||||
// Due to the PS3 being ALU bound,
|
|
||||||
// there are only two safe values here: 1/4 and 1/8.
|
|
||||||
// These options use the shaders ability to a free *|/ by 2|4|8.
|
|
||||||
// The console setting has a different mapping than the quality setting.
|
|
||||||
// Other platforms can use other values.
|
|
||||||
// 0.125 leaves less aliasing, but is softer (default!!!)
|
|
||||||
// 0.25 leaves more aliasing, and is sharper
|
|
||||||
FxaaFloat fxaaConsoleEdgeThreshold,
|
|
||||||
//
|
|
||||||
// Only used on FXAA Console.
|
|
||||||
// This used to be the FXAA_CONSOLE__EDGE_THRESHOLD_MIN define.
|
|
||||||
// It is here now to allow easier tuning.
|
|
||||||
// Trims the algorithm from processing darks.
|
|
||||||
// The console setting has a different mapping than the quality setting.
|
|
||||||
// This does not apply to PS3,
|
|
||||||
// PS3 was simplified to avoid more shader instructions.
|
|
||||||
// 0.06 - faster but more aliasing in darks
|
|
||||||
// 0.05 - default
|
|
||||||
// 0.04 - slower and less aliasing in darks
|
|
||||||
// Special notes when using FXAA_GREEN_AS_LUMA,
|
|
||||||
// Likely want to set this to zero.
|
|
||||||
// As colors that are mostly not-green
|
|
||||||
// will appear very dark in the green channel!
|
|
||||||
// Tune by looking at mostly non-green content,
|
|
||||||
// then start at zero and increase until aliasing is a problem.
|
|
||||||
FxaaFloat fxaaConsoleEdgeThresholdMin
|
|
||||||
) {
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaNw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xy));
|
|
||||||
FxaaFloat lumaSw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xw));
|
|
||||||
FxaaFloat lumaNe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zy));
|
|
||||||
FxaaFloat lumaSe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zw));
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat4 rgbyM = FxaaTexTop(tex, pos.xy);
|
|
||||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
|
||||||
// TODO Luma
|
|
||||||
FxaaFloat lumaM = FxaaLuma(rgbyM);
|
|
||||||
#else
|
|
||||||
FxaaFloat lumaM = rgbyM.y;
|
|
||||||
#endif
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaMaxNwSw = max(lumaNw, lumaSw);
|
|
||||||
lumaNe += 1.0/384.0;
|
|
||||||
FxaaFloat lumaMinNwSw = min(lumaNw, lumaSw);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaMaxNeSe = max(lumaNe, lumaSe);
|
|
||||||
FxaaFloat lumaMinNeSe = min(lumaNe, lumaSe);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaMax = max(lumaMaxNeSe, lumaMaxNwSw);
|
|
||||||
FxaaFloat lumaMin = min(lumaMinNeSe, lumaMinNwSw);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaMaxScaled = lumaMax * fxaaConsoleEdgeThreshold;
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat lumaMinM = min(lumaMin, lumaM);
|
|
||||||
FxaaFloat lumaMaxScaledClamped = max(fxaaConsoleEdgeThresholdMin, lumaMaxScaled);
|
|
||||||
FxaaFloat lumaMaxM = max(lumaMax, lumaM);
|
|
||||||
FxaaFloat dirSwMinusNe = lumaSw - lumaNe;
|
|
||||||
FxaaFloat lumaMaxSubMinM = lumaMaxM - lumaMinM;
|
|
||||||
FxaaFloat dirSeMinusNw = lumaSe - lumaNw;
|
|
||||||
if(lumaMaxSubMinM < lumaMaxScaledClamped)
|
|
||||||
{
|
|
||||||
#if (FXAA_DISCARD == 1)
|
|
||||||
FxaaDiscard;
|
|
||||||
#else
|
|
||||||
return rgbyM;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat2 dir;
|
|
||||||
dir.x = dirSwMinusNe + dirSeMinusNw;
|
|
||||||
dir.y = dirSwMinusNe - dirSeMinusNw;
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat2 dir1 = normalize(dir.xy);
|
|
||||||
FxaaFloat4 rgbyN1 = FxaaTexTop(tex, pos.xy - dir1 * fxaaConsoleRcpFrameOpt.zw);
|
|
||||||
FxaaFloat4 rgbyP1 = FxaaTexTop(tex, pos.xy + dir1 * fxaaConsoleRcpFrameOpt.zw);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * fxaaConsoleEdgeSharpness;
|
|
||||||
FxaaFloat2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat2 dir2x = dir2 * fxaaConsoleRcpFrameOpt2.zw;
|
|
||||||
FxaaFloat4 rgbyN2 = FxaaTexTop(tex, pos.xy - dir2x);
|
|
||||||
FxaaFloat4 rgbyP2 = FxaaTexTop(tex, pos.xy + dir2x);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
FxaaFloat4 rgbyA = rgbyN1 + rgbyP1;
|
|
||||||
FxaaFloat4 rgbyB = ((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25);
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
|
||||||
// TODO Luma
|
|
||||||
float lumaB = FxaaLuma(rgbyB);
|
|
||||||
#else
|
|
||||||
float lumaB = rgbyB.y;
|
|
||||||
#endif
|
|
||||||
if((lumaB < lumaMin) || (lumaB > lumaMax))
|
|
||||||
rgbyB.xyz = rgbyA.xyz * 0.5;
|
|
||||||
//
|
|
||||||
return rgbyB;
|
|
||||||
}
|
|
||||||
/*==========================================================================*/
|
|
||||||
|
|
||||||
uniform sampler2D f_color;
|
|
||||||
|
|
||||||
uniform vec2 screenSize;
|
|
||||||
|
|
||||||
#define edgeSharpness 7.0
|
|
||||||
#define edgeThreshold 0.1
|
|
||||||
#define edgeThresholdMin 0.005
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
vec4 posPos;
|
|
||||||
posPos.xy = pos - (0.6 / screenSize);
|
|
||||||
posPos.zw = pos + (0.6 / screenSize);
|
|
||||||
vec4 rcpFrameOpt;
|
|
||||||
rcpFrameOpt.xy = vec2(-0.50, -0.50) / screenSize;
|
|
||||||
rcpFrameOpt.zw = vec2( 0.50, 0.50) / screenSize;
|
|
||||||
vec4 rcpFrameOpt2;
|
|
||||||
rcpFrameOpt2.xy = vec2(-2.0, -2.0) / screenSize;
|
|
||||||
rcpFrameOpt2.zw = vec2( 2.0, 2.0) / screenSize;
|
|
||||||
|
|
||||||
fragColor = vec4(FxaaPixelShader(pos, posPos, f_color, rcpFrameOpt, rcpFrameOpt2, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0);
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
#line 2
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
precision highp sampler2D;
|
|
||||||
precision highp float;
|
|
||||||
|
|
||||||
#ifdef CC_VERT
|
|
||||||
uniform mat4 matrix_m;
|
|
||||||
uniform mat4 matrix_p;
|
|
||||||
|
|
||||||
in vec3 a_vert;
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
gl_Position = (matrix_p * (matrix_m * vec4(a_vert, 1.0)));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CC_FRAG
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
fragColor = vec4(1.0);
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,13 +0,0 @@
|
||||||
#line 0
|
|
||||||
|
|
||||||
precision lowp int;
|
|
||||||
precision lowp sampler2D;
|
|
||||||
precision lowp float;
|
|
||||||
|
|
||||||
in vec2 a_pos;
|
|
||||||
|
|
||||||
out vec2 pos;
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
gl_Position = vec4((pos = a_pos) * 2.0 - 1.0, 0.0, 1.0);
|
|
||||||
}
|
|
376
src/lwjgl/java/net/PeytonPlayz585/fileutils/File.java
Normal file
376
src/lwjgl/java/net/PeytonPlayz585/fileutils/File.java
Normal file
|
@ -0,0 +1,376 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class File {
|
||||||
|
|
||||||
|
private static final java.io.File filesystemBaseDirectory = new java.io.File("filesystem");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filesystemBaseDirectory.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
private transient int prefixLength;
|
||||||
|
private final char slash = '/';
|
||||||
|
private static final String pathSeperator = "/";
|
||||||
|
private static final String[] altPathSeperator = new String[] { "\\" };
|
||||||
|
|
||||||
|
public File(String pathName) {
|
||||||
|
if (pathName == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
this.path = this.normalize(pathName);
|
||||||
|
this.prefixLength = this.prefixLength(this.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File(String parent, String child) {
|
||||||
|
if (child == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parent != null) {
|
||||||
|
this.path = this.createPath(parent, child);
|
||||||
|
} else {
|
||||||
|
this.path = this.normalize(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public File(File parent, String child) {
|
||||||
|
if (child == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
if(parent != null) {
|
||||||
|
this.path = this.createPath(parent.path, child);
|
||||||
|
} else {
|
||||||
|
this.path = this.normalize(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int prefixLength(String path) {
|
||||||
|
char slash = this.slash;
|
||||||
|
int n = path.length();
|
||||||
|
if (n == 0) return 0;
|
||||||
|
char c0 = path.charAt(0);
|
||||||
|
char c1 = (n > 1) ? path.charAt(1) : 0;
|
||||||
|
if (c0 == slash) {
|
||||||
|
if (c1 == slash) return 2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (isLetter(c0) && (c1 == ':')) {
|
||||||
|
if ((n > 2) && (path.charAt(2) == slash))
|
||||||
|
return 3;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLetter(char c) {
|
||||||
|
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalize(String p) {
|
||||||
|
for(int i = 0; i < altPathSeperator.length; ++i) {
|
||||||
|
p = p.replace(altPathSeperator[i], pathSeperator);
|
||||||
|
}
|
||||||
|
if(p.startsWith(pathSeperator)) {
|
||||||
|
p = p.substring(1);
|
||||||
|
}
|
||||||
|
if(p.endsWith(pathSeperator)) {
|
||||||
|
p = p.substring(0, p.length() - pathSeperator.length());
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] splitPath(String p) {
|
||||||
|
String[] pth = normalize(p).split(pathSeperator);
|
||||||
|
for(int i = 0; i < pth.length; ++i) {
|
||||||
|
pth[i] = pth[i].trim();
|
||||||
|
}
|
||||||
|
return pth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createPath(Object... p) {
|
||||||
|
ArrayList<String> r = new ArrayList();
|
||||||
|
for(int i = 0; i < p.length; ++i) {
|
||||||
|
if(p[i] == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String gg = p[i].toString();
|
||||||
|
if(gg == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] parts = splitPath(gg);
|
||||||
|
for(int j = 0; j < parts.length; ++j) {
|
||||||
|
if(parts[j] == null || parts[j].equals(".")) {
|
||||||
|
continue;
|
||||||
|
}else if(parts[j].equals("..") && r.size() > 0) {
|
||||||
|
int k = r.size() - 1;
|
||||||
|
if(!r.get(k).equals("..")) {
|
||||||
|
r.remove(k);
|
||||||
|
}else {
|
||||||
|
r.add("..");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
r.add(parts[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(r.size() > 0) {
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
for(int i = 0; i < r.size(); ++i) {
|
||||||
|
if(i > 0) {
|
||||||
|
s.append(pathSeperator);
|
||||||
|
}
|
||||||
|
s.append(r.get(i));
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======== Virtual Filesystem Functions =============
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
int index = path.lastIndexOf(slash);
|
||||||
|
if (index < prefixLength) return path.substring(prefixLength);
|
||||||
|
return path.substring(index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exists() {
|
||||||
|
return exists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDirectory() {
|
||||||
|
return exists(path) && directoryExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renameTo(File newPath) {
|
||||||
|
renameFile(path, newPath.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] read() {
|
||||||
|
return readFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] data) {
|
||||||
|
writeFile(path, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
deleteFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mkdir() {
|
||||||
|
(new java.io.File(filesystemBaseDirectory, stripPath(path))).mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
public File[] listFiles() {
|
||||||
|
Collection<FileEntry> collection = listFiles(path, false, false);
|
||||||
|
int size = collection.size();
|
||||||
|
FileEntry[] entries = collection.toArray(new FileEntry[size]);
|
||||||
|
File[] files = new File[size];
|
||||||
|
|
||||||
|
for(int i = 0; i < size; i++) {
|
||||||
|
files[i] = new File(entries[i].path);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean exists(String path) {
|
||||||
|
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean fileExists(String path) {
|
||||||
|
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean directoryExists(String path) {
|
||||||
|
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean pathExists(String path) {
|
||||||
|
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void writeFile(String path, byte[] data) {
|
||||||
|
try {
|
||||||
|
java.io.File f = new java.io.File(filesystemBaseDirectory, stripPath(path));
|
||||||
|
java.io.File p = f.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
FileOutputStream os = new FileOutputStream(f);
|
||||||
|
os.write(data);
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final byte[] readFile(String path) {
|
||||||
|
java.io.File f = new java.io.File(filesystemBaseDirectory, stripPath(path));
|
||||||
|
if(!f.isFile()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
byte[] ret = new byte[(int)f.length()];
|
||||||
|
FileInputStream in = new FileInputStream(f);
|
||||||
|
in.read(ret);
|
||||||
|
in.close();
|
||||||
|
return ret;
|
||||||
|
}catch(IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final long getLastModified(String path) {
|
||||||
|
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int getFileSize(String path) {
|
||||||
|
return (int)(new java.io.File(filesystemBaseDirectory, stripPath(path))).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void renameFile(String oldPath, String newPath) {
|
||||||
|
java.io.File f1 = new java.io.File(filesystemBaseDirectory, stripPath(oldPath));
|
||||||
|
java.io.File f2 = new java.io.File(filesystemBaseDirectory, stripPath(newPath));
|
||||||
|
if(f1.exists()) {
|
||||||
|
if(f2.exists()) {
|
||||||
|
try {
|
||||||
|
FileInputStream fs1 = new FileInputStream(f1);
|
||||||
|
FileOutputStream fs2 = new FileOutputStream(f2);
|
||||||
|
byte[] buffer = new byte[1024 * 64];
|
||||||
|
int a;
|
||||||
|
while((a = fs1.read(buffer)) > 0) {
|
||||||
|
fs2.write(buffer, 0, a);
|
||||||
|
}
|
||||||
|
fs1.close();
|
||||||
|
fs2.close();
|
||||||
|
f1.delete();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Copy from '" + oldPath + "' to '" + newPath + "' failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
java.io.File p = f2.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
f1.renameTo(f2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void copyFile(String oldPath, String newPath) {
|
||||||
|
try {
|
||||||
|
java.io.File ff2 = new java.io.File(filesystemBaseDirectory, stripPath(newPath));
|
||||||
|
java.io.File p = ff2.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
FileInputStream f1 = new FileInputStream(new java.io.File(filesystemBaseDirectory, stripPath(oldPath)));
|
||||||
|
FileOutputStream f2 = new FileOutputStream(ff2);
|
||||||
|
byte[] buffer = new byte[1024 * 64];
|
||||||
|
int a;
|
||||||
|
while((a = f1.read(buffer)) > 0) {
|
||||||
|
f2.write(buffer, 0, a);
|
||||||
|
}
|
||||||
|
f1.close();
|
||||||
|
f2.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Copy from '" + oldPath + "' to '" + newPath + "' failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void deleteFile(String path) {
|
||||||
|
(new java.io.File(filesystemBaseDirectory, stripPath(path))).delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
|
||||||
|
path = stripPath(path);
|
||||||
|
ArrayList<FileEntry> ret = new ArrayList<>();
|
||||||
|
java.io.File f = new java.io.File(filesystemBaseDirectory, path);
|
||||||
|
if(f.isFile()) {
|
||||||
|
ret.add(new FileEntry(path, false, f.lastModified()));
|
||||||
|
}else if(f.isDirectory()) {
|
||||||
|
for(java.io.File ff : f.listFiles()) {
|
||||||
|
if(ff.isDirectory()) {
|
||||||
|
if(listDirs && !recursiveDirs) {
|
||||||
|
ret.add(new FileEntry(path + "/" + ff.getName(), true, -1l));
|
||||||
|
}
|
||||||
|
if(recursiveDirs) {
|
||||||
|
recursiveListing(path + "/" + ff.getName(), ff, ret, listDirs, recursiveDirs);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ret.add(new FileEntry(path + "/" + ff.getName(), false, ff.lastModified()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void recursiveListing(String path, java.io.File f, Collection<FileEntry> lst, boolean listDirs, boolean recursiveDirs) {
|
||||||
|
if(f.isFile()) {
|
||||||
|
lst.add(new FileEntry(path, false, f.lastModified()));
|
||||||
|
}else if(f.isDirectory()) {
|
||||||
|
if(listDirs) {
|
||||||
|
lst.add(new FileEntry(path, true, -1l));
|
||||||
|
}
|
||||||
|
if(recursiveDirs) {
|
||||||
|
for(java.io.File ff : f.listFiles()) {
|
||||||
|
recursiveListing(path + "/" + ff.getName(), ff, lst, listDirs, recursiveDirs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesAndDirectories(String path) {
|
||||||
|
return listFiles(path, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesRecursive(String path) {
|
||||||
|
return listFiles(path, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final FileEntry[] listFiles(String path) {
|
||||||
|
Collection<FileEntry> entries = listFilesAndDirectories(path);
|
||||||
|
FileEntry[] entryArray = new FileEntry[entries.size()];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(FileEntry entry : entries) {
|
||||||
|
entryArray[i] = entry;
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
return entryArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String stripPath(String str) {
|
||||||
|
if(str.startsWith("/")) {
|
||||||
|
str = str.substring(1);
|
||||||
|
}
|
||||||
|
if(str.endsWith("/")) {
|
||||||
|
str = str.substring(0, str.length() - 1);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCompressed(byte[] b) {
|
||||||
|
if(b == null || b.length < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (b[0] == (byte) 0x1F) && (b[1] == (byte) 0x8B);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
public class FileChooserResult {
|
||||||
|
|
||||||
|
public final String fileName;
|
||||||
|
public final byte[] fileData;
|
||||||
|
|
||||||
|
public FileChooserResult(String fileName, byte[] fileData) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.fileData = fileData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/lwjgl/java/net/PeytonPlayz585/fileutils/FileEntry.java
Normal file
36
src/lwjgl/java/net/PeytonPlayz585/fileutils/FileEntry.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
public class FileEntry {
|
||||||
|
|
||||||
|
public final String path;
|
||||||
|
public final boolean isDirectory;
|
||||||
|
public final long lastModified;
|
||||||
|
|
||||||
|
public FileEntry(String path, boolean isDirectory, long lastModified) {
|
||||||
|
this.path = path;
|
||||||
|
this.isDirectory = isDirectory;
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
int i = path.indexOf('/');
|
||||||
|
if(i >= 0) {
|
||||||
|
return path.substring(i + 1);
|
||||||
|
}else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFile() {
|
||||||
|
return !isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long length() {
|
||||||
|
return File.getFileSize(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long lastModified() {
|
||||||
|
return File.getLastModified(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class FilesystemUtils {
|
||||||
|
|
||||||
|
public static void recursiveDeleteDirectory(String dir) {
|
||||||
|
Collection<FileEntry> lst = File.listFiles(dir, true, true);
|
||||||
|
for(FileEntry t : lst) {
|
||||||
|
if(!t.isDirectory) {
|
||||||
|
File.deleteFile(t.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(FileEntry t : lst) {
|
||||||
|
if(t.isDirectory) {
|
||||||
|
File.deleteFile(t.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Why THE FUCK was this even here in the first place
|
||||||
|
//File.deleteFile(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
src/lwjgl/java/net/PeytonPlayz585/opengl/GL11.java
Normal file
9
src/lwjgl/java/net/PeytonPlayz585/opengl/GL11.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package net.PeytonPlayz585.opengl;
|
||||||
|
|
||||||
|
public class GL11 extends GL11_1 {
|
||||||
|
|
||||||
|
public static class EaglerAdapterImpl2 extends GL11_1.EaglerAdapterImpl2 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7572
src/lwjgl/java/net/PeytonPlayz585/opengl/GL11_1.java
Normal file
7572
src/lwjgl/java/net/PeytonPlayz585/opengl/GL11_1.java
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,7 @@ public class SoundManager {
|
||||||
|
|
||||||
file = "sounds/" + file;
|
file = "sounds/" + file;
|
||||||
if(flag) {
|
if(flag) {
|
||||||
int i1 = GL11.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!");
|
||||||
|
@ -54,37 +54,37 @@ public class SoundManager {
|
||||||
} else {
|
} else {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
int i1 = rand.nextInt(4 - 1 + 1) + 1;
|
int i1 = rand.nextInt(4 - 1 + 1) + 1;
|
||||||
int i2 = GL11.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.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.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.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.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.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.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.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.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!");
|
||||||
|
@ -99,7 +99,7 @@ public class SoundManager {
|
||||||
|
|
||||||
public void func_338_a(EntityPlayer player, float f) {
|
public void func_338_a(EntityPlayer player, float f) {
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
GL11.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
|
GL11.EaglerAdapterImpl2.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
|
||||||
} else {
|
} else {
|
||||||
double x = player.prevPosX + (player.posX - player.prevPosX) * f;
|
double x = player.prevPosX + (player.posX - player.prevPosX) * f;
|
||||||
double y = player.prevPosY + (player.posY - player.prevPosY) * f;
|
double y = player.prevPosY + (player.posY - player.prevPosY) * f;
|
||||||
|
@ -108,7 +108,7 @@ public class SoundManager {
|
||||||
double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GL11.setListenerPos((float)x, (float)y, (float)z, (float)player.motionX, (float)player.motionY, (float)player.motionZ, (float)pitch, (float)yaw);
|
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) {
|
} catch(Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class SoundManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
volume *= 0.25F;
|
volume *= 0.25F;
|
||||||
int i = GL11.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
|
int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
|
||||||
if(i == - 1) {
|
if(i == - 1) {
|
||||||
try {
|
try {
|
||||||
throw new FileNotFoundException("Audio file " + file + " not found!");
|
throw new FileNotFoundException("Audio file " + file + " not found!");
|
||||||
|
@ -155,8 +155,8 @@ public class SoundManager {
|
||||||
|
|
||||||
public void musicTick() throws FileNotFoundException {
|
public void musicTick() throws FileNotFoundException {
|
||||||
if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) {
|
if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) {
|
||||||
if(GL11.isPlaying(song)) {
|
if(GL11.EaglerAdapterImpl2.isPlaying(song)) {
|
||||||
GL11.endSound(song);
|
GL11.EaglerAdapterImpl2.endSound(song);
|
||||||
}
|
}
|
||||||
musicFlag = true;
|
musicFlag = true;
|
||||||
musicTimer = 0;
|
musicTimer = 0;
|
||||||
|
@ -165,7 +165,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && musicFlag && !musicTimerSet) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && !musicTimerSet) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
musicTimer = rand.nextInt(6 - 3 + 1) + 3;
|
musicTimer = rand.nextInt(6 - 3 + 1) + 3;
|
||||||
musicTimer = musicTimer * 60;
|
musicTimer = musicTimer * 60;
|
||||||
|
@ -176,7 +176,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && musicFlag && musicTimerSet) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && musicTimerSet) {
|
||||||
if(Minecraft.getMinecraft().ticksRan >= ticks) {
|
if(Minecraft.getMinecraft().ticksRan >= ticks) {
|
||||||
musicFlag = false;
|
musicFlag = false;
|
||||||
musicTimer = 0;
|
musicTimer = 0;
|
||||||
|
@ -186,7 +186,7 @@ public class SoundManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && !musicFlag) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && !musicFlag) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
int i = rand.nextInt(2);
|
int i = rand.nextInt(2);
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prevSong = songToPlay;
|
prevSong = songToPlay;
|
||||||
song = GL11.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
||||||
if(song == -1) {
|
if(song == -1) {
|
||||||
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prevSong = songToPlay;
|
prevSong = songToPlay;
|
||||||
song = GL11.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
||||||
if(song == -1) {
|
if(song == -1) {
|
||||||
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class Client {
|
||||||
//JOptionPane.showMessageDialog(null, "Press ok to continue", "Alpha v1.2.6",
|
//JOptionPane.showMessageDialog(null, "Press ok to continue", "Alpha v1.2.6",
|
||||||
//JOptionPane.PLAIN_MESSAGE);
|
//JOptionPane.PLAIN_MESSAGE);
|
||||||
|
|
||||||
GL11.initializeContext();
|
GL11.EaglerAdapterImpl2.initializeContext();
|
||||||
|
|
||||||
Minecraft mc = new Minecraft();
|
Minecraft mc = new Minecraft();
|
||||||
mc.field_6320_i = new Session("Player");
|
mc.field_6320_i = new Session("Player");
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -81,77 +81,68 @@ public class Tessellator {
|
||||||
private int normal;
|
private int normal;
|
||||||
|
|
||||||
/** The static instance of the Tessellator. */
|
/** The static instance of the Tessellator. */
|
||||||
public static final Tessellator instance = new Tessellator(525000);
|
public static final Tessellator instance = new Tessellator(2097152);
|
||||||
|
|
||||||
/** Whether this tessellator is currently in draw mode. */
|
/** Whether this tessellator is currently in draw mode. */
|
||||||
private boolean isDrawing = false;
|
private boolean isDrawing = false;
|
||||||
|
|
||||||
/** Whether we are currently using VBO or not. */
|
|
||||||
private boolean useVBO = false;
|
|
||||||
|
|
||||||
/** The size of the buffers used (in integers). */
|
|
||||||
private int bufferSize;
|
private int bufferSize;
|
||||||
|
|
||||||
|
|
||||||
private Tessellator(int par1) {
|
private Tessellator(int par1) {
|
||||||
this.bufferSize = par1;
|
this.bufferSize = par1;
|
||||||
this.byteBuffer = ByteBuffer.allocateDirect(par1 * 4).order(ByteOrder.nativeOrder());
|
this.byteBuffer = GLAllocation.createDirectByteBuffer(par1 * 4);
|
||||||
this.intBuffer = this.byteBuffer.asIntBuffer();
|
this.intBuffer = this.byteBuffer.asIntBuffer();
|
||||||
this.rawBuffer = new int[par1];
|
this.rawBuffer = new int[par1];
|
||||||
this.useVBO = false;// tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
|
|
||||||
|
|
||||||
// if (this.useVBO) {
|
|
||||||
// this.vertexBuffers = GLAllocation.createDirectIntBuffer(this.vboCount);
|
|
||||||
// ARBVertexBufferObject.glGenBuffersARB(this.vertexBuffers);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the data set up in this tessellator and resets the state to prepare for
|
* Draws the data set up in this tessellator and resets the state to prepare for
|
||||||
* new drawing.
|
* new drawing.
|
||||||
*/
|
*/
|
||||||
public int draw() {
|
public void draw() {
|
||||||
if (!this.isDrawing) {
|
if (!this.isDrawing) {
|
||||||
return 0;
|
throw new IllegalStateException("Not tesselating!");
|
||||||
} else {
|
} else {
|
||||||
this.isDrawing = false;
|
this.isDrawing = false;
|
||||||
|
|
||||||
if (this.vertexCount > 0) {
|
if (this.vertexCount > 0) {
|
||||||
IntBuffer up = null;
|
IntBuffer upload = null;
|
||||||
this.intBuffer.clear();
|
this.intBuffer.clear();
|
||||||
this.intBuffer.put(rawBuffer, 0, this.rawBufferIndex);
|
this.intBuffer.put(rawBuffer, 0, this.rawBufferIndex);
|
||||||
this.intBuffer.flip();
|
this.intBuffer.flip();
|
||||||
up = this.intBuffer;
|
upload = this.intBuffer;
|
||||||
|
|
||||||
if (this.hasTexture) {
|
if(this.hasTexture) {
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasColor) {
|
if(this.hasColor) {
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasNormals) {
|
if(this.hasNormals) {
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glDrawArrays(this.drawMode, 0, this.vertexCount, up);
|
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||||
|
GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, upload);
|
||||||
|
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
if (this.hasTexture) {
|
if(this.hasTexture) {
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasColor) {
|
if(this.hasColor) {
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasNormals) {
|
if(this.hasNormals) {
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int var1 = this.rawBufferIndex * 4;
|
|
||||||
this.reset();
|
this.reset();
|
||||||
return var1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +159,7 @@ public class Tessellator {
|
||||||
* Sets draw mode in the tessellator to draw quads.
|
* Sets draw mode in the tessellator to draw quads.
|
||||||
*/
|
*/
|
||||||
public void startDrawingQuads() {
|
public void startDrawingQuads() {
|
||||||
this.startDrawing(GL11.GL_QUADS);
|
this.startDrawing(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,15 +168,16 @@ public class Tessellator {
|
||||||
*/
|
*/
|
||||||
public void startDrawing(int par1) {
|
public void startDrawing(int par1) {
|
||||||
if (this.isDrawing) {
|
if (this.isDrawing) {
|
||||||
this.draw();
|
throw new IllegalStateException("Already tesselating!");
|
||||||
|
} else {
|
||||||
|
this.isDrawing = true;
|
||||||
|
this.reset();
|
||||||
|
this.drawMode = par1;
|
||||||
|
this.hasNormals = false;
|
||||||
|
this.hasColor = false;
|
||||||
|
this.hasTexture = false;
|
||||||
|
this.isColorDisabled = false;
|
||||||
}
|
}
|
||||||
this.isDrawing = true;
|
|
||||||
this.reset();
|
|
||||||
this.drawMode = par1;
|
|
||||||
this.hasNormals = false;
|
|
||||||
this.hasColor = false;
|
|
||||||
this.hasTexture = false;
|
|
||||||
this.isColorDisabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,81 +185,68 @@ public class Tessellator {
|
||||||
*/
|
*/
|
||||||
public void setTextureUV(double par1, double par3) {
|
public void setTextureUV(double par1, double par3) {
|
||||||
this.hasTexture = true;
|
this.hasTexture = true;
|
||||||
this.textureU = par1;
|
this.textureU = (float) par1;
|
||||||
this.textureV = par3;
|
this.textureV = (float) par3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque_F(float var1, float var2, float var3) {
|
||||||
* Sets the RGB values as specified, converting from floats between 0 and 1 to
|
this.setColorOpaque((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F));
|
||||||
* integers from 0-255.
|
|
||||||
*/
|
|
||||||
public void setColorOpaque_F(float par1, float par2, float par3) {
|
|
||||||
this.setColorOpaque((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA_F(float var1, float var2, float var3, float var4) {
|
||||||
* Sets the RGBA values for the color, converting from floats between 0 and 1 to
|
this.setColorRGBA((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F), (int)(var4 * 255.0F));
|
||||||
* integers from 0-255.
|
|
||||||
*/
|
|
||||||
public void setColorRGBA_F(float par1, float par2, float par3, float par4) {
|
|
||||||
this.setColorRGBA((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F), (int) (par4 * 255.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque(int var1, int var2, int var3) {
|
||||||
* Sets the RGB values as specified, and sets alpha to opaque.
|
this.setColorRGBA(var1, var2, var3, 255);
|
||||||
*/
|
|
||||||
public void setColorOpaque(int par1, int par2, int par3) {
|
|
||||||
this.setColorRGBA(par1, par2, par3, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA(int var1, int var2, int var3, int var4) {
|
||||||
* Sets the RGBA values for the color. Also clamps them to 0-255.
|
if(!this.isColorDisabled) {
|
||||||
*/
|
if(var1 > 255) {
|
||||||
public void setColorRGBA(int par1, int par2, int par3, int par4) {
|
var1 = 255;
|
||||||
if (!this.isColorDisabled) {
|
|
||||||
if (par1 > 255) {
|
|
||||||
par1 = 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par2 > 255) {
|
if(var2 > 255) {
|
||||||
par2 = 255;
|
var2 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par3 > 255) {
|
if(var3 > 255) {
|
||||||
par3 = 255;
|
var3 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par4 > 255) {
|
if(var4 > 255) {
|
||||||
par4 = 255;
|
var4 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par1 < 0) {
|
if(var1 < 0) {
|
||||||
par1 = 0;
|
var1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par2 < 0) {
|
if(var2 < 0) {
|
||||||
par2 = 0;
|
var2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par3 < 0) {
|
if(var3 < 0) {
|
||||||
par3 = 0;
|
var3 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par4 < 0) {
|
if(var4 < 0) {
|
||||||
par4 = 0;
|
var4 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasColor = true;
|
this.hasColor = true;
|
||||||
this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1;
|
if(ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
|
||||||
|
this.color = var4 << 24 | var3 << 16 | var2 << 8 | var1;
|
||||||
|
} else {
|
||||||
|
this.color = var1 << 24 | var2 << 16 | var3 << 8 | var4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void addVertexWithUV(double var1, double var3, double var5, double var7, double var9) {
|
||||||
* Adds a vertex specifying both x,y,z and the texture u,v for it.
|
this.setTextureUV(var7, var9);
|
||||||
*/
|
this.addVertex(var1, var3, var5);
|
||||||
public void addVertexWithUV(double par1, double par3, double par5, double par7, double par9) {
|
|
||||||
this.setTextureUV(par7, par9);
|
|
||||||
this.addVertex(par1, par3, par5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,8 +254,7 @@ public class Tessellator {
|
||||||
* trigger a draw() if the buffer gets full.
|
* trigger a draw() if the buffer gets full.
|
||||||
*/
|
*/
|
||||||
public void addVertex(double par1, double par3, double par5) {
|
public void addVertex(double par1, double par3, double par5) {
|
||||||
if (this.addedVertices > 65534)
|
if(this.addedVertices > 65534) return;
|
||||||
return;
|
|
||||||
++this.addedVertices;
|
++this.addedVertices;
|
||||||
|
|
||||||
this.rawBuffer[this.rawBufferIndex + 0] = Float.floatToRawIntBits((float) (par1 + this.xOffset));
|
this.rawBuffer[this.rawBufferIndex + 0] = Float.floatToRawIntBits((float) (par1 + this.xOffset));
|
||||||
|
@ -296,30 +274,26 @@ public class Tessellator {
|
||||||
this.rawBuffer[this.rawBufferIndex + 6] = this.normal;
|
this.rawBuffer[this.rawBufferIndex + 6] = this.normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rawBufferIndex += 7;
|
this.rawBufferIndex += 8;
|
||||||
++this.vertexCount;
|
++this.vertexCount;
|
||||||
|
if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32) {
|
||||||
|
this.draw();
|
||||||
|
this.isDrawing = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque_I(int var1) {
|
||||||
* Sets the color to the given opaque value (stored as byte values packed in an
|
int var2 = var1 >>> 16 & 255;
|
||||||
* integer).
|
int var3 = var1 >>> 8 & 255;
|
||||||
*/
|
int var4 = var1 & 255;
|
||||||
public void setColorOpaque_I(int par1) {
|
|
||||||
int var2 = par1 >> 16 & 255;
|
|
||||||
int var3 = par1 >> 8 & 255;
|
|
||||||
int var4 = par1 & 255;
|
|
||||||
this.setColorOpaque(var2, var3, var4);
|
this.setColorOpaque(var2, var3, var4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA_I(int var1, int var2) {
|
||||||
* Sets the color to the given color (packed as bytes in integer) and alpha
|
int var3 = var1 >>> 16 & 255;
|
||||||
* values.
|
int var4 = var1 >>> 8 & 255;
|
||||||
*/
|
int var5 = var1 & 255;
|
||||||
public void setColorRGBA_I(int par1, int par2) {
|
this.setColorRGBA(var3, var4, var5, var2);
|
||||||
int var3 = par1 >> 16 & 255;
|
|
||||||
int var4 = par1 >> 8 & 255;
|
|
||||||
int var5 = par1 & 255;
|
|
||||||
this.setColorRGBA(var3, var4, var5, par2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,11 +307,14 @@ public class Tessellator {
|
||||||
* Sets the normal for the current draw call.
|
* Sets the normal for the current draw call.
|
||||||
*/
|
*/
|
||||||
public void setNormal(float par1, float par2, float par3) {
|
public void setNormal(float par1, float par2, float par3) {
|
||||||
|
if(!this.isDrawing) {
|
||||||
|
System.out.println("But..");
|
||||||
|
}
|
||||||
|
|
||||||
this.hasNormals = true;
|
this.hasNormals = true;
|
||||||
//float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
|
int var4 = (int)((par1) * 127.0F) + 127;
|
||||||
int var4 = (int) ((par1) * 127.0F) + 127;
|
int var5 = (int)((par2) * 127.0F) + 127;
|
||||||
int var5 = (int) ((par2) * 127.0F) + 127;
|
int var6 = (int)((par3) * 127.0F) + 127;
|
||||||
int var6 = (int) ((par3) * 127.0F) + 127;
|
|
||||||
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
|
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
65
src/main/java/net/PeytonPlayz585/awt/Color.java
Normal file
65
src/main/java/net/PeytonPlayz585/awt/Color.java
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
package net.PeytonPlayz585.awt;
|
||||||
|
|
||||||
|
public class Color {
|
||||||
|
|
||||||
|
int value;
|
||||||
|
|
||||||
|
public Color(int rgb) {
|
||||||
|
value = 0xff000000 | rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Color getHSBColor(float h, float s, float b) {
|
||||||
|
return new Color(HSBtoRGB(h, s, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int HSBtoRGB(float hue, float saturation, float brightness) {
|
||||||
|
int r = 0, g = 0, b = 0;
|
||||||
|
if (saturation == 0) {
|
||||||
|
r = g = b = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
} else {
|
||||||
|
float h = (hue - (float) Math.floor(hue)) * 6.0f;
|
||||||
|
float f = h - (float) java.lang.Math.floor(h);
|
||||||
|
float p = brightness * (1.0f - saturation);
|
||||||
|
float q = brightness * (1.0f - saturation * f);
|
||||||
|
float t = brightness * (1.0f - (saturation * (1.0f - f)));
|
||||||
|
switch ((int) h) {
|
||||||
|
case 0:
|
||||||
|
r = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
g = (int)(t * 255.0f + 0.5f);
|
||||||
|
b = (int)(p * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
r = (int)(q * 255.0f + 0.5f);
|
||||||
|
g = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
b = (int)(p * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
r = (int)(p * 255.0f + 0.5f);
|
||||||
|
g = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
b = (int)(t * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
r = (int)(p * 255.0f + 0.5f);
|
||||||
|
g = (int)(q * 255.0f + 0.5f);
|
||||||
|
b = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
r = (int)(t * 255.0f + 0.5f);
|
||||||
|
g = (int)(p * 255.0f + 0.5f);
|
||||||
|
b = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
r = (int)(brightness * 255.0f + 0.5f);
|
||||||
|
g = (int)(p * 255.0f + 0.5f);
|
||||||
|
b = (int)(q * 255.0f + 0.5f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRGB() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package net.PeytonPlayz585.awt.image;
|
||||||
|
|
||||||
|
public class BufferedImage {
|
||||||
|
|
||||||
|
private final int[] pixels;
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final boolean isAlphaPremultiplied;
|
||||||
|
|
||||||
|
public BufferedImage(int[] pixels, int width, int height, boolean alpha) {
|
||||||
|
if(pixels.length != width*height) {
|
||||||
|
throw new IllegalArgumentException("array size does not equal image size");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.pixels = pixels;
|
||||||
|
this.isAlphaPremultiplied = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage(int width, int height, int[] pixels, boolean alpha) {
|
||||||
|
if(pixels.length != width*height) {
|
||||||
|
throw new IllegalArgumentException("array size does not equal image size");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.pixels = pixels;
|
||||||
|
this.isAlphaPremultiplied = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage(int width, int height, boolean alpha) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.pixels = new int[width * height];
|
||||||
|
this.isAlphaPremultiplied = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage(int w, int h, int k) {
|
||||||
|
this.width = w;
|
||||||
|
this.height = h;
|
||||||
|
this.isAlphaPremultiplied = true;
|
||||||
|
this.pixels = new int[w * h];
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getSubImage(int x, int y, int pw, int ph) {
|
||||||
|
int[] img = new int[pw * ph];
|
||||||
|
for(int i = 0; i < ph; ++i) {
|
||||||
|
System.arraycopy(pixels, (i + y) * this.width + x, img, i * pw, pw);
|
||||||
|
}
|
||||||
|
return new BufferedImage(pw, ph, img, isAlphaPremultiplied);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
System.arraycopy(pixels, offset + (y + startY) * scansize + startX, rgbArray, y * w, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
System.arraycopy(rgbArray, offset + (y + startY) * scansize + startX, pixels, y * w, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlphaPremultiplied() {
|
||||||
|
return isAlphaPremultiplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getData() {
|
||||||
|
return pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
}
|
30
src/main/java/net/PeytonPlayz585/awt/image/ImageIO.java
Normal file
30
src/main/java/net/PeytonPlayz585/awt/image/ImageIO.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package net.PeytonPlayz585.awt.image;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
|
public class ImageIO {
|
||||||
|
|
||||||
|
public static BufferedImage read(InputStream var1) throws IOException {
|
||||||
|
ByteArrayInputStream bais = (ByteArrayInputStream)var1;
|
||||||
|
byte[] data = bais.readAllBytes();
|
||||||
|
|
||||||
|
return GL11.EaglerAdapterImpl2.loadPNG(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedImage read(BufferedImage resource) throws IOException {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream getResourceAsStream(String var1) {
|
||||||
|
return GL11.EaglerAdapterImpl2.loadResource(var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedImage getResource(String string) {
|
||||||
|
return GL11.EaglerAdapterImpl2.loadPNG(GL11.EaglerAdapterImpl2.loadResourceBytes(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,20 +1,23 @@
|
||||||
package net.PeytonPlayz585.glemu;
|
package net.PeytonPlayz585.glemu;
|
||||||
|
|
||||||
import static net.PeytonPlayz585.opengl.GL11.*;
|
import static net.PeytonPlayz585.opengl.GL11.*;
|
||||||
|
import static net.PeytonPlayz585.opengl.GL11.EaglerAdapterImpl2.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.PeytonPlayz585.glemu.vector.*;
|
import net.PeytonPlayz585.glemu.vector.Vector2f;
|
||||||
|
import net.PeytonPlayz585.glemu.vector.Vector4f;
|
||||||
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class FixedFunctionShader {
|
public class FixedFunctionShader {
|
||||||
|
|
||||||
private static final FixedFunctionShader[] instances = new FixedFunctionShader[128];
|
private static final FixedFunctionShader[] instances = new FixedFunctionShader[4096]; //lol
|
||||||
private static final List<FixedFunctionShader> instanceList = new ArrayList();
|
private static final List<FixedFunctionShader> instanceList = new ArrayList();
|
||||||
|
|
||||||
public static void refreshCoreGL() {
|
public static void refreshCoreGL() {
|
||||||
for (int i = 0; i < instances.length; ++i) {
|
for(int i = 0; i < instances.length; ++i) {
|
||||||
if (instances[i] != null) {
|
if(instances[i] != null) {
|
||||||
_wglDeleteProgram(instances[i].globject);
|
_wglDeleteProgram(instances[i].globject);
|
||||||
instances[i] = null;
|
instances[i] = null;
|
||||||
}
|
}
|
||||||
|
@ -26,43 +29,69 @@ public class FixedFunctionShader {
|
||||||
public static final int COLOR = 1;
|
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 TEXTURE0 = 4;
|
||||||
public static final int LIGHTING = 8;
|
public static final int TEXTURE1 = 8;
|
||||||
public static final int FOG = 16;
|
public static final int TEXGEN = 16;
|
||||||
public static final int ALPHATEST = 32;
|
public static final int LIGHTING = 32;
|
||||||
public static final int UNIT0 = 64;
|
public static final int FOG = 64;
|
||||||
|
public static final int ALPHATEST = 128;
|
||||||
|
public static final int UNIT0 = 256;
|
||||||
|
public static final int UNIT1 = 512;
|
||||||
|
public static final int FIX_ANISOTROPIC = 1024;
|
||||||
|
public static final int SWAP_RB = 2048;
|
||||||
|
|
||||||
public static FixedFunctionShader instance(int i) {
|
public static FixedFunctionShader instance(int i) {
|
||||||
FixedFunctionShader s = instances[i];
|
FixedFunctionShader s = instances[i];
|
||||||
if (s == null) {
|
if(s == null) {
|
||||||
boolean CC_a_color = false;
|
boolean CC_a_color = false;
|
||||||
boolean CC_a_normal = false;
|
boolean CC_a_normal = false;
|
||||||
boolean CC_a_texture0 = false;
|
boolean CC_a_texture0 = false;
|
||||||
|
boolean CC_a_texture1 = false;
|
||||||
|
boolean CC_TEX_GEN_STRQ = false;
|
||||||
boolean CC_lighting = false;
|
boolean CC_lighting = false;
|
||||||
boolean CC_fog = false;
|
boolean CC_fog = false;
|
||||||
boolean CC_alphatest = false;
|
boolean CC_alphatest = false;
|
||||||
boolean CC_unit0 = false;
|
boolean CC_unit0 = false;
|
||||||
if ((i & COLOR) == COLOR) {
|
boolean CC_unit1 = false;
|
||||||
|
boolean CC_anisotropic = false;
|
||||||
|
boolean CC_swap_rb = false;
|
||||||
|
if((i & COLOR) == COLOR) {
|
||||||
CC_a_color = true;
|
CC_a_color = true;
|
||||||
}
|
}
|
||||||
if ((i & NORMAL) == NORMAL) {
|
if((i & NORMAL) == NORMAL) {
|
||||||
CC_a_normal = true;
|
CC_a_normal = true;
|
||||||
}
|
}
|
||||||
if ((i & TEXTURE0) == TEXTURE0) {
|
if((i & TEXTURE0) == TEXTURE0) {
|
||||||
CC_a_texture0 = true;
|
CC_a_texture0 = true;
|
||||||
}
|
}
|
||||||
if ((i & LIGHTING) == LIGHTING) {
|
if((i & TEXTURE1) == TEXTURE1) {
|
||||||
|
CC_a_texture1 = true;
|
||||||
|
}
|
||||||
|
if((i & TEXGEN) == TEXGEN) {
|
||||||
|
CC_TEX_GEN_STRQ = true;
|
||||||
|
}
|
||||||
|
if((i & LIGHTING) == LIGHTING) {
|
||||||
CC_lighting = true;
|
CC_lighting = true;
|
||||||
}
|
}
|
||||||
if ((i & FOG) == FOG) {
|
if((i & FOG) == FOG) {
|
||||||
CC_fog = true;
|
CC_fog = true;
|
||||||
}
|
}
|
||||||
if ((i & ALPHATEST) == ALPHATEST) {
|
if((i & ALPHATEST) == ALPHATEST) {
|
||||||
CC_alphatest = true;
|
CC_alphatest = true;
|
||||||
}
|
}
|
||||||
if ((i & UNIT0) == UNIT0) {
|
if((i & UNIT0) == UNIT0) {
|
||||||
CC_unit0 = true;
|
CC_unit0 = true;
|
||||||
}
|
}
|
||||||
s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_lighting, CC_fog, CC_alphatest, CC_unit0);
|
if((i & UNIT1) == UNIT1) {
|
||||||
|
CC_unit1 = true;
|
||||||
|
}
|
||||||
|
if((i & FIX_ANISOTROPIC) == FIX_ANISOTROPIC) {
|
||||||
|
CC_anisotropic = true;
|
||||||
|
}
|
||||||
|
if((i & SWAP_RB) == SWAP_RB) {
|
||||||
|
CC_swap_rb = true;
|
||||||
|
}
|
||||||
|
s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_a_texture1, CC_TEX_GEN_STRQ, CC_lighting,
|
||||||
|
CC_fog, CC_alphatest, CC_unit0, CC_unit1, CC_anisotropic, CC_swap_rb);
|
||||||
instances[i] = s;
|
instances[i] = s;
|
||||||
instanceList.add(s);
|
instanceList.add(s);
|
||||||
}
|
}
|
||||||
|
@ -70,137 +99,166 @@ public class FixedFunctionShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String shaderSource = null;
|
private static String shaderSource = null;
|
||||||
|
|
||||||
private final boolean enable_color;
|
private final boolean enable_color;
|
||||||
private final boolean enable_normal;
|
private final boolean enable_normal;
|
||||||
private final boolean enable_texture0;
|
private final boolean enable_texture0;
|
||||||
|
private final boolean enable_texture1;
|
||||||
|
private final boolean enable_TEX_GEN_STRQ;
|
||||||
private final boolean enable_lighting;
|
private final boolean enable_lighting;
|
||||||
private final boolean enable_fog;
|
private final boolean enable_fog;
|
||||||
private final boolean enable_alphatest;
|
private final boolean enable_alphatest;
|
||||||
private final boolean enable_unit0;
|
private final boolean enable_unit0;
|
||||||
|
private final boolean enable_unit1;
|
||||||
|
private final boolean enable_anisotropic_fix;
|
||||||
|
private final boolean enable_swap_rb;
|
||||||
private final ProgramGL globject;
|
private final ProgramGL globject;
|
||||||
|
|
||||||
private UniformGL u_matrix_m = null;
|
private UniformGL u_matrix_m = null;
|
||||||
private UniformGL u_matrix_p = null;
|
private UniformGL u_matrix_p = null;
|
||||||
private UniformGL u_matrix_t = null;
|
private UniformGL u_matrix_t = null;
|
||||||
|
|
||||||
private UniformGL u_fogColor = null;
|
private UniformGL u_fogColor = null;
|
||||||
private UniformGL u_fogMode = null;
|
//private UniformGL u_fogMode = null;
|
||||||
private UniformGL u_fogStart = null;
|
//private UniformGL u_fogStart = null;
|
||||||
private UniformGL u_fogEnd = null;
|
//private UniformGL u_fogEnd = null;
|
||||||
private UniformGL u_fogDensity = null;
|
//private UniformGL u_fogDensity = null;
|
||||||
private UniformGL u_fogPremultiply = null;
|
private UniformGL u_fogParam = null;
|
||||||
|
|
||||||
private UniformGL u_colorUniform = null;
|
private UniformGL u_colorUniform = null;
|
||||||
private UniformGL u_normalUniform = null;
|
private UniformGL u_normalUniform = null;
|
||||||
|
|
||||||
private UniformGL u_alphaTestF = null;
|
private UniformGL u_alphaTestF = null;
|
||||||
|
|
||||||
|
//private UniformGL u_textureGenS_M = null;
|
||||||
|
//private UniformGL u_textureGenT_M = null;
|
||||||
|
//private UniformGL u_textureGenR_M = null;
|
||||||
|
//private UniformGL u_textureGenQ_M = null;
|
||||||
|
private UniformGL u_textureGen_M = null;
|
||||||
|
private UniformGL u_textureGenS_V = null;
|
||||||
|
private UniformGL u_textureGenT_V = null;
|
||||||
|
private UniformGL u_textureGenR_V = null;
|
||||||
|
private UniformGL u_textureGenQ_V = null;
|
||||||
|
|
||||||
private UniformGL u_texCoordV0 = null;
|
private UniformGL u_texCoordV0 = null;
|
||||||
|
private UniformGL u_texCoordV1 = null;
|
||||||
|
|
||||||
private UniformGL u_light0Pos = null;
|
private UniformGL u_light0Pos = null;
|
||||||
private UniformGL u_light1Pos = null;
|
private UniformGL u_light1Pos = null;
|
||||||
|
//private UniformGL u_invertNormals = null;
|
||||||
|
|
||||||
|
private UniformGL u_anisotropic_fix = null;
|
||||||
|
|
||||||
private final int a_position;
|
private final int a_position;
|
||||||
private final int a_texture0;
|
private final int a_texture0;
|
||||||
private final int a_color;
|
private final int a_color;
|
||||||
private final int a_normal;
|
private final int a_normal;
|
||||||
|
private final int a_texture1;
|
||||||
|
|
||||||
private final int attributeIndexesToEnable;
|
private final int attributeIndexesToEnable;
|
||||||
|
|
||||||
public final StreamBuffer streamBuffer;
|
public final StreamBuffer streamBuffer;
|
||||||
public boolean bufferIsInitialized = false;
|
public boolean bufferIsInitialized = false;
|
||||||
|
|
||||||
private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0,
|
private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0, boolean CC_a_texture1, boolean CC_TEX_GEN_STRQ, boolean CC_lighting,
|
||||||
boolean CC_lighting, boolean CC_fog, boolean CC_alphatest, boolean CC_unit0) {
|
boolean CC_fog, boolean CC_alphatest, boolean CC_unit0, boolean CC_unit1, boolean CC_anisotropic_fix, boolean CC_swap_rb) {
|
||||||
enable_color = CC_a_color;
|
enable_color = CC_a_color;
|
||||||
enable_normal = CC_a_normal;
|
enable_normal = CC_a_normal;
|
||||||
enable_texture0 = CC_a_texture0;
|
enable_texture0 = CC_a_texture0;
|
||||||
|
enable_texture1 = CC_a_texture1;
|
||||||
|
enable_TEX_GEN_STRQ = CC_TEX_GEN_STRQ;
|
||||||
enable_lighting = CC_lighting;
|
enable_lighting = CC_lighting;
|
||||||
enable_fog = CC_fog;
|
enable_fog = CC_fog;
|
||||||
enable_alphatest = CC_alphatest;
|
enable_alphatest = CC_alphatest;
|
||||||
enable_unit0 = CC_unit0;
|
enable_unit0 = CC_unit0;
|
||||||
|
enable_unit1 = CC_unit1;
|
||||||
if (shaderSource == null) {
|
enable_anisotropic_fix = CC_anisotropic_fix;
|
||||||
|
enable_swap_rb = CC_swap_rb;
|
||||||
|
|
||||||
|
if(shaderSource == null) {
|
||||||
shaderSource = fileContents("/glsl/core.glsl");
|
shaderSource = fileContents("/glsl/core.glsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
String source = "";
|
String source = "";
|
||||||
if (enable_color)
|
if(enable_color) source += "\n#define CC_a_color\n";
|
||||||
source += "\n#define CC_a_color\n";
|
if(enable_normal) source += "#define CC_a_normal\n";
|
||||||
if (enable_normal)
|
if(enable_texture0) source += "#define CC_a_texture0\n";
|
||||||
source += "#define CC_a_normal\n";
|
if(enable_texture1) source += "#define CC_a_texture1\n";
|
||||||
if (enable_texture0)
|
if(enable_TEX_GEN_STRQ) source += "#define CC_TEX_GEN_STRQ\n";
|
||||||
source += "#define CC_a_texture0\n";
|
if(enable_lighting) source += "#define CC_lighting\n";
|
||||||
if (enable_lighting)
|
if(enable_fog) source += "#define CC_fog\n";
|
||||||
source += "#define CC_lighting\n";
|
if(enable_alphatest) source += "#define CC_alphatest\n";
|
||||||
if (enable_fog)
|
if(enable_unit0) source += "#define CC_unit0\n";
|
||||||
source += "#define CC_fog\n";
|
if(enable_unit1) source += "#define CC_unit1\n";
|
||||||
if (enable_alphatest)
|
if(enable_anisotropic_fix) source += "#define CC_patch_anisotropic\n";
|
||||||
source += "#define CC_alphatest\n";
|
if(enable_swap_rb) source += "#define CC_swap_rb\n";
|
||||||
if (enable_unit0)
|
|
||||||
source += "#define CC_unit0\n";
|
|
||||||
source += shaderSource;
|
source += shaderSource;
|
||||||
|
|
||||||
ShaderGL v = _wglCreateShader(_wGL_VERTEX_SHADER);
|
ShaderGL v = _wglCreateShader(_wGL_VERTEX_SHADER);
|
||||||
_wglShaderSource(v, _wgetShaderHeader() + "\n#define CC_VERT\n" + source);
|
_wglShaderSource(v, _wgetShaderHeader()+"\n#define CC_VERT\n"+source);
|
||||||
_wglCompileShader(v);
|
_wglCompileShader(v);
|
||||||
|
|
||||||
if (!_wglGetShaderCompiled(v)) {
|
if(!_wglGetShaderCompiled(v)) {
|
||||||
System.err.println(("\n\n" + _wglGetShaderInfoLog(v)).replace("\n", "\n[/glsl/core.glsl][CC_VERT] "));
|
System.err.println(("\n\n"+_wglGetShaderInfoLog(v)).replace("\n", "\n[/glsl/core.glsl][CC_VERT] "));
|
||||||
throw new RuntimeException("broken shader file");
|
throw new RuntimeException("broken shader file");
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderGL f = _wglCreateShader(_wGL_FRAGMENT_SHADER);
|
ShaderGL f = _wglCreateShader(_wGL_FRAGMENT_SHADER);
|
||||||
_wglShaderSource(f, _wgetShaderHeader() + "\n#define CC_FRAG\n" + source);
|
_wglShaderSource(f, _wgetShaderHeader()+"\n#define CC_FRAG\n"+source);
|
||||||
_wglCompileShader(f);
|
_wglCompileShader(f);
|
||||||
|
|
||||||
if (!_wglGetShaderCompiled(f)) {
|
if(!_wglGetShaderCompiled(f)) {
|
||||||
System.err.println(("\n\n" + _wglGetShaderInfoLog(f)).replace("\n", "\n[/glsl/core.glsl][CC_FRAG] "));
|
System.err.println(("\n\n"+_wglGetShaderInfoLog(f)).replace("\n", "\n[/glsl/core.glsl][CC_FRAG] "));
|
||||||
throw new RuntimeException("broken shader file");
|
throw new RuntimeException("broken shader file");
|
||||||
}
|
}
|
||||||
|
|
||||||
globject = _wglCreateProgram();
|
globject = _wglCreateProgram();
|
||||||
_wglAttachShader(globject, v);
|
_wglAttachShader(globject, v);
|
||||||
_wglAttachShader(globject, f);
|
_wglAttachShader(globject, f);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
a_position = i++;
|
a_position = i++;
|
||||||
_wglBindAttributeLocation(globject, a_position, "a_position");
|
_wglBindAttributeLocation(globject, a_position, "a_position");
|
||||||
|
|
||||||
if (enable_texture0) {
|
if(enable_texture0) {
|
||||||
a_texture0 = i++;
|
a_texture0 = i++;
|
||||||
_wglBindAttributeLocation(globject, a_texture0, "a_texture0");
|
_wglBindAttributeLocation(globject, a_texture0, "a_texture0");
|
||||||
} else {
|
}else {
|
||||||
a_texture0 = -1;
|
a_texture0 = -1;
|
||||||
}
|
}
|
||||||
if (enable_color) {
|
if(enable_color) {
|
||||||
a_color = i++;
|
a_color = i++;
|
||||||
_wglBindAttributeLocation(globject, a_color, "a_color");
|
_wglBindAttributeLocation(globject, a_color, "a_color");
|
||||||
} else {
|
}else {
|
||||||
a_color = -1;
|
a_color = -1;
|
||||||
}
|
}
|
||||||
if (enable_normal) {
|
if(enable_normal) {
|
||||||
a_normal = i++;
|
a_normal = i++;
|
||||||
_wglBindAttributeLocation(globject, a_normal, "a_normal");
|
_wglBindAttributeLocation(globject, a_normal, "a_normal");
|
||||||
} else {
|
}else {
|
||||||
a_normal = -1;
|
a_normal = -1;
|
||||||
}
|
}
|
||||||
|
if(enable_texture1) {
|
||||||
|
a_texture1 = i++;
|
||||||
|
_wglBindAttributeLocation(globject, a_texture1, "a_texture1");
|
||||||
|
}else {
|
||||||
|
a_texture1 = -1;
|
||||||
|
}
|
||||||
|
|
||||||
attributeIndexesToEnable = i;
|
attributeIndexesToEnable = i;
|
||||||
|
|
||||||
_wglLinkProgram(globject);
|
_wglLinkProgram(globject);
|
||||||
|
|
||||||
_wglDetachShader(globject, v);
|
_wglDetachShader(globject, v);
|
||||||
_wglDetachShader(globject, f);
|
_wglDetachShader(globject, f);
|
||||||
_wglDeleteShader(v);
|
_wglDeleteShader(v);
|
||||||
_wglDeleteShader(f);
|
_wglDeleteShader(f);
|
||||||
|
|
||||||
if (!_wglGetProgramLinked(globject)) {
|
if(!_wglGetProgramLinked(globject)) {
|
||||||
System.err.println(("\n\n" + _wglGetProgramInfoLog(globject)).replace("\n", "\n[LINKER] "));
|
System.err.println(("\n\n"+_wglGetProgramInfoLog(globject)).replace("\n", "\n[LINKER] "));
|
||||||
throw new RuntimeException("broken shader file");
|
throw new RuntimeException("broken shader file");
|
||||||
}
|
}
|
||||||
|
|
||||||
_wglUseProgram(globject);
|
_wglUseProgram(globject);
|
||||||
|
|
||||||
u_matrix_m = _wglGetUniformLocation(globject, "matrix_m");
|
u_matrix_m = _wglGetUniformLocation(globject, "matrix_m");
|
||||||
|
@ -208,51 +266,76 @@ public class FixedFunctionShader {
|
||||||
u_matrix_t = _wglGetUniformLocation(globject, "matrix_t");
|
u_matrix_t = _wglGetUniformLocation(globject, "matrix_t");
|
||||||
|
|
||||||
u_colorUniform = _wglGetUniformLocation(globject, "colorUniform");
|
u_colorUniform = _wglGetUniformLocation(globject, "colorUniform");
|
||||||
|
|
||||||
if (enable_lighting) {
|
if(enable_lighting) {
|
||||||
u_normalUniform = _wglGetUniformLocation(globject, "normalUniform");
|
u_normalUniform = _wglGetUniformLocation(globject, "normalUniform");
|
||||||
|
//u_invertNormals = _wglGetUniformLocation(globject, "invertNormals");
|
||||||
u_light0Pos = _wglGetUniformLocation(globject, "light0Pos");
|
u_light0Pos = _wglGetUniformLocation(globject, "light0Pos");
|
||||||
u_light1Pos = _wglGetUniformLocation(globject, "light1Pos");
|
u_light1Pos = _wglGetUniformLocation(globject, "light1Pos");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_fog) {
|
if(enable_fog) {
|
||||||
u_fogColor = _wglGetUniformLocation(globject, "fogColor");
|
u_fogColor = _wglGetUniformLocation(globject, "fogColor");
|
||||||
u_fogMode = _wglGetUniformLocation(globject, "fogMode");
|
//u_fogMode = _wglGetUniformLocation(globject, "fogMode");
|
||||||
u_fogStart = _wglGetUniformLocation(globject, "fogStart");
|
//u_fogStart = _wglGetUniformLocation(globject, "fogStart");
|
||||||
u_fogEnd = _wglGetUniformLocation(globject, "fogEnd");
|
//u_fogEnd = _wglGetUniformLocation(globject, "fogEnd");
|
||||||
u_fogDensity = _wglGetUniformLocation(globject, "fogDensity");
|
//u_fogDensity = _wglGetUniformLocation(globject, "fogDensity");
|
||||||
u_fogPremultiply = _wglGetUniformLocation(globject, "fogPremultiply");
|
u_fogParam = _wglGetUniformLocation(globject, "fogParam");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_alphatest) {
|
if(enable_alphatest) {
|
||||||
u_alphaTestF = _wglGetUniformLocation(globject, "alphaTestF");
|
u_alphaTestF = _wglGetUniformLocation(globject, "alphaTestF");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(enable_TEX_GEN_STRQ) {
|
||||||
|
//u_textureGenS_M = _wglGetUniformLocation(globject, "textureGenS_M");
|
||||||
|
//u_textureGenT_M = _wglGetUniformLocation(globject, "textureGenT_M");
|
||||||
|
//u_textureGenR_M = _wglGetUniformLocation(globject, "textureGenR_M");
|
||||||
|
//u_textureGenQ_M = _wglGetUniformLocation(globject, "textureGenQ_M");
|
||||||
|
u_textureGen_M = _wglGetUniformLocation(globject, "textureGen_M");
|
||||||
|
u_textureGenS_V = _wglGetUniformLocation(globject, "textureGenS_V");
|
||||||
|
u_textureGenT_V = _wglGetUniformLocation(globject, "textureGenT_V");
|
||||||
|
u_textureGenR_V = _wglGetUniformLocation(globject, "textureGenR_V");
|
||||||
|
u_textureGenQ_V = _wglGetUniformLocation(globject, "textureGenQ_V");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enable_anisotropic_fix) {
|
||||||
|
u_anisotropic_fix = _wglGetUniformLocation(globject, "anisotropic_fix");
|
||||||
|
_wglUniform2f(u_anisotropic_fix, 1024.0f * 63.0f / 64.0f, 1024.0f * 63.0f / 64.0f);
|
||||||
|
}
|
||||||
|
|
||||||
_wglUniform1i(_wglGetUniformLocation(globject, "tex0"), 0);
|
_wglUniform1i(_wglGetUniformLocation(globject, "tex0"), 0);
|
||||||
|
_wglUniform1i(_wglGetUniformLocation(globject, "tex1"), 1);
|
||||||
|
|
||||||
u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0");
|
u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0");
|
||||||
|
u_texCoordV1 = _wglGetUniformLocation(globject, "texCoordV1");
|
||||||
|
|
||||||
streamBuffer = new StreamBuffer(0x8000, 3, 8, (vertexArray, vertexBuffer) -> {
|
streamBuffer = new StreamBuffer(0x8000, 3, 8, (vertexArray, vertexBuffer) -> {
|
||||||
_wglBindVertexArray0(vertexArray);
|
_wglBindVertexArray0(vertexArray);
|
||||||
_wglBindBuffer(_wGL_ARRAY_BUFFER, vertexBuffer);
|
_wglBindBuffer(_wGL_ARRAY_BUFFER, vertexBuffer);
|
||||||
setupArrayForProgram();
|
setupArrayForProgram();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupArrayForProgram() {
|
public void setupArrayForProgram() {
|
||||||
_wglEnableVertexAttribArray(a_position);
|
_wglEnableVertexAttribArray(a_position);
|
||||||
_wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 28, 0);
|
_wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 32, 0);
|
||||||
if (enable_texture0) {
|
if(enable_texture0) {
|
||||||
_wglEnableVertexAttribArray(a_texture0);
|
_wglEnableVertexAttribArray(a_texture0);
|
||||||
_wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 28, 12);
|
_wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 32, 12);
|
||||||
}
|
}
|
||||||
if (enable_color) {
|
if(enable_color) {
|
||||||
_wglEnableVertexAttribArray(a_color);
|
_wglEnableVertexAttribArray(a_color);
|
||||||
_wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 28, 20);
|
_wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 32, 20);
|
||||||
}
|
}
|
||||||
if (enable_normal) {
|
if(enable_normal) {
|
||||||
_wglEnableVertexAttribArray(a_normal);
|
_wglEnableVertexAttribArray(a_normal);
|
||||||
_wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 28, 24);
|
_wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 32, 24);
|
||||||
|
}
|
||||||
|
if(enable_texture1) {
|
||||||
|
_wglEnableVertexAttribArray(a_texture1);
|
||||||
|
_wglVertexAttribPointer(a_texture1, 2, _wGL_SHORT, false, 32, 28);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,9 +344,9 @@ public class FixedFunctionShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unuseProgram() {
|
public void unuseProgram() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void optimize() {
|
public static void optimize() {
|
||||||
FixedFunctionShader pp;
|
FixedFunctionShader pp;
|
||||||
for(int i = 0, l = instanceList.size(); i < l; ++i) {
|
for(int i = 0, l = instanceList.size(); i < l; ++i) {
|
||||||
|
@ -271,137 +354,281 @@ public class FixedFunctionShader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float[] modelBuffer = new float[16];
|
private float[] matBuffer = new float[16];
|
||||||
private float[] projectionBuffer = new float[16];
|
|
||||||
private float[] textureBuffer = new float[16];
|
|
||||||
|
|
||||||
private Matrix4f modelMatrix = (Matrix4f) new Matrix4f().setZero();
|
|
||||||
private Matrix4f projectionMatrix = (Matrix4f) new Matrix4f().setZero();
|
|
||||||
private Matrix4f textureMatrix = (Matrix4f) new Matrix4f().setZero();
|
|
||||||
private Vector4f light0Pos = new Vector4f();
|
private Vector4f light0Pos = new Vector4f();
|
||||||
private Vector4f light1Pos = new Vector4f();
|
private Vector4f light1Pos = new Vector4f();
|
||||||
|
private Vector2f anisotropicFix = new Vector2f(0.0f, 0.0f);
|
||||||
public void setModelMatrix(Matrix4f mat) {
|
|
||||||
if (!mat.equals(modelMatrix)) {
|
|
||||||
modelMatrix.load(mat).store(modelBuffer);
|
|
||||||
_wglUniformMat4fv(u_matrix_m, modelBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProjectionMatrix(Matrix4f mat) {
|
|
||||||
if (!mat.equals(projectionMatrix)) {
|
|
||||||
projectionMatrix.load(mat).store(projectionBuffer);
|
|
||||||
_wglUniformMat4fv(u_matrix_p, projectionBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextureMatrix(Matrix4f mat) {
|
|
||||||
if (!mat.equals(textureMatrix)) {
|
|
||||||
textureMatrix.load(mat).store(textureBuffer);
|
|
||||||
_wglUniformMat4fv(u_matrix_t, textureBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLightPositions(Vector4f pos0, Vector4f pos1) {
|
|
||||||
if (!pos0.equals(light0Pos) || !pos1.equals(light1Pos)) {
|
|
||||||
light0Pos.set(pos0);
|
|
||||||
light1Pos.set(pos1);
|
|
||||||
_wglUniform3f(u_light0Pos, light0Pos.x, light0Pos.y, light0Pos.z);
|
|
||||||
_wglUniform3f(u_light1Pos, light1Pos.x, light1Pos.y, light1Pos.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int fogMode = 0;
|
private int fogMode = 0;
|
||||||
|
|
||||||
public void setFogMode(int mode) {
|
|
||||||
if (fogMode != mode) {
|
|
||||||
fogMode = mode;
|
|
||||||
_wglUniform1i(u_fogMode, mode % 2);
|
|
||||||
_wglUniform1f(u_fogPremultiply, mode / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float fogColorR = 0.0f;
|
private float fogColorR = 0.0f;
|
||||||
private float fogColorG = 0.0f;
|
private float fogColorG = 0.0f;
|
||||||
private float fogColorB = 0.0f;
|
private float fogColorB = 0.0f;
|
||||||
private float fogColorA = 0.0f;
|
private float fogColorA = 0.0f;
|
||||||
|
|
||||||
public void setFogColor(float r, float g, float b, float a) {
|
|
||||||
if (fogColorR != r || fogColorG != g || fogColorB != b || fogColorA != a) {
|
|
||||||
fogColorR = r;
|
|
||||||
fogColorG = g;
|
|
||||||
fogColorB = b;
|
|
||||||
fogColorA = a;
|
|
||||||
_wglUniform4f(u_fogColor, fogColorR, fogColorG, fogColorB, fogColorA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float fogStart = 0.0f;
|
private float fogStart = 0.0f;
|
||||||
private float fogEnd = 0.0f;
|
private float fogEnd = 0.0f;
|
||||||
|
|
||||||
public void setFogStartEnd(float s, float e) {
|
|
||||||
if (fogStart != s || fogEnd != e) {
|
|
||||||
fogStart = s;
|
|
||||||
fogEnd = e;
|
|
||||||
_wglUniform1f(u_fogStart, fogStart);
|
|
||||||
_wglUniform1f(u_fogEnd, fogEnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float fogDensity = 0.0f;
|
private float fogDensity = 0.0f;
|
||||||
|
|
||||||
public void setFogDensity(float d) {
|
|
||||||
if (fogDensity != d) {
|
|
||||||
fogDensity = d;
|
|
||||||
_wglUniform1f(u_fogDensity, fogDensity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float alphaTestValue = 0.0f;
|
private float alphaTestValue = 0.0f;
|
||||||
|
|
||||||
public void setAlphaTest(float limit) {
|
|
||||||
if (alphaTestValue != limit) {
|
|
||||||
alphaTestValue = limit;
|
|
||||||
_wglUniform1f(u_alphaTestF, alphaTestValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float tex0x = 0.0f;
|
private float tex0x = 0.0f;
|
||||||
private float tex0y = 0.0f;
|
private float tex0y = 0.0f;
|
||||||
|
|
||||||
public void setTex0Coords(float x, float y) {
|
private float tex1x = 0.0f;
|
||||||
if (tex0x != x || tex0y != y) {
|
private float tex1y = 0.0f;
|
||||||
tex0x = x;
|
|
||||||
tex0y = y;
|
|
||||||
_wglUniform2f(u_texCoordV0, tex0x, tex0y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float colorUniformR = 0.0f;
|
private float colorUniformR = 0.0f;
|
||||||
private float colorUniformG = 0.0f;
|
private float colorUniformG = 0.0f;
|
||||||
private float colorUniformB = 0.0f;
|
private float colorUniformB = 0.0f;
|
||||||
private float colorUniformA = 0.0f;
|
private float colorUniformA = 0.0f;
|
||||||
|
|
||||||
public void setColor(float r, float g, float b, float a) {
|
|
||||||
if (colorUniformR != r || colorUniformG != g || colorUniformB != b || colorUniformA != a) {
|
|
||||||
colorUniformR = r;
|
|
||||||
colorUniformG = g;
|
|
||||||
colorUniformB = b;
|
|
||||||
colorUniformA = a;
|
|
||||||
_wglUniform4f(u_colorUniform, colorUniformR, colorUniformG, colorUniformB, colorUniformA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float normalUniformX = 0.0f;
|
private float normalUniformX = 0.0f;
|
||||||
private float normalUniformY = 0.0f;
|
private float normalUniformY = 0.0f;
|
||||||
private float normalUniformZ = 0.0f;
|
private float normalUniformZ = 0.0f;
|
||||||
|
|
||||||
public void setNormal(float x, float y, float z) {
|
private int anisotropicFixSerial = -1;
|
||||||
if (normalUniformX != x || normalUniformY != y || normalUniformZ != z) {
|
private int colorSerial = -1;
|
||||||
normalUniformX = x;
|
private int normalSerial = -1;
|
||||||
normalUniformY = y;
|
private int tex0Serial = -1;
|
||||||
normalUniformZ = z;
|
private int tex1Serial = -1;
|
||||||
_wglUniform3f(u_normalUniform, normalUniformX, normalUniformY, normalUniformZ);
|
private int texPlaneSerial = -1;
|
||||||
|
private int texSSerial = -1;
|
||||||
|
private int texTSerial = -1;
|
||||||
|
private int texRSerial = -1;
|
||||||
|
private int texQSerial = -1;
|
||||||
|
private int fogColorSerial = -1;
|
||||||
|
private int fogCfgSerial = -1;
|
||||||
|
private int matModelSerialCounter = -1;
|
||||||
|
private int matProjSerialCounter = -1;
|
||||||
|
private int matTexSerialCounter = -1;
|
||||||
|
private int lightPos0Serial = -1;
|
||||||
|
private int lightPos1Serial = -1;
|
||||||
|
|
||||||
|
private int texS_plane = -1;
|
||||||
|
private float texS_X = -999.0f;
|
||||||
|
private float texS_Y = -999.0f;
|
||||||
|
private float texS_Z = -999.0f;
|
||||||
|
private float texS_W = -999.0f;
|
||||||
|
|
||||||
|
private int texT_plane = -1;
|
||||||
|
private float texT_X = -999.0f;
|
||||||
|
private float texT_Y = -999.0f;
|
||||||
|
private float texT_Z = -999.0f;
|
||||||
|
private float texT_W = -999.0f;
|
||||||
|
|
||||||
|
private int texR_plane = -1;
|
||||||
|
private float texR_X = -999.0f;
|
||||||
|
private float texR_Y = -999.0f;
|
||||||
|
private float texR_Z = -999.0f;
|
||||||
|
private float texR_W = -999.0f;
|
||||||
|
|
||||||
|
private int texQ_plane = -1;
|
||||||
|
private float texQ_X = -999.0f;
|
||||||
|
private float texQ_Y = -999.0f;
|
||||||
|
private float texQ_Z = -999.0f;
|
||||||
|
private float texQ_W = -999.0f;
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(anisotropicFixSerial != GL11.anisotropicFixSerial) {
|
||||||
|
float x = GL11.anisotropicFixX;
|
||||||
|
float y = GL11.anisotropicFixY;
|
||||||
|
anisotropicFixSerial = GL11.anisotropicFixSerial;
|
||||||
|
if(anisotropicFix.x != x || anisotropicFix.y != y) {
|
||||||
|
anisotropicFix.x = x;
|
||||||
|
anisotropicFix.y = y;
|
||||||
|
_wglUniform2f(u_anisotropic_fix, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(colorSerial != GL11.colorSerial) {
|
||||||
|
float r = GL11.colorR;
|
||||||
|
float g = GL11.colorG;
|
||||||
|
float b = GL11.colorB;
|
||||||
|
float a = GL11.colorA;
|
||||||
|
colorSerial = GL11.colorSerial;
|
||||||
|
if(colorUniformR != r || colorUniformG != g || colorUniformB != b || colorUniformA != a) {
|
||||||
|
colorUniformR = r;
|
||||||
|
colorUniformG = g;
|
||||||
|
colorUniformB = b;
|
||||||
|
colorUniformA = a;
|
||||||
|
_wglUniform4f(u_colorUniform, r, g, b, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(normalSerial != GL11.normalSerial) {
|
||||||
|
float x = GL11.normalX;
|
||||||
|
float y = GL11.normalY;
|
||||||
|
float z = GL11.normalZ;
|
||||||
|
normalSerial = GL11.normalSerial;
|
||||||
|
if(normalUniformX != x || normalUniformY != y || normalUniformZ != z) {
|
||||||
|
normalUniformX = x;
|
||||||
|
normalUniformY = y;
|
||||||
|
normalUniformZ = z;
|
||||||
|
_wglUniform3f(u_normalUniform, x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(tex0Serial != GL11.tex0Serial) {
|
||||||
|
float x = GL11.tex0X;
|
||||||
|
float y = GL11.tex0Y;
|
||||||
|
tex0Serial = GL11.tex0Serial;
|
||||||
|
if(tex0x != x || tex0y != y) {
|
||||||
|
tex0x = x;
|
||||||
|
tex0y = y;
|
||||||
|
_wglUniform2f(u_texCoordV0, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(tex1Serial != GL11.tex1Serial) {
|
||||||
|
float x = GL11.tex1X;
|
||||||
|
float y = GL11.tex1Y;
|
||||||
|
tex1Serial = GL11.tex1Serial;
|
||||||
|
if(tex1x != x || tex1y != y) {
|
||||||
|
tex1x = x;
|
||||||
|
tex1y = y;
|
||||||
|
_wglUniform2f(u_texCoordV1, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(texPlaneSerial != GL11.texPlaneSerial) {
|
||||||
|
int s = GL11.texS_plane;
|
||||||
|
int t = GL11.texT_plane;
|
||||||
|
int r = GL11.texR_plane;
|
||||||
|
int q = GL11.texQ_plane;
|
||||||
|
texPlaneSerial = GL11.texPlaneSerial;
|
||||||
|
if(texS_plane != s || texT_plane != t || texR_plane != r || texQ_plane != q) {
|
||||||
|
texS_plane = s;
|
||||||
|
texT_plane = t;
|
||||||
|
texR_plane = r;
|
||||||
|
texQ_plane = q;
|
||||||
|
_wglUniform4i(u_textureGen_M, s, t, r, q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(texSSerial != GL11.texSSerial) {
|
||||||
|
float x = GL11.texS_X;
|
||||||
|
float y = GL11.texS_Y;
|
||||||
|
float z = GL11.texS_Z;
|
||||||
|
float w = GL11.texS_W;
|
||||||
|
texSSerial = GL11.texSSerial;
|
||||||
|
if(texS_X != x || texS_Y != y || texS_Z != z || texS_W != w) {
|
||||||
|
texS_X = x;
|
||||||
|
texS_Y = y;
|
||||||
|
texS_Z = z;
|
||||||
|
texS_W = w;
|
||||||
|
_wglUniform4f(u_textureGenS_V, x, y, z, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(texTSerial != GL11.texTSerial) {
|
||||||
|
float x = GL11.texT_X;
|
||||||
|
float y = GL11.texT_Y;
|
||||||
|
float z = GL11.texT_Z;
|
||||||
|
float w = GL11.texT_W;
|
||||||
|
texTSerial = GL11.texTSerial;
|
||||||
|
if(texT_X != x || texT_Y != y || texT_Z != z || texT_W != w) {
|
||||||
|
texT_X = x;
|
||||||
|
texT_Y = y;
|
||||||
|
texT_Z = z;
|
||||||
|
texT_W = w;
|
||||||
|
_wglUniform4f(u_textureGenT_V, x, y, z, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(texRSerial != GL11.texRSerial) {
|
||||||
|
float x = GL11.texR_X;
|
||||||
|
float y = GL11.texR_Y;
|
||||||
|
float z = GL11.texR_Z;
|
||||||
|
float w = GL11.texR_W;
|
||||||
|
texRSerial = GL11.texRSerial;
|
||||||
|
if(texR_X != x || texR_Y != y || texR_Z != z || texR_W != w) {
|
||||||
|
texR_X = x;
|
||||||
|
texR_Y = y;
|
||||||
|
texR_Z = z;
|
||||||
|
texR_W = w;
|
||||||
|
_wglUniform4f(u_textureGenR_V, x, y, z, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(texQSerial != GL11.texQSerial) {
|
||||||
|
float x = GL11.texQ_X;
|
||||||
|
float y = GL11.texQ_Y;
|
||||||
|
float z = GL11.texQ_Z;
|
||||||
|
float w = GL11.texQ_W;
|
||||||
|
texQSerial = GL11.texQSerial;
|
||||||
|
if(texQ_X != x || texQ_Y != y || texQ_Z != z || texQ_W != w) {
|
||||||
|
texQ_X = x;
|
||||||
|
texQ_Y = y;
|
||||||
|
texQ_Z = z;
|
||||||
|
texQ_W = w;
|
||||||
|
_wglUniform4f(u_textureGenQ_V, x, y, z, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(fogColorSerial != GL11.fogColorSerial) {
|
||||||
|
float r = GL11.fogColorR;
|
||||||
|
float g = GL11.fogColorG;
|
||||||
|
float b = GL11.fogColorB;
|
||||||
|
float a = GL11.fogColorA;
|
||||||
|
fogColorSerial = GL11.fogColorSerial;
|
||||||
|
if(fogColorR != r || fogColorG != g || fogColorB != b || fogColorA != a) {
|
||||||
|
fogColorR = r;
|
||||||
|
fogColorG = g;
|
||||||
|
fogColorB = b;
|
||||||
|
fogColorA = a;
|
||||||
|
_wglUniform4f(u_fogColor, r, g, b, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(fogCfgSerial != GL11.fogCfgSerial) {
|
||||||
|
int fogModex = GL11.fogPremultiply ? 2 : GL11.fogMode;
|
||||||
|
float fogStarty = GL11.fogStart;
|
||||||
|
float fogEndz = GL11.fogEnd - fogStarty;
|
||||||
|
float fogDensityw = GL11.fogDensity;
|
||||||
|
fogCfgSerial = GL11.fogCfgSerial;
|
||||||
|
if(fogMode != fogModex || fogStart != fogStarty ||
|
||||||
|
fogEnd != fogEndz || fogDensity != fogDensityw) {
|
||||||
|
fogMode = fogModex;
|
||||||
|
fogStart = fogStarty;
|
||||||
|
fogEnd = fogEndz;
|
||||||
|
fogDensity = fogDensityw;
|
||||||
|
_wglUniform4f(u_fogParam, fogModex, fogStarty, fogEndz, fogDensityw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float limit = GL11.alphaThresh;
|
||||||
|
if(alphaTestValue != limit) {
|
||||||
|
alphaTestValue = limit;
|
||||||
|
_wglUniform1f(u_alphaTestF, limit);
|
||||||
|
}
|
||||||
|
float[] matCopyBuffer = matBuffer;
|
||||||
|
int i = GL11.matModelPointer;
|
||||||
|
int j = GL11.matModelVSerial[i];
|
||||||
|
if(matModelSerialCounter != j) {
|
||||||
|
matModelSerialCounter = j;
|
||||||
|
GL11.matModelV[i].store(matCopyBuffer);
|
||||||
|
_wglUniformMat4fv(u_matrix_m, matCopyBuffer);
|
||||||
|
}
|
||||||
|
i = GL11.matProjPointer;
|
||||||
|
j = GL11.matProjVSerial[i];
|
||||||
|
if(matProjSerialCounter != j) {
|
||||||
|
matProjSerialCounter = j;
|
||||||
|
GL11.matProjV[i].store(matCopyBuffer);
|
||||||
|
_wglUniformMat4fv(u_matrix_p, matCopyBuffer);
|
||||||
|
}
|
||||||
|
i = GL11.matTexPointer;
|
||||||
|
j = GL11.matTexVSerial[i];
|
||||||
|
if(matTexSerialCounter != j) {
|
||||||
|
matTexSerialCounter = j;
|
||||||
|
GL11.matTexV[i].store(matCopyBuffer);
|
||||||
|
_wglUniformMat4fv(u_matrix_t, matCopyBuffer);
|
||||||
|
}
|
||||||
|
if(lightPos0Serial != GL11.lightPos0Serial) {
|
||||||
|
lightPos0Serial = GL11.lightPos0Serial;
|
||||||
|
Vector4f pos = GL11.lightPos0vec;
|
||||||
|
if(!pos.equals(light0Pos)) {
|
||||||
|
light0Pos.set(pos);
|
||||||
|
_wglUniform3f(u_light0Pos, pos.x, pos.y, pos.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(lightPos1Serial != GL11.lightPos1Serial) {
|
||||||
|
lightPos1Serial = GL11.lightPos1Serial;
|
||||||
|
Vector4f pos = GL11.lightPos1vec;
|
||||||
|
if(!pos.equals(light1Pos)) {
|
||||||
|
light1Pos.set(pos);
|
||||||
|
_wglUniform3f(u_light1Pos, pos.x, pos.y, pos.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.PeytonPlayz585.glemu;
|
package net.PeytonPlayz585.glemu;
|
||||||
|
|
||||||
import static net.PeytonPlayz585.opengl.GL11.*;
|
import static net.PeytonPlayz585.opengl.GL11.*;
|
||||||
|
import static net.PeytonPlayz585.opengl.GL11.EaglerAdapterImpl2.*;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.PeytonPlayz585.glemu;
|
||||||
|
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.GLAllocation;
|
import net.minecraft.src.GLAllocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class that emulates immediate mode vertex data submission.
|
* Utility class that emulates immediate mode vertex data submission.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.PeytonPlayz585.glemu;
|
package net.PeytonPlayz585.glemu;
|
||||||
|
|
||||||
import static net.PeytonPlayz585.opengl.GL11.*;
|
import static net.PeytonPlayz585.opengl.GL11.EaglerAdapterImpl2.*;
|
||||||
|
|
||||||
public class StreamBuffer {
|
public class StreamBuffer {
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,49 @@ package net.PeytonPlayz585.input;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class Keyboard extends GL11 {
|
public class Keyboard {
|
||||||
|
|
||||||
|
public static void destroy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEventKey() {
|
||||||
|
return GL11.EaglerAdapterImpl2.getEventKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isKeyDown(int i) {
|
||||||
|
return GL11.EaglerAdapterImpl2.isKeyDown(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getEventKeyState() {
|
||||||
|
return GL11.EaglerAdapterImpl2.getEventKeyState();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean next() {
|
public static boolean next() {
|
||||||
return keysNext();
|
return GL11.EaglerAdapterImpl2.keysNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getKeyName(int var0) {
|
||||||
|
return GL11.EaglerAdapterImpl2.getKeyName(var0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void enableRepeatEvents(boolean b) {
|
||||||
|
GL11.EaglerAdapterImpl2.enableRepeatEvents(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getClipboardString() {
|
||||||
|
return GL11.EaglerAdapterImpl2.getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setClipboard(String s) {
|
||||||
|
GL11.EaglerAdapterImpl2.setClipboard(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char getEventCharacter() {
|
public static char getEventCharacter() {
|
||||||
return getEventChar();
|
return GL11.EaglerAdapterImpl2.getEventChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFunctionKeyDown(int p1, int p2) {
|
||||||
|
return isKeyDown(p1) && getEventKey() == p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,54 +2,60 @@ package net.PeytonPlayz585.input;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class Mouse extends GL11 {
|
public class Mouse {
|
||||||
|
|
||||||
public static int getX() {
|
public static int getX() {
|
||||||
return mouseGetX();
|
return GL11.EaglerAdapterImpl2.mouseGetX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getY() {
|
public static int getY() {
|
||||||
return mouseGetY();
|
return GL11.EaglerAdapterImpl2.mouseGetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean next() {
|
public static void create() {
|
||||||
return mouseNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getEventButtonState() {
|
|
||||||
return mouseGetEventButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEventX() {
|
|
||||||
return mouseGetEventX();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int getEventY() {
|
|
||||||
return mouseGetEventY();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEventButton() {
|
|
||||||
return mouseGetEventButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDX() {
|
|
||||||
return mouseGetDX();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDY() {
|
|
||||||
return mouseGetDY();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setGrabbed(boolean b) {
|
public static void setGrabbed(boolean b) {
|
||||||
mouseSetGrabbed(b);
|
GL11.EaglerAdapterImpl2.mouseSetGrabbed(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isButtonDown(int i) {
|
public static int getDX() {
|
||||||
return mouseIsButtonDown(i);
|
return GL11.EaglerAdapterImpl2.mouseGetDX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDY() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseGetDY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void destroy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean next() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEventButton() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseGetEventButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getEventButtonState() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseGetEventButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getEventDWheel() {
|
public static int getEventDWheel() {
|
||||||
return mouseGetEventDWheel();
|
return GL11.EaglerAdapterImpl2.mouseGetEventDWheel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isButtonDown(int i) {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseIsButtonDown(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEventX() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseGetEventX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEventY() {
|
||||||
|
return GL11.EaglerAdapterImpl2.mouseGetEventY();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
58
src/main/java/net/PeytonPlayz585/opengl/Display.java
Normal file
58
src/main/java/net/PeytonPlayz585/opengl/Display.java
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
package net.PeytonPlayz585.opengl;
|
||||||
|
|
||||||
|
public class Display {
|
||||||
|
|
||||||
|
static Display display = new Display();
|
||||||
|
|
||||||
|
//Can NOT be null!
|
||||||
|
private static String title = "Minecraft";
|
||||||
|
|
||||||
|
public Display() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isActive() {
|
||||||
|
return GL11.EaglerAdapterImpl2.isFocused();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getWidth() {
|
||||||
|
return GL11.EaglerAdapterImpl2.getCanvasWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getHeight() {
|
||||||
|
return GL11.EaglerAdapterImpl2.getCanvasHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFullscreen(boolean b) {
|
||||||
|
GL11.EaglerAdapterImpl2.setFullscreen(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTitle(String newTitle) {
|
||||||
|
if(newTitle == null) {
|
||||||
|
throw new IllegalArgumentException("title CAN NOT be null");
|
||||||
|
}
|
||||||
|
title = newTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void update() {
|
||||||
|
//GL11.EaglerAdapterImpl2.doc.setTitle(title);
|
||||||
|
GL11.EaglerAdapterImpl2.updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Display getDisplayMode() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void swapBuffers() {
|
||||||
|
GL11.glFlush();
|
||||||
|
GL11.EaglerAdapterImpl2.updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void destroy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFocused() {
|
||||||
|
return GL11.EaglerAdapterImpl2.isFocused();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +0,0 @@
|
||||||
package net.PeytonPlayz585.opengl;
|
|
||||||
|
|
||||||
public class GL11 extends EaglerAdapterGL30 {
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,8 +17,8 @@ public class LocalStorageManager {
|
||||||
public static NBTTagCompound levelSettingsStorage = null;
|
public static NBTTagCompound levelSettingsStorage = null;
|
||||||
|
|
||||||
public static void loadStorage() {
|
public static void loadStorage() {
|
||||||
byte[] g = GL11.loadLocalStorage("g");
|
byte[] g = GL11.EaglerAdapterImpl2.loadLocalStorage("g");
|
||||||
byte[] p = GL11.loadLocalStorage("p");
|
byte[] p = GL11.EaglerAdapterImpl2.loadLocalStorage("p");
|
||||||
|
|
||||||
if(g != null) {
|
if(g != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -51,7 +51,7 @@ public class LocalStorageManager {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||||
NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s));
|
NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s));
|
||||||
GL11.saveLocalStorage("g", s.toByteArray());
|
GL11.EaglerAdapterImpl2.saveLocalStorage("g", s.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class LocalStorageManager {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||||
NBTBase.writeTag(levelSettingsStorage, new DataOutputStream(s));
|
NBTBase.writeTag(levelSettingsStorage, new DataOutputStream(s));
|
||||||
GL11.saveLocalStorage("p", s.toByteArray());
|
GL11.EaglerAdapterImpl2.saveLocalStorage("p", s.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package net.PeytonPlayz585.textures;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.src.RenderEngine;
|
||||||
|
|
||||||
|
public class TextureLocation {
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
private int glObject;
|
||||||
|
|
||||||
|
public TextureLocation(String path) {
|
||||||
|
this.path = path;
|
||||||
|
this.glObject = -1;
|
||||||
|
locations.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void freeTextures() {
|
||||||
|
for (TextureLocation l : locations) {
|
||||||
|
l.glObject = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTexturePointer() {
|
||||||
|
RenderEngine r = Minecraft.getMinecraft().renderEngine;
|
||||||
|
if (glObject == -1) {
|
||||||
|
glObject = r.getTexture(path);
|
||||||
|
if (glObject == -1) {
|
||||||
|
System.err.println("could not load: " + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return glObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bindTexture() {
|
||||||
|
RenderEngine r = Minecraft.getMinecraft().renderEngine;
|
||||||
|
int i = getTexturePointer();
|
||||||
|
if(i != -1) {
|
||||||
|
r.bindTexture(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ArrayList<TextureLocation> locations = new ArrayList();
|
||||||
|
|
||||||
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft;
|
|
||||||
|
|
||||||
public class EaglerImage {
|
|
||||||
|
|
||||||
public final int[] data;
|
|
||||||
public final int w;
|
|
||||||
public final int h;
|
|
||||||
public final boolean alpha;
|
|
||||||
|
|
||||||
public EaglerImage(int width, int height, int[] pixels, boolean alpha) {
|
|
||||||
this.w = width;
|
|
||||||
this.h = height;
|
|
||||||
this.data = pixels;
|
|
||||||
this.alpha = alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EaglerImage(int width, int height, boolean alpha) {
|
|
||||||
this.w = width;
|
|
||||||
this.h = height;
|
|
||||||
this.data = new int[width * height];
|
|
||||||
this.alpha = alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EaglerImage getSubImage(int x, int y, int pw, int ph) {
|
|
||||||
int[] img = new int[pw * ph];
|
|
||||||
for(int i = 0; i < ph; ++i) {
|
|
||||||
System.arraycopy(data, (i + y) * this.w + x, img, i * pw, pw);
|
|
||||||
}
|
|
||||||
return new EaglerImage(pw, ph, img, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] data() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
|
|
||||||
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 x = startX; x < startX + w; x++) {
|
|
||||||
int imageDataIndex = y * this.w + x;
|
|
||||||
int argb = data[imageDataIndex];
|
|
||||||
int alpha = (argb >> 24) & 0xff;
|
|
||||||
int red = (argb >> 16) & 0xff;
|
|
||||||
int green = (argb >> 8) & 0xff;
|
|
||||||
int blue = argb & 0xff;
|
|
||||||
int rgb = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
|
||||||
|
|
||||||
rgbArray[offset + (y - startY) * scansize + (x - startX)] = rgb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rgbArray;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft;
|
|
||||||
|
|
||||||
import java.nio.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
|
||||||
|
|
||||||
public class GLAllocation {
|
|
||||||
|
|
||||||
public GLAllocation() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized int generateDisplayLists(int i) {
|
|
||||||
int j = GL11.glGenLists(i);
|
|
||||||
displayLists.add(Integer.valueOf(j));
|
|
||||||
displayLists.add(Integer.valueOf(i));
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void generateTextureNames(IntBuffer intbuffer) {
|
|
||||||
|
|
||||||
for (int i = intbuffer.position(); i < intbuffer.limit(); i++) {
|
|
||||||
int tx = GL11.glGenTextures();
|
|
||||||
intbuffer.put(i, tx);
|
|
||||||
textureNames.add(Integer.valueOf(tx));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void deleteTexturesAndDisplayLists() {
|
|
||||||
for (int i = 0; i < displayLists.size(); i += 2) {
|
|
||||||
GL11.glDeleteLists(((Integer) displayLists.get(i)).intValue(),
|
|
||||||
((Integer) displayLists.get(i + 1)).intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < textureNames.size(); j++) {
|
|
||||||
GL11.glDeleteTextures(((Integer) textureNames.get(j)).intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
displayLists.clear();
|
|
||||||
textureNames.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ByteBuffer createDirectByteBuffer(int par0) {
|
|
||||||
return GL11.isWebGL ? ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()) : ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IntBuffer createDirectIntBuffer(int par0) {
|
|
||||||
return GL11.isWebGL ? IntBuffer.wrap(new int[par0]) : createDirectByteBuffer(par0 << 2).asIntBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FloatBuffer createDirectFloatBuffer(int par0) {
|
|
||||||
return GL11.isWebGL ? FloatBuffer.wrap(new float[par0]) : createDirectByteBuffer(par0 << 2).asFloatBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List displayLists = new ArrayList();
|
|
||||||
private static List textureNames = new ArrayList();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft.adapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
|
|
||||||
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
|
|
||||||
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
|
|
||||||
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
|
|
||||||
*
|
|
||||||
* NOT FOR COMMERCIAL OR MALICIOUS USE
|
|
||||||
*
|
|
||||||
* (please read the 'LICENSE' file this repo's root directory for more info)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FileChooserResult {
|
|
||||||
|
|
||||||
public final String fileName;
|
|
||||||
public final byte[] fileData;
|
|
||||||
|
|
||||||
public FileChooserResult(String fileName, byte[] fileData) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.fileData = fileData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package net.minecraft.client;
|
||||||
|
|
||||||
import net.PeytonPlayz585.input.Keyboard;
|
import net.PeytonPlayz585.input.Keyboard;
|
||||||
import net.PeytonPlayz585.input.Mouse;
|
import net.PeytonPlayz585.input.Mouse;
|
||||||
|
import net.PeytonPlayz585.opengl.Display;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.PeytonPlayz585.sound.SoundManager;
|
import net.PeytonPlayz585.sound.SoundManager;
|
||||||
import net.PeytonPlayz585.util.glu.GLU;
|
import net.PeytonPlayz585.util.glu.GLU;
|
||||||
|
@ -113,8 +114,8 @@ public class Minecraft implements Runnable {
|
||||||
|
|
||||||
public Minecraft() {
|
public Minecraft() {
|
||||||
new ThreadSleepForever(this, "Timer hack thread");
|
new ThreadSleepForever(this, "Timer hack thread");
|
||||||
this.displayWidth = GL11.getCanvasWidth();
|
this.displayWidth = Display.getWidth();
|
||||||
this.displayHeight = GL11.getCanvasHeight();
|
this.displayHeight = Display.getHeight();
|
||||||
mc = this;
|
mc = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,13 +156,7 @@ public class Minecraft implements Runnable {
|
||||||
|
|
||||||
this.checkGLError("Post startup");
|
this.checkGLError("Post startup");
|
||||||
this.ingameGUI = new GuiIngame(this);
|
this.ingameGUI = new GuiIngame(this);
|
||||||
if(GL11.forcedUser != null & GL11.forcedServer != null & GL11.joinServerOnLaunch) {
|
this.displayGuiScreen(new GuiMainMenu());
|
||||||
this.field_6320_i.inventory = GL11.forcedUser;
|
|
||||||
this.gameSettings.username = GL11.forcedUser;
|
|
||||||
this.displayGuiScreen(new GuiConnecting(this, GL11.forcedServer));
|
|
||||||
} else {
|
|
||||||
this.displayGuiScreen(new GuiMainMenu());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadScreen() {
|
private void loadScreen() {
|
||||||
|
@ -199,7 +194,7 @@ public class Minecraft implements Runnable {
|
||||||
GL11.glEnable(3008 /* GL_ALPHA_TEST */);
|
GL11.glEnable(3008 /* GL_ALPHA_TEST */);
|
||||||
GL11.glAlphaFunc(516, 1.0F);
|
GL11.glAlphaFunc(516, 1.0F);
|
||||||
GL11.glFlush();
|
GL11.glFlush();
|
||||||
GL11.updateDisplay();
|
Display.update();
|
||||||
GL11.optimize();
|
GL11.optimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,9 +300,9 @@ public class Minecraft implements Runnable {
|
||||||
if(this.theWorld != null && this.theWorld.multiplayerWorld) {
|
if(this.theWorld != null && this.theWorld.multiplayerWorld) {
|
||||||
this.theWorld.func_6465_g();
|
this.theWorld.func_6465_g();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(8))) {
|
if(!Keyboard.isFunctionKeyDown(this.gameSettings.keyBindFunction.keyCode, 8)) {
|
||||||
GL11.updateDisplay();
|
Display.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.field_6307_v) {
|
if(!this.field_6307_v) {
|
||||||
|
@ -318,28 +313,28 @@ public class Minecraft implements Runnable {
|
||||||
this.field_9243_r.func_4136_b(this.timer.renderPartialTicks);
|
this.field_9243_r.func_4136_b(this.timer.renderPartialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isFocused()) {
|
if(!Display.isFocused()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10L);
|
Thread.sleep(10L);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(4)) {
|
if(Keyboard.isFunctionKeyDown(this.gameSettings.keyBindFunction.keyCode, 4)) {
|
||||||
this.func_6238_a(var20);
|
this.func_6238_a(var20);
|
||||||
} else {
|
} else {
|
||||||
this.field_6290_K = System.nanoTime();
|
this.field_6290_K = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(8)) {
|
if(Keyboard.isFunctionKeyDown(this.gameSettings.keyBindFunction.keyCode, 8)) {
|
||||||
GL11.updateDisplay();
|
Display.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if((GL11.getCanvasWidth() != this.displayWidth || GL11.getCanvasHeight() != this.displayHeight)) {
|
if((Display.getWidth() != this.displayWidth || Display.getHeight() != this.displayHeight)) {
|
||||||
this.displayWidth = GL11.getCanvasWidth();
|
this.displayWidth = Display.getWidth();
|
||||||
this.displayHeight = GL11.getCanvasHeight();
|
this.displayHeight = Display.getHeight();
|
||||||
if(this.displayWidth <= 0) {
|
if(this.displayWidth <= 0) {
|
||||||
this.displayWidth = 1;
|
this.displayWidth = 1;
|
||||||
}
|
}
|
||||||
|
@ -447,11 +442,11 @@ public class Minecraft implements Runnable {
|
||||||
this.theWorld.chunkProvider.saveChunks(false, (IProgressUpdate)null);
|
this.theWorld.chunkProvider.saveChunks(false, (IProgressUpdate)null);
|
||||||
}
|
}
|
||||||
this.running = false;
|
this.running = false;
|
||||||
GL11.exit();
|
GL11.EaglerAdapterImpl2.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_6259_e() {
|
public void func_6259_e() {
|
||||||
if(GL11.isFocused()) {
|
if(Display.isFocused()) {
|
||||||
if(!this.field_6289_L) {
|
if(!this.field_6289_L) {
|
||||||
this.field_6289_L = true;
|
this.field_6289_L = true;
|
||||||
this.mouseHelper.func_774_a();
|
this.mouseHelper.func_774_a();
|
||||||
|
@ -674,7 +669,7 @@ public class Minecraft implements Runnable {
|
||||||
this.func_6252_g();
|
this.func_6252_g();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(6)) {
|
if(Keyboard.isFunctionKeyDown(this.gameSettings.keyBindFunction.keyCode, 6)) {
|
||||||
this.gameSettings.thirdPersonView = !this.gameSettings.thirdPersonView;
|
this.gameSettings.thirdPersonView = !this.gameSettings.thirdPersonView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,10 +691,6 @@ public class Minecraft implements Runnable {
|
||||||
this.thePlayer.inventory.currentItem = var4;
|
this.thePlayer.inventory.currentItem = var4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Keyboard.getEventKey() == this.gameSettings.keyBindToggleFog.keyCode) {
|
|
||||||
this.gameSettings.setOptionValue(4, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54) ? 1 : -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
|
|
||||||
public class ColorizerFoliage {
|
public class ColorizerFoliage {
|
||||||
private static final int[] field_6529_a = new int[65536];
|
private static final int[] field_6529_a = new int[65536];
|
||||||
|
@ -12,13 +12,14 @@ public class ColorizerFoliage {
|
||||||
int var5 = (int)((1.0D - var2) * 255.0D);
|
int var5 = (int)((1.0D - var2) * 255.0D);
|
||||||
return field_6529_a[var5 << 8 | var4];
|
return field_6529_a[var5 << 8 | var4];
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
EaglerImage var0 = GL11.loadPNG(GL11.loadResourceBytes("/misc/foliagecolor.png"));
|
BufferedImage var0 = ImageIO.read(ImageIO.getResource("/misc/foliagecolor.png"));
|
||||||
var0.getRGB(0, 0, 256, 256, field_6529_a, 0, 256);
|
var0.getRGB(0, 0, 256, 256, field_6529_a, 0, 256);
|
||||||
} catch (Exception var1) {
|
} catch (Exception var1) {
|
||||||
var1.printStackTrace();
|
var1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
|
|
||||||
public class ColorizerGrass {
|
public class ColorizerGrass {
|
||||||
private static final int[] field_6540_a = new int[65536];
|
private static final int[] field_6540_a = new int[65536];
|
||||||
|
@ -12,10 +12,10 @@ public class ColorizerGrass {
|
||||||
int var5 = (int)((1.0D - var2) * 255.0D);
|
int var5 = (int)((1.0D - var2) * 255.0D);
|
||||||
return field_6540_a[var5 << 8 | var4];
|
return field_6540_a[var5 << 8 | var4];
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
EaglerImage var0 = GL11.loadPNG(GL11.loadResourceBytes("/misc/grasscolor.png"));
|
BufferedImage var0 = ImageIO.read(ImageIO.getResource("/misc/grasscolor.png"));
|
||||||
var0.getRGB(0, 0, 256, 256, field_6540_a, 0, 256);
|
var0.getRGB(0, 0, 256, 256, field_6540_a, 0, 256);
|
||||||
} catch (Exception var1) {
|
} catch (Exception var1) {
|
||||||
var1.printStackTrace();
|
var1.printStackTrace();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Random;
|
||||||
import net.PeytonPlayz585.glemu.GameOverlayFramebuffer;
|
import net.PeytonPlayz585.glemu.GameOverlayFramebuffer;
|
||||||
import net.PeytonPlayz585.input.Keyboard;
|
import net.PeytonPlayz585.input.Keyboard;
|
||||||
import net.PeytonPlayz585.input.Mouse;
|
import net.PeytonPlayz585.input.Mouse;
|
||||||
|
import net.PeytonPlayz585.opengl.Display;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.PeytonPlayz585.util.glu.GLU;
|
import net.PeytonPlayz585.util.glu.GLU;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -17,21 +18,24 @@ public class EntityRenderer {
|
||||||
private MouseFilter mouseFilterYAxis = new MouseFilter();
|
private MouseFilter mouseFilterYAxis = new MouseFilter();
|
||||||
|
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
private float field_1387_i = 0.0F;
|
private float farPlaneDistance = 0.0F;
|
||||||
public ItemRenderer field_1395_a;
|
public ItemRenderer field_1395_a;
|
||||||
private int field_1386_j;
|
private int field_1386_j;
|
||||||
private Entity field_1385_k = null;
|
private Entity field_1385_k = null;
|
||||||
|
private boolean cloudFog = false;
|
||||||
|
private double cameraZoom = 1.0D;
|
||||||
|
private double cameraYaw = 0.0D;
|
||||||
|
private double cameraPitch = 0.0D;
|
||||||
private long field_1384_l = System.currentTimeMillis();
|
private long field_1384_l = System.currentTimeMillis();
|
||||||
private Random field_1383_m = new Random();
|
private Random field_1383_m = new Random();
|
||||||
volatile int field_1394_b = 0;
|
volatile int field_1394_b = 0;
|
||||||
volatile int field_1393_c = 0;
|
volatile int field_1393_c = 0;
|
||||||
FloatBuffer field_1392_d = GLAllocation.createDirectFloatBuffer(16);
|
FloatBuffer fogColorBuffer = GLAllocation.createDirectFloatBuffer(16);
|
||||||
float field_4270_e;
|
float fogColorRed;
|
||||||
float field_4269_f;
|
float fogColorGreen;
|
||||||
float field_4268_g;
|
float fogColorBlue;
|
||||||
private float field_1382_n;
|
private float fogColor2;
|
||||||
private float field_1381_o;
|
private float fogColor1;
|
||||||
|
|
||||||
private static boolean zoomMode = false;
|
private static boolean zoomMode = false;
|
||||||
|
|
||||||
private GameOverlayFramebuffer overlayFramebuffer;
|
private GameOverlayFramebuffer overlayFramebuffer;
|
||||||
|
@ -43,11 +47,11 @@ public class EntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_911_a() {
|
public void func_911_a() {
|
||||||
this.field_1382_n = this.field_1381_o;
|
this.fogColor2 = this.fogColor1;
|
||||||
float var1 = this.mc.theWorld.getLightBrightness(MathHelper.floor_double(this.mc.thePlayer.posX), MathHelper.floor_double(this.mc.thePlayer.posY), MathHelper.floor_double(this.mc.thePlayer.posZ));
|
float var1 = this.mc.theWorld.getLightBrightness(MathHelper.floor_double(this.mc.thePlayer.posX), MathHelper.floor_double(this.mc.thePlayer.posY), MathHelper.floor_double(this.mc.thePlayer.posZ));
|
||||||
float var2 = (float)(3 - this.mc.gameSettings.renderDistance) / 3.0F;
|
float var2 = (float)(3 - this.mc.gameSettings.renderDistance) / 3.0F;
|
||||||
float var3 = var1 * (1.0F - var2) + var2;
|
float var3 = var1 * (1.0F - var2) + var2;
|
||||||
this.field_1381_o += (var3 - this.field_1381_o) * 0.1F;
|
this.fogColor1 += (var3 - this.fogColor1) * 0.1F;
|
||||||
++this.field_1386_j;
|
++this.field_1386_j;
|
||||||
this.field_1395_a.func_895_a();
|
this.field_1395_a.func_895_a();
|
||||||
if(this.mc.field_6288_M) {
|
if(this.mc.field_6288_M) {
|
||||||
|
@ -182,6 +186,7 @@ public class EntityRenderer {
|
||||||
|
|
||||||
private void orientCamera(float var1) {
|
private void orientCamera(float var1) {
|
||||||
EntityPlayerSP var2 = this.mc.thePlayer;
|
EntityPlayerSP var2 = this.mc.thePlayer;
|
||||||
|
float var31 = var2.yOffset - 1.62F;
|
||||||
double var3 = var2.prevPosX + (var2.posX - var2.prevPosX) * (double)var1;
|
double var3 = var2.prevPosX + (var2.posX - var2.prevPosX) * (double)var1;
|
||||||
double var5 = var2.prevPosY + (var2.posY - var2.prevPosY) * (double)var1;
|
double var5 = var2.prevPosY + (var2.posY - var2.prevPosY) * (double)var1;
|
||||||
double var7 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * (double)var1;
|
double var7 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * (double)var1;
|
||||||
|
@ -229,18 +234,31 @@ public class EntityRenderer {
|
||||||
|
|
||||||
GL11.glRotatef(var2.prevRotationPitch + (var2.rotationPitch - var2.prevRotationPitch) * var1, 1.0F, 0.0F, 0.0F);
|
GL11.glRotatef(var2.prevRotationPitch + (var2.rotationPitch - var2.prevRotationPitch) * var1, 1.0F, 0.0F, 0.0F);
|
||||||
GL11.glRotatef(var2.prevRotationYaw + (var2.rotationYaw - var2.prevRotationYaw) * var1 + 180.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(var2.prevRotationYaw + (var2.rotationYaw - var2.prevRotationYaw) * var1 + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
|
||||||
|
GL11.glTranslatef(0.0F, var31, 0.0F);
|
||||||
|
var3 = var2.prevPosX + (var2.posX - var2.prevPosX) * (double)var1;
|
||||||
|
var5 = var2.prevPosY + (var2.posY - var2.prevPosY) * (double)var1 - (double)var3;
|
||||||
|
var7 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * (double)var1;
|
||||||
|
this.cloudFog = this.mc.field_6323_f.func_27307_a(var3, var5, var7, var1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCameraTransform(float var1, int var2) {
|
private void setupCameraTransform(float var1, int var2) {
|
||||||
this.field_1387_i = (float)(256 >> this.mc.gameSettings.renderDistance);
|
this.farPlaneDistance = (float)(256 >> this.mc.gameSettings.renderDistance);
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
GL11.glLoadIdentity();
|
GL11.glLoadIdentity();
|
||||||
float var3 = 0.07F;
|
float var3 = 0.07F;
|
||||||
if(this.mc.gameSettings.anaglyph) {
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
GL11.glTranslatef((float)(-(var2 * 2 - 1)) * var3, 0.0F, 0.0F);
|
GL11.glTranslatef((float)(-(var2 * 2 - 1)) * var3, 0.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.cameraZoom != 1.0D) {
|
||||||
|
GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F);
|
||||||
|
GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D);
|
||||||
|
GLU.gluPerspective(this.func_914_d(var1), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F);
|
||||||
|
} else {
|
||||||
|
GLU.gluPerspective(this.func_914_d(var1), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F);
|
||||||
|
}
|
||||||
|
|
||||||
GLU.gluPerspective(this.func_914_d(var1), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.field_1387_i);
|
|
||||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||||
GL11.glLoadIdentity();
|
GL11.glLoadIdentity();
|
||||||
if(this.mc.gameSettings.anaglyph) {
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
|
@ -293,7 +311,7 @@ public class EntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_4136_b(float var1) {
|
public void func_4136_b(float var1) {
|
||||||
if(!GL11.isFocused()) {
|
if(!Display.isFocused()) {
|
||||||
if(System.currentTimeMillis() - this.field_1384_l > 500L) {
|
if(System.currentTimeMillis() - this.field_1384_l > 500L) {
|
||||||
this.mc.func_6252_g();
|
this.mc.func_6252_g();
|
||||||
}
|
}
|
||||||
|
@ -340,7 +358,7 @@ public class EntityRenderer {
|
||||||
this.mc.ingameGUI.renderGameOverlay(var1, this.mc.currentScreen != null, var10, var11);
|
this.mc.ingameGUI.renderGameOverlay(var1, this.mc.currentScreen != null, var10, var11);
|
||||||
GL11.enableOverlayFramebufferBlending(false);
|
GL11.enableOverlayFramebufferBlending(false);
|
||||||
this.overlayFramebuffer.endRender();
|
this.overlayFramebuffer.endRender();
|
||||||
GL11.glClearColor(this.field_4270_e, this.field_4269_f, this.field_4268_g, 0.0F);
|
GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F);
|
||||||
}
|
}
|
||||||
this.func_905_b();
|
this.func_905_b();
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
@ -411,17 +429,17 @@ public class EntityRenderer {
|
||||||
this.setupCameraTransform(var1, var11);
|
this.setupCameraTransform(var1, var11);
|
||||||
ClippingHelperImplementation.func_1155_a();
|
ClippingHelperImplementation.func_1155_a();
|
||||||
if(this.mc.gameSettings.renderDistance < 2) {
|
if(this.mc.gameSettings.renderDistance < 2) {
|
||||||
this.func_4140_a(-1);
|
this.setupFog(-1, var1);
|
||||||
var3.func_4142_a(var1);
|
var3.func_4142_a(var1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_FOG);
|
GL11.glEnable(GL11.GL_FOG);
|
||||||
this.func_4140_a(1);
|
this.setupFog(1, var1);
|
||||||
Frustrum var12 = new Frustrum();
|
Frustrum var12 = new Frustrum();
|
||||||
var12.func_343_a(var5, var7, var9);
|
var12.func_343_a(var5, var7, var9);
|
||||||
this.mc.field_6323_f.func_960_a(var12, var1);
|
this.mc.field_6323_f.func_960_a(var12, var1);
|
||||||
this.mc.field_6323_f.func_948_a(var2, false);
|
this.mc.field_6323_f.func_948_a(var2, false);
|
||||||
this.func_4140_a(0);
|
this.setupFog(0, var1);
|
||||||
GL11.glEnable(GL11.GL_FOG);
|
GL11.glEnable(GL11.GL_FOG);
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
|
@ -430,7 +448,7 @@ public class EntityRenderer {
|
||||||
var3.func_951_a(var2.getPosition(var1), var12, var1);
|
var3.func_951_a(var2.getPosition(var1), var12, var1);
|
||||||
var4.func_1187_b(var2, var1);
|
var4.func_1187_b(var2, var1);
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
this.func_4140_a(0);
|
this.setupFog(0, var1);
|
||||||
var4.func_1189_a(var2, var1);
|
var4.func_1189_a(var2, var1);
|
||||||
if(this.mc.objectMouseOver != null && var2.isInsideOfMaterial(Material.water)) {
|
if(this.mc.objectMouseOver != null && var2.isInsideOfMaterial(Material.water)) {
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
@ -440,7 +458,7 @@ public class EntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
this.func_4140_a(0);
|
this.setupFog(0, var1);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
|
||||||
|
@ -449,7 +467,7 @@ public class EntityRenderer {
|
||||||
GL11.glDepthMask(true);
|
GL11.glDepthMask(true);
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
if(this.mc.objectMouseOver != null && !var2.isInsideOfMaterial(Material.water)) {
|
if(this.cameraZoom == 1.0D && this.mc.objectMouseOver != null && !var2.isInsideOfMaterial(Material.water)) {
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
var3.func_959_a(var2, this.mc.objectMouseOver, 0, var2.inventory.getCurrentItem(), var1);
|
var3.func_959_a(var2, this.mc.objectMouseOver, 0, var2.inventory.getCurrentItem(), var1);
|
||||||
var3.drawSelectionBox(var2, this.mc.objectMouseOver, 0, var2.inventory.getCurrentItem(), var1);
|
var3.drawSelectionBox(var2, this.mc.objectMouseOver, 0, var2.inventory.getCurrentItem(), var1);
|
||||||
|
@ -460,13 +478,15 @@ public class EntityRenderer {
|
||||||
if(this.field_1385_k != null) {
|
if(this.field_1385_k != null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.func_4140_a(0);
|
this.setupFog(0, var1);
|
||||||
GL11.glEnable(GL11.GL_FOG);
|
GL11.glEnable(GL11.GL_FOG);
|
||||||
var3.func_4141_b(var1);
|
var3.func_4141_b(var1);
|
||||||
GL11.glDisable(GL11.GL_FOG);
|
GL11.glDisable(GL11.GL_FOG);
|
||||||
this.func_4140_a(1);
|
this.setupFog(1, var1);
|
||||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
if(this.cameraZoom == 1.0D) {
|
||||||
this.func_4135_b(var1, var11);
|
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||||
|
this.func_4135_b(var1, var11);
|
||||||
|
}
|
||||||
if(!this.mc.gameSettings.anaglyph) {
|
if(!this.mc.gameSettings.anaglyph) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -515,6 +535,51 @@ public class EntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFogColor(float var1) {
|
private void updateFogColor(float var1) {
|
||||||
|
// World var2 = this.mc.theWorld;
|
||||||
|
// EntityPlayerSP var3 = this.mc.thePlayer;
|
||||||
|
// float var4 = 1.0F / (float)(4 - this.mc.gameSettings.renderDistance);
|
||||||
|
// var4 = 1.0F - (float)Math.pow((double)var4, 0.25D);
|
||||||
|
// Vec3D var5 = var2.func_4079_a(this.mc.thePlayer, var1);
|
||||||
|
// float var6 = (float)var5.xCoord;
|
||||||
|
// float var7 = (float)var5.yCoord;
|
||||||
|
// float var8 = (float)var5.zCoord;
|
||||||
|
// Vec3D var9 = var2.func_4082_d(var1);
|
||||||
|
// this.fogColorRed = (float)var9.xCoord;
|
||||||
|
// this.fogColorGreen = (float)var9.yCoord;
|
||||||
|
// this.fogColorBlue = (float)var9.zCoord;
|
||||||
|
// this.fogColorRed += (var6 - this.fogColorRed) * var4;
|
||||||
|
// this.fogColorGreen += (var7 - this.fogColorGreen) * var4;
|
||||||
|
// this.fogColorBlue += (var8 - this.fogColorBlue) * var4;
|
||||||
|
//
|
||||||
|
// if(this.cloudFog) {
|
||||||
|
// Vec3D var16 = var2.func_628_d(var1);
|
||||||
|
// this.fogColorRed = (float)var16.xCoord;
|
||||||
|
// this.fogColorGreen = (float)var16.yCoord;
|
||||||
|
// this.fogColorBlue = (float)var16.zCoord;
|
||||||
|
// } else if(var3.isInsideOfMaterial(Material.water)) {
|
||||||
|
// this.fogColorRed = 0.02F;
|
||||||
|
// this.fogColorGreen = 0.02F;
|
||||||
|
// this.fogColorBlue = 0.2F;
|
||||||
|
// } else if(var3.isInsideOfMaterial(Material.lava)) {
|
||||||
|
// this.fogColorRed = 0.6F;
|
||||||
|
// this.fogColorGreen = 0.1F;
|
||||||
|
// this.fogColorBlue = 0.0F;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// float var10 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * var1;
|
||||||
|
// this.fogColorRed *= var10;
|
||||||
|
// this.fogColorGreen *= var10;
|
||||||
|
// this.fogColorBlue *= var10;
|
||||||
|
// if(this.mc.gameSettings.anaglyph) {
|
||||||
|
// float var11 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F;
|
||||||
|
// float var12 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F;
|
||||||
|
// float var13 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F;
|
||||||
|
// this.fogColorRed = var11;
|
||||||
|
// this.fogColorGreen = var12;
|
||||||
|
// this.fogColorBlue = var13;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F);
|
||||||
World var2 = this.mc.theWorld;
|
World var2 = this.mc.theWorld;
|
||||||
EntityPlayerSP var3 = this.mc.thePlayer;
|
EntityPlayerSP var3 = this.mc.thePlayer;
|
||||||
float var4 = 1.0F / (float)(4 - this.mc.gameSettings.renderDistance);
|
float var4 = 1.0F / (float)(4 - this.mc.gameSettings.renderDistance);
|
||||||
|
@ -524,78 +589,95 @@ public class EntityRenderer {
|
||||||
float var7 = (float)var5.yCoord;
|
float var7 = (float)var5.yCoord;
|
||||||
float var8 = (float)var5.zCoord;
|
float var8 = (float)var5.zCoord;
|
||||||
Vec3D var9 = var2.func_4082_d(var1);
|
Vec3D var9 = var2.func_4082_d(var1);
|
||||||
this.field_4270_e = (float)var9.xCoord;
|
this.fogColorRed = (float)var9.xCoord;
|
||||||
this.field_4269_f = (float)var9.yCoord;
|
this.fogColorGreen = (float)var9.yCoord;
|
||||||
this.field_4268_g = (float)var9.zCoord;
|
this.fogColorBlue = (float)var9.zCoord;
|
||||||
this.field_4270_e += (var6 - this.field_4270_e) * var4;
|
this.fogColorRed += (var6 - this.fogColorRed) * var4;
|
||||||
this.field_4269_f += (var7 - this.field_4269_f) * var4;
|
this.fogColorGreen += (var7 - this.fogColorGreen) * var4;
|
||||||
this.field_4268_g += (var8 - this.field_4268_g) * var4;
|
this.fogColorBlue += (var8 - this.fogColorBlue) * var4;
|
||||||
if(var3.isInsideOfMaterial(Material.water)) {
|
|
||||||
this.field_4270_e = 0.02F;
|
if(this.cloudFog) {
|
||||||
this.field_4269_f = 0.02F;
|
Vec3D var16 = var2.func_628_d(var1);
|
||||||
this.field_4268_g = 0.2F;
|
this.fogColorRed = (float)var16.xCoord;
|
||||||
|
this.fogColorGreen = (float)var16.yCoord;
|
||||||
|
this.fogColorBlue = (float)var16.zCoord;
|
||||||
|
} else if(var3.isInsideOfMaterial(Material.water)) {
|
||||||
|
this.fogColorRed = 0.02F;
|
||||||
|
this.fogColorGreen = 0.02F;
|
||||||
|
this.fogColorBlue = 0.2F;
|
||||||
} else if(var3.isInsideOfMaterial(Material.lava)) {
|
} else if(var3.isInsideOfMaterial(Material.lava)) {
|
||||||
this.field_4270_e = 0.6F;
|
this.fogColorRed = 0.6F;
|
||||||
this.field_4269_f = 0.1F;
|
this.fogColorGreen = 0.1F;
|
||||||
this.field_4268_g = 0.0F;
|
this.fogColorBlue = 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
float var10 = this.field_1382_n + (this.field_1381_o - this.field_1382_n) * var1;
|
float var12 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * var1;
|
||||||
this.field_4270_e *= var10;
|
this.fogColorRed *= var12;
|
||||||
this.field_4269_f *= var10;
|
this.fogColorGreen *= var12;
|
||||||
this.field_4268_g *= var10;
|
this.fogColorBlue *= var12;
|
||||||
if(this.mc.gameSettings.anaglyph) {
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
float var11 = (this.field_4270_e * 30.0F + this.field_4269_f * 59.0F + this.field_4268_g * 11.0F) / 100.0F;
|
float var13 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F;
|
||||||
float var12 = (this.field_4270_e * 30.0F + this.field_4269_f * 70.0F) / 100.0F;
|
float var14 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F;
|
||||||
float var13 = (this.field_4270_e * 30.0F + this.field_4268_g * 70.0F) / 100.0F;
|
float var15 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F;
|
||||||
this.field_4270_e = var11;
|
this.fogColorRed = var13;
|
||||||
this.field_4269_f = var12;
|
this.fogColorGreen = var14;
|
||||||
this.field_4268_g = var13;
|
this.fogColorBlue = var15;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glClearColor(this.field_4270_e, this.field_4269_f, this.field_4268_g, 0.0F);
|
GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void func_4140_a(int var1) {
|
private void setupFog(int var1, float var2) {
|
||||||
EntityPlayerSP var2 = this.mc.thePlayer;
|
EntityPlayerSP var3 = this.mc.thePlayer;
|
||||||
GL11.glFog(GL11.GL_FOG_COLOR, this.func_908_a(this.field_4270_e, this.field_4269_f, this.field_4268_g, 1.0F));
|
GL11.glFog(GL11.GL_FOG_COLOR, this.func_908_a(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));
|
||||||
GL11.glNormal3f(0.0F, -1.0F, 0.0F);
|
GL11.glNormal3f(0.0F, -1.0F, 0.0F);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
float var3;
|
|
||||||
float var4;
|
float var4;
|
||||||
float var5;
|
float var5;
|
||||||
float var6;
|
float var6;
|
||||||
float var7;
|
float var7;
|
||||||
float var8;
|
float var8;
|
||||||
if(var2.isInsideOfMaterial(Material.water)) {
|
float var9;
|
||||||
|
if(this.cloudFog) {
|
||||||
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
|
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
|
||||||
GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F);
|
GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F);
|
||||||
var3 = 0.4F;
|
var4 = 1.0F;
|
||||||
var4 = 0.4F;
|
var5 = 1.0F;
|
||||||
var5 = 0.9F;
|
var6 = 1.0F;
|
||||||
if(this.mc.gameSettings.anaglyph) {
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
var6 = (var3 * 30.0F + var4 * 59.0F + var5 * 11.0F) / 100.0F;
|
var7 = (var4 * 30.0F + var5 * 59.0F + var6 * 11.0F) / 100.0F;
|
||||||
var7 = (var3 * 30.0F + var4 * 70.0F) / 100.0F;
|
var8 = (var4 * 30.0F + var5 * 70.0F) / 100.0F;
|
||||||
var8 = (var3 * 30.0F + var5 * 70.0F) / 100.0F;
|
var9 = (var4 * 30.0F + var6 * 70.0F) / 100.0F;
|
||||||
}
|
}
|
||||||
} else if(var2.isInsideOfMaterial(Material.lava)) {
|
} else if(var3.isInsideOfMaterial(Material.water)) {
|
||||||
|
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
|
||||||
|
GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F);
|
||||||
|
var4 = 0.4F;
|
||||||
|
var5 = 0.4F;
|
||||||
|
var6 = 0.9F;
|
||||||
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
|
var7 = (var4 * 30.0F + var5 * 59.0F + var6 * 11.0F) / 100.0F;
|
||||||
|
var8 = (var4 * 30.0F + var5 * 70.0F) / 100.0F;
|
||||||
|
var9 = (var4 * 30.0F + var6 * 70.0F) / 100.0F;
|
||||||
|
}
|
||||||
|
} else if(var3.isInsideOfMaterial(Material.lava)) {
|
||||||
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
|
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
|
||||||
GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F);
|
GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F);
|
||||||
var3 = 0.4F;
|
var4 = 0.4F;
|
||||||
var4 = 0.3F;
|
|
||||||
var5 = 0.3F;
|
var5 = 0.3F;
|
||||||
|
var6 = 0.3F;
|
||||||
if(this.mc.gameSettings.anaglyph) {
|
if(this.mc.gameSettings.anaglyph) {
|
||||||
var6 = (var3 * 30.0F + var4 * 59.0F + var5 * 11.0F) / 100.0F;
|
var7 = (var4 * 30.0F + var5 * 59.0F + var6 * 11.0F) / 100.0F;
|
||||||
var7 = (var3 * 30.0F + var4 * 70.0F) / 100.0F;
|
var8 = (var4 * 30.0F + var5 * 70.0F) / 100.0F;
|
||||||
var8 = (var3 * 30.0F + var5 * 70.0F) / 100.0F;
|
var9 = (var4 * 30.0F + var6 * 70.0F) / 100.0F;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR);
|
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR);
|
||||||
GL11.glFogf(GL11.GL_FOG_START, this.field_1387_i * 0.25F);
|
GL11.glFogf(GL11.GL_FOG_START, this.farPlaneDistance * 0.25F);
|
||||||
GL11.glFogf(GL11.GL_FOG_END, this.field_1387_i);
|
GL11.glFogf(GL11.GL_FOG_END, this.farPlaneDistance);
|
||||||
if(var1 < 0) {
|
if(var1 < 0) {
|
||||||
GL11.glFogf(GL11.GL_FOG_START, 0.0F);
|
GL11.glFogf(GL11.GL_FOG_START, 0.0F);
|
||||||
GL11.glFogf(GL11.GL_FOG_END, this.field_1387_i * 0.8F);
|
GL11.glFogf(GL11.GL_FOG_END, this.farPlaneDistance * 0.8F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mc.theWorld.worldProvider.field_4220_c) {
|
if(this.mc.theWorld.worldProvider.field_4220_c) {
|
||||||
|
@ -608,9 +690,9 @@ public class EntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private FloatBuffer func_908_a(float var1, float var2, float var3, float var4) {
|
private FloatBuffer func_908_a(float var1, float var2, float var3, float var4) {
|
||||||
this.field_1392_d.clear();
|
this.fogColorBuffer.clear();
|
||||||
this.field_1392_d.put(var1).put(var2).put(var3).put(var4);
|
this.fogColorBuffer.put(var1).put(var2).put(var3).put(var4);
|
||||||
this.field_1392_d.flip();
|
this.fogColorBuffer.flip();
|
||||||
return this.field_1392_d;
|
return this.fogColorBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
|
||||||
|
|
||||||
public class FontRenderer {
|
public class FontRenderer {
|
||||||
|
|
||||||
public FontRenderer(GameSettings gamesettings, String s, RenderEngine renderengine) {
|
public FontRenderer(GameSettings gamesettings, String s, RenderEngine renderengine) {
|
||||||
charWidth = new int[256];
|
charWidth = new int[256];
|
||||||
fontTextureName = 0;
|
fontTextureName = 0;
|
||||||
EaglerImage bufferedimage = GL11.loadPNG(GL11.loadResourceBytes(s));
|
BufferedImage bufferedimage = GL11.EaglerAdapterImpl2.loadPNG(GL11.EaglerAdapterImpl2.loadResourceBytes(s));
|
||||||
int i = bufferedimage.w;
|
int i = bufferedimage.getWidth();
|
||||||
int j = bufferedimage.h;
|
int j = bufferedimage.getHeight();
|
||||||
int ai[] = bufferedimage.data();
|
int ai[] = bufferedimage.getData();
|
||||||
for (int k = 0; k < 256; k++) {
|
for (int k = 0; k < 256; k++) {
|
||||||
int l = k % 16;
|
int l = k % 16;
|
||||||
int k1 = k / 16;
|
int k1 = k / 16;
|
||||||
|
@ -167,7 +164,6 @@ public class FontRenderer {
|
||||||
private int charWidth[];
|
private int charWidth[];
|
||||||
public int fontTextureName;
|
public int fontTextureName;
|
||||||
private int fontDisplayLists;
|
private int fontDisplayLists;
|
||||||
private IntBuffer buffer;
|
|
||||||
|
|
||||||
public static final char formatChar = '\247';
|
public static final char formatChar = '\247';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
import net.PeytonPlayz585.input.Keyboard;
|
import net.PeytonPlayz585.input.Keyboard;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.PeytonPlayz585.storage.LocalStorageManager;
|
import net.PeytonPlayz585.storage.LocalStorageManager;
|
||||||
|
@ -33,10 +34,10 @@ public class GameSettings {
|
||||||
public KeyBinding keyBindInventory = new KeyBinding("Inventory", 23);
|
public KeyBinding keyBindInventory = new KeyBinding("Inventory", 23);
|
||||||
public KeyBinding keyBindDrop = new KeyBinding("Drop", 16);
|
public KeyBinding keyBindDrop = new KeyBinding("Drop", 16);
|
||||||
public KeyBinding keyBindChat = new KeyBinding("Chat", 20);
|
public KeyBinding keyBindChat = new KeyBinding("Chat", 20);
|
||||||
public KeyBinding keyBindToggleFog = new KeyBinding("Toggle fog", 33);
|
public KeyBinding keyBindFunction = new KeyBinding("Function", 33);
|
||||||
public KeyBinding keyBindSneak = new KeyBinding("Sneak", 42);
|
public KeyBinding keyBindSneak = new KeyBinding("Sneak", 42);
|
||||||
public KeyBinding keyBindZoom = new KeyBinding("Zoom", 46);
|
public KeyBinding keyBindZoom = new KeyBinding("Zoom", 46);
|
||||||
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindZoom};
|
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindFunction, this.keyBindZoom};
|
||||||
protected Minecraft mc;
|
protected Minecraft mc;
|
||||||
public int numberOfOptions = 10;
|
public int numberOfOptions = 10;
|
||||||
public int difficulty = 2;
|
public int difficulty = 2;
|
||||||
|
@ -134,7 +135,7 @@ public class GameSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] fileData = GL11.readFile("options.txt");
|
byte[] fileData = File.readFile("options.txt");
|
||||||
if(fileData == null) {
|
if(fileData == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,10 +272,10 @@ public class GameSettings {
|
||||||
|
|
||||||
var1.flush();
|
var1.flush();
|
||||||
byte[] fileData = byteArrayOutputStream.toByteArray();
|
byte[] fileData = byteArrayOutputStream.toByteArray();
|
||||||
GL11.writeFile("options.txt", fileData);
|
File.writeFile("options.txt", fileData);
|
||||||
|
|
||||||
var1.close();
|
var1.close();
|
||||||
LocalStorageManager.saveStorageG();
|
//LocalStorageManager.saveStorageG();
|
||||||
LocalStorageManager.saveStorageP();
|
//LocalStorageManager.saveStorageP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.awt.Color;
|
||||||
import net.PeytonPlayz585.input.Keyboard;
|
import net.PeytonPlayz585.input.Keyboard;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.PeytonPlayz585.opengl.GL12;
|
import net.PeytonPlayz585.opengl.GL12;
|
||||||
|
@ -143,14 +144,14 @@ public class GuiIngame extends Gui {
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||||
String var23;
|
String var23;
|
||||||
if((Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(4)) || this.mc.gameSettings.showFPS) {
|
if(Keyboard.isFunctionKeyDown(Minecraft.getMinecraft().gameSettings.keyBindFunction.keyCode, 4) || this.mc.gameSettings.showFPS) {
|
||||||
var8.drawStringWithShadow("Minecraft Alpha v1.2.6 (" + this.mc.field_6292_I + ")", 2, 2, 16777215);
|
var8.drawStringWithShadow("Minecraft Alpha v1.2.6 (" + this.mc.field_6292_I + ")", 2, 2, 16777215);
|
||||||
var8.drawStringWithShadow(this.mc.func_6241_m(), 2, 12, 16777215);
|
var8.drawStringWithShadow(this.mc.func_6241_m(), 2, 12, 16777215);
|
||||||
var8.drawStringWithShadow(this.mc.func_6262_n(), 2, 22, 16777215);
|
var8.drawStringWithShadow(this.mc.func_6262_n(), 2, 22, 16777215);
|
||||||
var8.drawStringWithShadow(this.mc.func_6245_o(), 2, 32, 16777215);
|
var8.drawStringWithShadow(this.mc.func_6245_o(), 2, 32, 16777215);
|
||||||
long var24 = GL11.maxMemory();
|
long var24 = GL11.EaglerAdapterImpl2.maxMemory();
|
||||||
long var29 = GL11.totalMemory();
|
long var29 = GL11.EaglerAdapterImpl2.totalMemory();
|
||||||
long var30 = GL11.freeMemory();
|
long var30 = GL11.EaglerAdapterImpl2.freeMemory();
|
||||||
long var21 = var29 - var30;
|
long var21 = var29 - var30;
|
||||||
var23 = "Used memory: " + var21 * 100L / var24 + "% (" + var21 / 1024L / 1024L + "MB) of " + var24 / 1024L / 1024L + "MB";
|
var23 = "Used memory: " + var21 * 100L / var24 + "% (" + var21 / 1024L / 1024L + "MB) of " + var24 / 1024L / 1024L + "MB";
|
||||||
this.drawString(var8, var23, var6 - var8.getStringWidth(var23) - 2, 2, 14737632);
|
this.drawString(var8, var23, var6 - var8.getStringWidth(var23) - 2, 2, 14737632);
|
||||||
|
@ -175,7 +176,7 @@ public class GuiIngame extends Gui {
|
||||||
GL11.glTranslatef((float)(var6 / 2), (float)(var7 - 48), 0.0F);
|
GL11.glTranslatef((float)(var6 / 2), (float)(var7 - 48), 0.0F);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
var17 = hsbToRgb(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
|
var17 = Color.HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
|
||||||
var8.drawString(this.field_9420_i, -var8.getStringWidth(this.field_9420_i) / 2, -4, var17 + (var16 << 24));
|
var8.drawString(this.field_9420_i, -var8.getStringWidth(this.field_9420_i) / 2, -4, var17 + (var16 << 24));
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
@ -364,48 +365,6 @@ public class GuiIngame extends Gui {
|
||||||
this.field_9419_j = 60;
|
this.field_9419_j = 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int hsbToRgb(float hue, float saturation, float brightness) {
|
|
||||||
hue = (hue % 1f) + 1f;
|
|
||||||
saturation = Math.min(1f, Math.max(0f, saturation));
|
|
||||||
brightness = Math.min(1f, Math.max(0f, brightness));
|
|
||||||
|
|
||||||
float q = brightness < 0.5f ? brightness * (1f + saturation) : brightness + saturation - brightness * saturation;
|
|
||||||
float p = 2f * brightness - q;
|
|
||||||
|
|
||||||
float r, g, b;
|
|
||||||
if (hue < 1f/6f) {
|
|
||||||
r = q;
|
|
||||||
g = p + (q - p) * 6f * hue;
|
|
||||||
b = p;
|
|
||||||
} else if (hue < 2f/6f) {
|
|
||||||
r = p - (q - p) * 6f * (hue - 1f/6f);
|
|
||||||
g = q;
|
|
||||||
b = p;
|
|
||||||
} else if (hue < 3f/6f) {
|
|
||||||
r = p;
|
|
||||||
g = q - (q - p) * 6f * (hue - 2f/6f);
|
|
||||||
b = p - (q - p) * 6f * (hue - 2f/6f);
|
|
||||||
} else if (hue < 4f/6f) {
|
|
||||||
r = p;
|
|
||||||
g = p;
|
|
||||||
b = q - (q - p) * 6f * (hue - 3f/6f);
|
|
||||||
} else if (hue < 5f/6f) {
|
|
||||||
r = p + (q - p) * 6f * (hue - 4f/6f);
|
|
||||||
g = p;
|
|
||||||
b = q;
|
|
||||||
} else {
|
|
||||||
r = q;
|
|
||||||
g = p - (q - p) * 6f * (hue - 5f/6f);
|
|
||||||
b = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
int red = (int) Math.max(0f, Math.min(255f, r * 255f));
|
|
||||||
int green = (int) Math.max(0f, Math.min(255f, g * 255f));
|
|
||||||
int blue = (int) Math.max(0f, Math.min(255f, b * 255f));
|
|
||||||
|
|
||||||
return (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderCrossHairs(int w, int h) {
|
public void renderCrossHairs(int w, int h) {
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/icons.png"));
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/icons.png"));
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class GuiMainMenu extends GuiScreen {
|
||||||
public GuiMainMenu() {
|
public GuiMainMenu() {
|
||||||
try {
|
try {
|
||||||
ArrayList var1 = new ArrayList();
|
ArrayList var1 = new ArrayList();
|
||||||
byte[] splash = GL11.loadResourceBytes("/title/splashes.txt");
|
byte[] splash = GL11.EaglerAdapterImpl2.loadResourceBytes("/title/splashes.txt");
|
||||||
BufferedReader var2 = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(splash)));
|
BufferedReader var2 = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(splash)));
|
||||||
String var3 = "";
|
String var3 = "";
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
import net.PeytonPlayz585.fileutils.FileChooserResult;
|
||||||
import net.PeytonPlayz585.input.Mouse;
|
import net.PeytonPlayz585.input.Mouse;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.lax1dude.eaglercraft.adapter.FileChooserResult;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class GuiTexturePacks extends GuiScreen {
|
public class GuiTexturePacks extends GuiScreen {
|
||||||
|
@ -34,7 +35,7 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
protected void actionPerformed(GuiButton var1) {
|
protected void actionPerformed(GuiButton var1) {
|
||||||
if(var1.enabled) {
|
if(var1.enabled) {
|
||||||
if(var1.id == 5) {
|
if(var1.id == 5) {
|
||||||
GL11.displayFileChooser("application/zip", "zip");
|
GL11.EaglerAdapterImpl2.displayFileChooser("application/zip", "zip");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(var1.id == 6) {
|
if(var1.id == 6) {
|
||||||
|
@ -190,13 +191,13 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
--this.field_6454_o;
|
--this.field_6454_o;
|
||||||
|
|
||||||
FileChooserResult packFile = null;
|
FileChooserResult packFile = null;
|
||||||
if (GL11.fileChooserHasResult()) {
|
if (GL11.EaglerAdapterImpl2.fileChooserHasResult()) {
|
||||||
packFile = GL11.getFileChooserResult();
|
packFile = GL11.EaglerAdapterImpl2.getFileChooserResult();
|
||||||
}
|
}
|
||||||
if(packFile == null) {
|
if(packFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GL11.writeFile("texturepacks/" + packFile.fileName, packFile.fileData);
|
File.writeFile("texturepacks/" + packFile.fileName, packFile.fileData);
|
||||||
Minecraft.getMinecraft().displayGuiScreen(new GuiTexturePacks(field_6461_a));
|
Minecraft.getMinecraft().displayGuiScreen(new GuiTexturePacks(field_6461_a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.opengl.Display;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ public class LoadingScreenRenderer implements IProgressUpdate {
|
||||||
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(this.field_1007_c, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1007_c)) / 2, var6 / 2 - 4 - 16, 16777215);
|
this.mc.fontRenderer.drawStringWithShadow(this.field_1007_c, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1007_c)) / 2, var6 / 2 - 4 - 16, 16777215);
|
||||||
this.mc.fontRenderer.drawStringWithShadow(this.field_1004_a, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1004_a)) / 2, var6 / 2 - 4 + 8, 16777215);
|
this.mc.fontRenderer.drawStringWithShadow(this.field_1004_a, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1004_a)) / 2, var6 / 2 - 4 + 8, 16777215);
|
||||||
GL11.updateDisplay();
|
Display.update();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.awt.Color;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class MobSpawnerBase {
|
public class MobSpawnerBase {
|
||||||
|
@ -79,64 +80,9 @@ public class MobSpawnerBase {
|
||||||
var1 = 1.0F;
|
var1 = 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F);
|
return Color.getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F).getRGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getHSBColor(float hue, float saturation, float brightness) {
|
|
||||||
float r, g, b;
|
|
||||||
if (saturation == 0) {
|
|
||||||
r = g = b = brightness;
|
|
||||||
} else {
|
|
||||||
float h = (hue - (float) Math.floor(hue)) * 6.0f;
|
|
||||||
float f = h - (float) Math.floor(h);
|
|
||||||
float p = brightness * (1.0f - saturation);
|
|
||||||
float q = brightness * (1.0f - saturation * f);
|
|
||||||
float t = brightness * (1.0f - (saturation * (1.0f - f)));
|
|
||||||
|
|
||||||
int hi = (int) h;
|
|
||||||
switch (hi) {
|
|
||||||
case 0:
|
|
||||||
r = brightness;
|
|
||||||
g = t;
|
|
||||||
b = p;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
r = q;
|
|
||||||
g = brightness;
|
|
||||||
b = p;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
r = p;
|
|
||||||
g = brightness;
|
|
||||||
b = t;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
r = p;
|
|
||||||
g = q;
|
|
||||||
b = brightness;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
r = t;
|
|
||||||
g = p;
|
|
||||||
b = brightness;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
r = brightness;
|
|
||||||
g = p;
|
|
||||||
b = q;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
r = g = b = brightness;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int red = Math.round(r * 255);
|
|
||||||
int green = Math.round(g * 255);
|
|
||||||
int blue = Math.round(b * 255);
|
|
||||||
return (255 << 24) | (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getEntitiesForType(EnumCreatureType var1) {
|
public List getEntitiesForType(EnumCreatureType var1) {
|
||||||
if(var1 == EnumCreatureType.monster) {
|
if(var1 == EnumCreatureType.monster) {
|
||||||
if(this.biomeMonsters.isEmpty()) {
|
if(this.biomeMonsters.isEmpty()) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class NetworkManager {
|
||||||
}else {
|
}else {
|
||||||
throw new IOException("Invalid URI Protocol!");
|
throw new IOException("Invalid URI Protocol!");
|
||||||
}
|
}
|
||||||
if(!GL11.startConnection(var4)) {
|
if(!GL11.EaglerAdapterImpl2.startConnection(var4)) {
|
||||||
throw new IOException("Websocket to " + uri + " failed!");
|
throw new IOException("Websocket to " + uri + " failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class NetworkManager {
|
||||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||||
Packet.writePacket(var2, yee);
|
Packet.writePacket(var2, yee);
|
||||||
yee.flush();
|
yee.flush();
|
||||||
GL11.writePacket(sendBuffer.toByteArray());
|
GL11.EaglerAdapterImpl2.writePacket(sendBuffer.toByteArray());
|
||||||
sendBuffer.flush();
|
sendBuffer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class NetworkManager {
|
||||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||||
Packet.writePacket(var2, yee);
|
Packet.writePacket(var2, yee);
|
||||||
yee.flush();
|
yee.flush();
|
||||||
GL11.writePacket(sendBuffer.toByteArray());
|
GL11.EaglerAdapterImpl2.writePacket(sendBuffer.toByteArray());
|
||||||
sendBuffer.flush();
|
sendBuffer.flush();
|
||||||
this.chunkDataSendCounter = 50;
|
this.chunkDataSendCounter = 50;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class NetworkManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] packet;
|
byte[] packet;
|
||||||
while((packet = GL11.readPacket()) != null) {
|
while((packet = GL11.EaglerAdapterImpl2.readPacket()) != null) {
|
||||||
readChunks.add(ByteBuffer.wrap(packet));
|
readChunks.add(ByteBuffer.wrap(packet));
|
||||||
}
|
}
|
||||||
if(!readChunks.isEmpty()) {
|
if(!readChunks.isEmpty()) {
|
||||||
|
@ -201,8 +201,8 @@ public class NetworkManager {
|
||||||
this.isTerminating = true;
|
this.isTerminating = true;
|
||||||
this.terminationReason = var1;
|
this.terminationReason = var1;
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
if(GL11.connectionOpen()) {
|
if(GL11.EaglerAdapterImpl2.connectionOpen()) {
|
||||||
GL11.endConnection();
|
GL11.EaglerAdapterImpl2.endConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ public class NetworkManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isConnectionOpen() {
|
static boolean isConnectionOpen() {
|
||||||
return GL11.connectionOpen();
|
return GL11.EaglerAdapterImpl2.connectionOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isServerTerminating(NetworkManager var0) {
|
static boolean isServerTerminating(NetworkManager var0) {
|
||||||
|
|
|
@ -7,15 +7,15 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
|
||||||
|
|
||||||
public class RenderEngine {
|
public class RenderEngine {
|
||||||
|
|
||||||
public RenderEngine(TexturePackList var1, GameSettings gamesettings) {
|
public RenderEngine(TexturePackList var1, GameSettings gamesettings) {
|
||||||
field_6527_k = var1;
|
field_6527_k = var1;
|
||||||
textureMap = new HashMap<String, Integer>();
|
textureMap = new HashMap<String, Integer>();
|
||||||
textureNameToImageMap = new HashMap<Integer, EaglerImage>();
|
textureNameToImageMap = new HashMap<Integer, BufferedImage>();
|
||||||
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
|
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
|
||||||
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
|
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
|
||||||
textureList = new ArrayList<TextureFX>();
|
textureList = new ArrayList<TextureFX>();
|
||||||
|
@ -55,7 +55,7 @@ public class RenderEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int allocateAndSetupTexture(EaglerImage bufferedimage) {
|
public int allocateAndSetupTexture(BufferedImage bufferedimage) {
|
||||||
singleIntBuffer.clear();
|
singleIntBuffer.clear();
|
||||||
GLAllocation.generateTextureNames(singleIntBuffer);
|
GLAllocation.generateTextureNames(singleIntBuffer);
|
||||||
int i = singleIntBuffer.get(0);
|
int i = singleIntBuffer.get(0);
|
||||||
|
@ -79,7 +79,7 @@ public class RenderEngine {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupTexture(EaglerImage bufferedimage, int i) {
|
public void setupTexture(BufferedImage bufferedimage, int i) {
|
||||||
bindTexture(i);
|
bindTexture(i);
|
||||||
if (useMipmaps) {
|
if (useMipmaps) {
|
||||||
GL11.glTexParameteri(3553, 10241, GL11.GL_NEAREST_MIPMAP_LINEAR);
|
GL11.glTexParameteri(3553, 10241, GL11.GL_NEAREST_MIPMAP_LINEAR);
|
||||||
|
@ -90,15 +90,15 @@ public class RenderEngine {
|
||||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
|
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
|
||||||
}
|
}
|
||||||
if (clampTexture) {
|
if (clampTexture) {
|
||||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10496 /* GL_CLAMP */);
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
|
||||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10496 /* GL_CLAMP */);
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
|
||||||
} else {
|
} else {
|
||||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
|
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
|
||||||
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
|
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
|
||||||
}
|
}
|
||||||
int j = bufferedimage.w;
|
int j = bufferedimage.getWidth();
|
||||||
int k = bufferedimage.h;
|
int k = bufferedimage.getHeight();
|
||||||
int ai[] = bufferedimage.data();
|
int ai[] = bufferedimage.getData();
|
||||||
byte abyte0[] = new byte[j * k * 4];
|
byte abyte0[] = new byte[j * k * 4];
|
||||||
for (int l = 0; l < ai.length; l++) {
|
for (int l = 0; l < ai.length; l++) {
|
||||||
int j1 = ai[l] >> 24 & 0xff;
|
int j1 = ai[l] >> 24 & 0xff;
|
||||||
|
@ -140,8 +140,8 @@ public class RenderEngine {
|
||||||
texturefx.func_783_a();
|
texturefx.func_783_a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EaglerImage readTextureImage(byte[] inputstream) throws IOException {
|
public BufferedImage readTextureImage(byte[] inputstream) throws IOException {
|
||||||
return GL11.loadPNG(inputstream);
|
return GL11.EaglerAdapterImpl2.loadPNG(inputstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindTexture(int i) {
|
public void bindTexture(int i) {
|
||||||
|
@ -177,10 +177,10 @@ public class RenderEngine {
|
||||||
TexturePackBase var1 = this.field_6527_k.selectedTexturePack;
|
TexturePackBase var1 = this.field_6527_k.selectedTexturePack;
|
||||||
Iterator var2 = this.textureNameToImageMap.keySet().iterator();
|
Iterator var2 = this.textureNameToImageMap.keySet().iterator();
|
||||||
|
|
||||||
EaglerImage var4;
|
BufferedImage var4;
|
||||||
while(var2.hasNext()) {
|
while(var2.hasNext()) {
|
||||||
int var3 = ((Integer)var2.next()).intValue();
|
int var3 = ((Integer)var2.next()).intValue();
|
||||||
var4 = (EaglerImage)this.textureNameToImageMap.get(Integer.valueOf(var3));
|
var4 = (BufferedImage)this.textureNameToImageMap.get(Integer.valueOf(var3));
|
||||||
this.setupTexture(var4, var3);
|
this.setupTexture(var4, var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class RenderEngine {
|
||||||
public static boolean useMipmaps = false;
|
public static boolean useMipmaps = false;
|
||||||
private static HashMap<String, Integer> textureMap;
|
private static HashMap<String, Integer> textureMap;
|
||||||
private TexturePackList field_6527_k;
|
private TexturePackList field_6527_k;
|
||||||
private HashMap<Integer, EaglerImage> textureNameToImageMap;
|
private HashMap<Integer, BufferedImage> textureNameToImageMap;
|
||||||
public IntBuffer singleIntBuffer;
|
public IntBuffer singleIntBuffer;
|
||||||
private ByteBuffer imageDataB1;
|
private ByteBuffer imageDataB1;
|
||||||
private java.util.List<TextureFX> textureList;
|
private java.util.List<TextureFX> textureList;
|
||||||
|
|
|
@ -1024,4 +1024,8 @@ public class RenderGlobal implements IWorldAccess {
|
||||||
|
|
||||||
public void func_935_a(int var1, int var2, int var3, TileEntity var4) {
|
public void func_935_a(int var1, int var2, int var3, TileEntity var4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean func_27307_a(double var1, double var3, double var5, float var7) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,40 +1,50 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class RenderHelper {
|
public class RenderHelper {
|
||||||
|
private static FloatBuffer field_1695_a = GLAllocation.createDirectFloatBuffer(16);
|
||||||
|
|
||||||
public static void disableStandardItemLighting() {
|
public static void disableStandardItemLighting() {
|
||||||
GL11.glDisable(2896);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
GL11.glDisable(16384);
|
GL11.glDisable(GL11.GL_LIGHT0);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHT1);
|
||||||
|
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enableStandardItemLighting2() {
|
|
||||||
GL11.glEnable(2896);
|
|
||||||
GL11.glEnable(16384);
|
|
||||||
GL11.glEnable(16385);
|
|
||||||
GL11.glEnable(2903);
|
|
||||||
GL11.glColorMaterial(1032, 5634);
|
|
||||||
GL11.copyModelToLightMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void enableStandardItemLighting() {
|
public static void enableStandardItemLighting() {
|
||||||
GL11.glPushMatrix();
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHT0);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHT1);
|
||||||
|
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||||
|
GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
|
||||||
float var0 = 0.4F;
|
float var0 = 0.4F;
|
||||||
float var1 = 0.6F;
|
float var1 = 0.6F;
|
||||||
float var2 = 0.0F;
|
float var2 = 0.0F;
|
||||||
Vec3D var3 = Vec3D.createVector((double)0.2F, 1.0D, (double)-0.7F).normalize();
|
Vec3D var3 = Vec3D.createVector((double)0.2F, 1.0D, (double)-0.7F).normalize();
|
||||||
GL11.glRotatef((float)var3.xCoord, (float)var3.yCoord, (float)var3.zCoord, 0.0F);
|
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, func_1157_a(var3.xCoord, var3.yCoord, var3.zCoord, 0.0D));
|
||||||
GL11.glRotatef(var1, var1, var1, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, func_1156_a(var1, var1, var1, 1.0F));
|
||||||
GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, func_1156_a(0.0F, 0.0F, 0.0F, 1.0F));
|
||||||
GL11.glRotatef(var2, var2, var2, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, func_1156_a(var2, var2, var2, 1.0F));
|
||||||
GL11.glRotatef(var2, var0, var1, var2);
|
|
||||||
var3 = Vec3D.createVector((double)-0.2F, 1.0D, (double)0.7F).normalize();
|
var3 = Vec3D.createVector((double)-0.2F, 1.0D, (double)0.7F).normalize();
|
||||||
GL11.glRotatef((float)var3.xCoord, (float)var3.yCoord, (float)var3.zCoord, 0.0F);
|
GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, func_1157_a(var3.xCoord, var3.yCoord, var3.zCoord, 0.0D));
|
||||||
GL11.glRotatef(var1, var1, var1, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, func_1156_a(var1, var1, var1, 1.0F));
|
||||||
GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, func_1156_a(0.0F, 0.0F, 0.0F, 1.0F));
|
||||||
GL11.glRotatef(var2, var2, var2, 1.0F);
|
GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, func_1156_a(var2, var2, var2, 1.0F));
|
||||||
enableStandardItemLighting2();
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
GL11.glPopMatrix();
|
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, func_1156_a(var0, var0, var0, 1.0F));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private static FloatBuffer func_1157_a(double var0, double var2, double var4, double var6) {
|
||||||
|
return func_1156_a((float)var0, (float)var2, (float)var4, (float)var6);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static FloatBuffer func_1156_a(float var0, float var1, float var2, float var3) {
|
||||||
|
field_1695_a.clear();
|
||||||
|
field_1695_a.put(var0).put(var1).put(var2).put(var3);
|
||||||
|
field_1695_a.flip();
|
||||||
|
return field_1695_a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import java.io.IOException;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
|
||||||
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class TextureCompassFX extends TextureFX {
|
public class TextureCompassFX extends TextureFX {
|
||||||
|
@ -16,13 +18,14 @@ public class TextureCompassFX extends TextureFX {
|
||||||
this.field_1128_f = 1;
|
this.field_1128_f = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EaglerImage var2 = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png"));
|
BufferedImage var2 = ImageIO.read(ImageIO.getResource("/gui/items.png"));
|
||||||
int var3 = this.field_1126_b % 16 * 16;
|
int var3 = this.field_1126_b % 16 * 16;
|
||||||
int var4 = this.field_1126_b / 16 * 16;
|
int var4 = this.field_1126_b / 16 * 16;
|
||||||
var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
|
var2.getRGB(var3, var4, 16, 16, this.field_4230_h, 0, 16);
|
||||||
} catch (Exception var5) {
|
} catch (IOException var5) {
|
||||||
var5.printStackTrace();
|
var5.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_783_a() {
|
public void func_783_a() {
|
||||||
|
|
|
@ -27,6 +27,6 @@ public abstract class TexturePackBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] func_6481_a(String s) {
|
public byte[] func_6481_a(String s) {
|
||||||
return GL11.loadResourceBytes(s);
|
return GL11.EaglerAdapterImpl2.loadResourceBytes(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.util.Collection;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deleteExistingTexturePackFiles();
|
deleteExistingTexturePackFiles();
|
||||||
byte[] data = GL11.readFile("texturepacks/" + s);
|
byte[] data = File.readFile("texturepacks/" + s);
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||||
ZipInputStream zis = new ZipInputStream(bais);
|
ZipInputStream zis = new ZipInputStream(bais);
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
if(name.startsWith("/")) {
|
if(name.startsWith("/")) {
|
||||||
name = name.substring(1, name.length() - 1);
|
name = name.substring(1, name.length() - 1);
|
||||||
}
|
}
|
||||||
GL11.writeFile("texturepackdata/" + name.replace(" ", ""), fileData);
|
File.writeFile("texturepackdata/" + name.replace(" ", ""), fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
zis.closeEntry();
|
zis.closeEntry();
|
||||||
|
@ -61,7 +63,7 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
|
|
||||||
public void func_6485_a(Minecraft var1) throws IOException {
|
public void func_6485_a(Minecraft var1) throws IOException {
|
||||||
try {
|
try {
|
||||||
byte[] data = GL11.readFile("texturepackdata/pack.txt");
|
byte[] data = File.readFile("texturepackdata/pack.txt");
|
||||||
InputStream var3 = new ByteArrayInputStream(data);
|
InputStream var3 = new ByteArrayInputStream(data);
|
||||||
BufferedReader var4 = new BufferedReader(new InputStreamReader(var3));
|
BufferedReader var4 = new BufferedReader(new InputStreamReader(var3));
|
||||||
this.firstDescriptionLine = this.func_6492_b(var4.readLine());
|
this.firstDescriptionLine = this.func_6492_b(var4.readLine());
|
||||||
|
@ -76,7 +78,7 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
int packPNG = -1;
|
int packPNG = -1;
|
||||||
|
|
||||||
public void func_6483_c(Minecraft var1) {
|
public void func_6483_c(Minecraft var1) {
|
||||||
byte[] data = GL11.readFile("texturepackdata/pack.png");
|
byte[] data = File.readFile("texturepackdata/pack.png");
|
||||||
if(data != null) {
|
if(data != null) {
|
||||||
if(packPNG == -1) {
|
if(packPNG == -1) {
|
||||||
packPNG = getTexture("pack.png");
|
packPNG = getTexture("pack.png");
|
||||||
|
@ -90,7 +92,7 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
|
|
||||||
private int getTexture(String s) {
|
private int getTexture(String s) {
|
||||||
try {
|
try {
|
||||||
byte[] b = GL11.readFile("texturepackdata/" + s);
|
byte[] b = File.readFile("texturepackdata/" + s);
|
||||||
Minecraft.getMinecraft().renderEngine.singleIntBuffer.clear();
|
Minecraft.getMinecraft().renderEngine.singleIntBuffer.clear();
|
||||||
GLAllocation.generateTextureNames(Minecraft.getMinecraft().renderEngine.singleIntBuffer);
|
GLAllocation.generateTextureNames(Minecraft.getMinecraft().renderEngine.singleIntBuffer);
|
||||||
int i = Minecraft.getMinecraft().renderEngine.singleIntBuffer.get(0);
|
int i = Minecraft.getMinecraft().renderEngine.singleIntBuffer.get(0);
|
||||||
|
@ -107,10 +109,10 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
path = path.substring(1);
|
path = path.substring(1);
|
||||||
}
|
}
|
||||||
System.out.println(path);
|
System.out.println(path);
|
||||||
byte[] data = GL11.readFile("texturepackdata/" + path.replace(" ", ""));
|
byte[] data = File.readFile("texturepackdata/" + path.replace(" ", ""));
|
||||||
|
|
||||||
if(data == null) {
|
if(data == null) {
|
||||||
return GL11.loadResourceBytes(var1);
|
return GL11.EaglerAdapterImpl2.loadResourceBytes(var1);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Texture Found in texture pack: " + path);
|
System.out.println("Texture Found in texture pack: " + path);
|
||||||
|
@ -119,17 +121,17 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
|
|
||||||
private void deleteExistingTexturePackFiles() {
|
private void deleteExistingTexturePackFiles() {
|
||||||
String path = "texturepackdata/";
|
String path = "texturepackdata/";
|
||||||
Collection<GL11.FileEntry> lst = GL11.listFiles(path, true, true);
|
Collection<FileEntry> lst = File.listFiles(path, true, true);
|
||||||
for(GL11.FileEntry t : lst) {
|
for(FileEntry t : lst) {
|
||||||
if(!t.isDirectory) {
|
if(!t.isDirectory) {
|
||||||
GL11.deleteFile(t.path);
|
File.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(GL11.FileEntry t : lst) {
|
for(FileEntry t : lst) {
|
||||||
if(t.isDirectory) {
|
if(t.isDirectory) {
|
||||||
GL11.deleteFile(t.path);
|
File.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GL11.deleteFile(path);
|
File.deleteFile(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,9 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class TexturePackList {
|
public class TexturePackList {
|
||||||
|
@ -46,7 +47,7 @@ public class TexturePackList {
|
||||||
this.selectedTexturePack = null;
|
this.selectedTexturePack = null;
|
||||||
var1.add(this.defaultTexturePack);
|
var1.add(this.defaultTexturePack);
|
||||||
|
|
||||||
Collection<FileEntry> var2 = GL11.listFiles("texturepacks/", false, false);
|
Collection<FileEntry> var2 = File.listFiles("texturepacks/", false, false);
|
||||||
Collection<FileEntry> var3 = var2;
|
Collection<FileEntry> var3 = var2;
|
||||||
int var4 = var2.size();
|
int var4 = var2.size();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import java.io.IOException;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
|
||||||
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class TextureWatchFX extends TextureFX {
|
public class TextureWatchFX extends TextureFX {
|
||||||
|
@ -17,13 +19,13 @@ public class TextureWatchFX extends TextureFX {
|
||||||
this.field_1128_f = 1;
|
this.field_1128_f = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EaglerImage var2 = GL11.loadPNG(GL11.loadResourceBytes("/gui/items.png"));
|
BufferedImage var2 = ImageIO.read(ImageIO.getResource("/gui/items.png"));
|
||||||
int var3 = this.field_1126_b % 16 * 16;
|
int var3 = this.field_1126_b % 16 * 16;
|
||||||
int var4 = this.field_1126_b / 16 * 16;
|
int var4 = this.field_1126_b / 16 * 16;
|
||||||
var2.getRGB(var3, var4, 16, 16, this.field_4224_h, 0, 16);
|
var2.getRGB(var3, var4, 16, 16, this.field_4224_h, 0, 16);
|
||||||
var2 = GL11.loadPNG(GL11.loadResourceBytes("/misc/dial.png"));
|
var2 = ImageIO.read(ImageIO.getResource("/misc/dial.png"));
|
||||||
var2.getRGB(0, 0, 16, 16, this.field_4223_i, 0, 16);
|
var2.getRGB(0, 0, 16, 16, this.field_4223_i, 0, 16);
|
||||||
} catch (Exception var5) {
|
} catch (IOException var5) {
|
||||||
var5.printStackTrace();
|
var5.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class World implements IBlockAccess {
|
public class World implements IBlockAccess {
|
||||||
|
@ -67,11 +69,11 @@ public class World implements IBlockAccess {
|
||||||
return net.PeytonPlayz585.minecraft.World.func_629_a(var1);
|
return net.PeytonPlayz585.minecraft.World.func_629_a(var1);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = GL11.readFile("saves/" + var1 + "/level.dat");
|
byte[] data = File.readFile("saves/" + var1 + "/level.dat");
|
||||||
if(!(data == null)) {
|
if(!(data == null)) {
|
||||||
try {
|
try {
|
||||||
NBTTagCompound var5;
|
NBTTagCompound var5;
|
||||||
if(GL11.isCompressed(data)) {
|
if(File.isCompressed(data)) {
|
||||||
var5 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
var5 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
||||||
} else {
|
} else {
|
||||||
var5 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
var5 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
||||||
|
@ -92,18 +94,18 @@ public class World implements IBlockAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
String path = "saves/" + var1 + "/";
|
String path = "saves/" + var1 + "/";
|
||||||
Collection<GL11.FileEntry> lst = GL11.listFiles(path, true, true);
|
Collection<FileEntry> lst = File.listFiles(path, true, true);
|
||||||
for(GL11.FileEntry t : lst) {
|
for(FileEntry t : lst) {
|
||||||
if(!t.isDirectory) {
|
if(!t.isDirectory) {
|
||||||
GL11.deleteFile(t.path);
|
File.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(GL11.FileEntry t : lst) {
|
for(FileEntry t : lst) {
|
||||||
if(t.isDirectory) {
|
if(t.isDirectory) {
|
||||||
GL11.deleteFile(t.path);
|
File.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GL11.deleteFile(path);
|
File.deleteFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldChunkManager func_4075_a() {
|
public WorldChunkManager func_4075_a() {
|
||||||
|
@ -248,7 +250,7 @@ public class World implements IBlockAccess {
|
||||||
} finally {
|
} finally {
|
||||||
if(GL11.isWebGL) {
|
if(GL11.isWebGL) {
|
||||||
var7.flush();
|
var7.flush();
|
||||||
GL11.writeFile(this.field_9432_t + "/session.lock", data.toByteArray());
|
File.writeFile(this.field_9432_t + "/session.lock", data.toByteArray());
|
||||||
}
|
}
|
||||||
var7.close();
|
var7.close();
|
||||||
}
|
}
|
||||||
|
@ -265,7 +267,7 @@ public class World implements IBlockAccess {
|
||||||
this.field_1033_r = !net.PeytonPlayz585.minecraft.World.doesLevelExist(this.field_9432_t);
|
this.field_1033_r = !net.PeytonPlayz585.minecraft.World.doesLevelExist(this.field_9432_t);
|
||||||
exists = net.PeytonPlayz585.minecraft.World.doesLevelExist(this.field_9432_t);
|
exists = net.PeytonPlayz585.minecraft.World.doesLevelExist(this.field_9432_t);
|
||||||
} else {
|
} else {
|
||||||
data = GL11.readFile(var18);
|
data = File.readFile(var18);
|
||||||
this.field_1033_r = data == null;
|
this.field_1033_r = data == null;
|
||||||
exists = data != null;
|
exists = data != null;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +277,7 @@ public class World implements IBlockAccess {
|
||||||
if(!GL11.isWebGL) {
|
if(!GL11.isWebGL) {
|
||||||
var8 = net.PeytonPlayz585.minecraft.World.getNBTDataFromLevel(var18);
|
var8 = net.PeytonPlayz585.minecraft.World.getNBTDataFromLevel(var18);
|
||||||
} else {
|
} else {
|
||||||
if(GL11.isCompressed(data)) {
|
if(File.isCompressed(data)) {
|
||||||
var8 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
var8 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
||||||
} else {
|
} else {
|
||||||
var8 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
var8 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
||||||
|
@ -420,20 +422,20 @@ public class World implements IBlockAccess {
|
||||||
String var6 = field_9432_t + "/level.dat";
|
String var6 = field_9432_t + "/level.dat";
|
||||||
ByteArrayOutputStream data = new ByteArrayOutputStream();
|
ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(var3, data);
|
CompressedStreamTools.writeGzippedCompoundToOutputStream(var3, data);
|
||||||
GL11.writeFile(var4, data.toByteArray());
|
File.writeFile(var4, data.toByteArray());
|
||||||
|
|
||||||
if(GL11.readFile(var5) != null) {
|
if(File.readFile(var5) != null) {
|
||||||
GL11.deleteFile(var5);
|
File.deleteFile(var5);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.renameFile(var6, var5);
|
File.renameFile(var6, var5);
|
||||||
if(GL11.readFile(var6) != null) {
|
if(File.readFile(var6) != null) {
|
||||||
GL11.deleteFile(var6);
|
File.deleteFile(var6);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.renameFile(var4, var6);
|
File.renameFile(var4, var6);
|
||||||
if(GL11.readFile(var4) != null) {
|
if(File.readFile(var4) != null) {
|
||||||
GL11.deleteFile(var4);
|
File.deleteFile(var4);
|
||||||
}
|
}
|
||||||
} catch (Exception var7) {
|
} catch (Exception var7) {
|
||||||
var7.printStackTrace();
|
var7.printStackTrace();
|
||||||
|
@ -2018,10 +2020,10 @@ public class World implements IBlockAccess {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String var1 = this.field_9432_t + "/session.lock";
|
String var1 = this.field_9432_t + "/session.lock";
|
||||||
if(GL11.readFile(var1) == null) {
|
if(File.readFile(var1) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(GL11.readFile(var1)));
|
DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(File.readFile(var1)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(var2.readLong() != this.field_1054_E) {
|
if(var2.readLong() != this.field_1054_E) {
|
||||||
|
|
161
src/teavm/java/net/PeytonPlayz585/BufferUtils.java
Normal file
161
src/teavm/java/net/PeytonPlayz585/BufferUtils.java
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
package net.PeytonPlayz585;
|
||||||
|
|
||||||
|
import java.nio.Buffer;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.nio.DoubleBuffer;
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
import java.nio.LongBuffer;
|
||||||
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
|
import net.minecraft.src.GLAllocation;
|
||||||
|
|
||||||
|
public class BufferUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It's not possible to directly allocate and then convert the buffers in TeaVM
|
||||||
|
* So to fix this, I'm wrapping the values to the buffer instead
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static ByteBuffer createByteBuffer(int size) {
|
||||||
|
return ByteBuffer.wrap(new byte[size]).order(ByteOrder.nativeOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShortBuffer createShortBuffer(int size) {
|
||||||
|
return ShortBuffer.wrap(new short[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharBuffer createCharBuffer(int size) {
|
||||||
|
return CharBuffer.wrap(new char[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntBuffer createIntBuffer(int size) {
|
||||||
|
return IntBuffer.wrap(new int[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LongBuffer createLongBuffer(int size) {
|
||||||
|
return LongBuffer.wrap(new long[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FloatBuffer createFloatBuffer(int size) {
|
||||||
|
return FloatBuffer.wrap(new float[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DoubleBuffer createDoubleBuffer(int size) {
|
||||||
|
return DoubleBuffer.wrap(new double[size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PointerBuffer createPointerBuffer(int size) {
|
||||||
|
//Doesn't actually directly allocate
|
||||||
|
//I rewrote the PointerBuffer class to use buffer.wrap
|
||||||
|
return PointerBuffer.allocateDirect(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getElementSizeExponent(Buffer buf) {
|
||||||
|
if (buf instanceof ByteBuffer) {
|
||||||
|
return 0;
|
||||||
|
} else if (buf instanceof ShortBuffer || buf instanceof CharBuffer) {
|
||||||
|
return 1;
|
||||||
|
} else if (buf instanceof FloatBuffer || buf instanceof IntBuffer) {
|
||||||
|
return 2;
|
||||||
|
} else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer) {
|
||||||
|
return 3;
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Unsupported buffer type: " + buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOffset(Buffer buffer) {
|
||||||
|
return buffer.position() << getElementSizeExponent(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(ByteBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position(), b.remaining());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(ShortBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(CharBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(IntBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(FloatBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(LongBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void zeroBuffer(DoubleBuffer b) {
|
||||||
|
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wrote my own implementation since JNI isn't supported in TeaVM
|
||||||
|
private static void zeroBuffer0(Buffer b, long offset, long length) {
|
||||||
|
for (int i = 0; i < b.remaining(); i++) {
|
||||||
|
put(b, i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(Buffer b, int i, int i2) {
|
||||||
|
if(b instanceof ByteBuffer) {
|
||||||
|
put((ByteBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof ShortBuffer) {
|
||||||
|
put((ShortBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof CharBuffer) {
|
||||||
|
put((CharBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof IntBuffer) {
|
||||||
|
put((IntBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof FloatBuffer) {
|
||||||
|
put((FloatBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof LongBuffer) {
|
||||||
|
put((LongBuffer)b, i, i2);
|
||||||
|
} else if(b instanceof DoubleBuffer) {
|
||||||
|
put((DoubleBuffer)b, i, i2);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unsupported buffer type!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(ByteBuffer b, int i, int i2) {
|
||||||
|
b.put(i, (byte) i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(ShortBuffer b, int i, int i2) {
|
||||||
|
b.put(i, (short) i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(CharBuffer b, int i, int i2) {
|
||||||
|
b.put(i, (char) i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(IntBuffer b, int i, int i2) {
|
||||||
|
b.put(i, i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(FloatBuffer b, int i, int i2) {
|
||||||
|
b.put(i, i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(LongBuffer b, int i, int i2) {
|
||||||
|
b.put(i, i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void put(DoubleBuffer b, int i, int i2) {
|
||||||
|
b.put(i, i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Not in BufferUtils but thought I would add it anyways
|
||||||
|
public static int getBufferSizeInBytes(Buffer buffer) {
|
||||||
|
return buffer.capacity() * getElementSizeExponent(buffer);
|
||||||
|
}
|
||||||
|
}
|
299
src/teavm/java/net/PeytonPlayz585/Client.java
Normal file
299
src/teavm/java/net/PeytonPlayz585/Client.java
Normal file
File diff suppressed because one or more lines are too long
21
src/teavm/java/net/PeytonPlayz585/LWJGLException.java
Normal file
21
src/teavm/java/net/PeytonPlayz585/LWJGLException.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package net.PeytonPlayz585;
|
||||||
|
|
||||||
|
public class LWJGLException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public LWJGLException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LWJGLException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LWJGLException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LWJGLException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
314
src/teavm/java/net/PeytonPlayz585/PointerBuffer.java
Normal file
314
src/teavm/java/net/PeytonPlayz585/PointerBuffer.java
Normal file
|
@ -0,0 +1,314 @@
|
||||||
|
package net.PeytonPlayz585;
|
||||||
|
|
||||||
|
import java.nio.*;
|
||||||
|
|
||||||
|
public class PointerBuffer {
|
||||||
|
protected final ByteBuffer pointers;
|
||||||
|
protected final Buffer view;
|
||||||
|
protected final LongBuffer view64;
|
||||||
|
|
||||||
|
public PointerBuffer(final int capacity) {
|
||||||
|
this(ByteBuffer.wrap(new byte[capacity * getPointerSize()]).order(ByteOrder.nativeOrder()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer(final ByteBuffer source) {
|
||||||
|
checkSource(source);
|
||||||
|
pointers = source.slice().order(source.order());
|
||||||
|
|
||||||
|
view = view64 = pointers.asLongBuffer(); //Assumes 64-bit, no way to check for it
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkSource(final ByteBuffer source) {
|
||||||
|
if (!source.isDirect()) {
|
||||||
|
throw new IllegalArgumentException("The source buffer is not direct.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final int alignment = 8;
|
||||||
|
|
||||||
|
//There is no reliable way of getting a memory address for a buffer in JS
|
||||||
|
if (source.remaining() % alignment != 0) {
|
||||||
|
throw new IllegalArgumentException("The source buffer is not aligned to " + alignment + " bytes.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteBuffer getBuffer() {
|
||||||
|
return pointers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean is64Bit() {
|
||||||
|
//No reliable way to check this
|
||||||
|
//So I'm just assuming it's true
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPointerSize() {
|
||||||
|
return 8; //Also assumes 64-bit
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int capacity() {
|
||||||
|
return view.capacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int position() {
|
||||||
|
return view.position();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int positionByte() {
|
||||||
|
return position() * getPointerSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer position(int newPosition) {
|
||||||
|
view.position(newPosition);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int limit() {
|
||||||
|
return view.limit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer limit(int newLimit) {
|
||||||
|
view.limit(newLimit);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer mark() {
|
||||||
|
view.mark();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer reset() {
|
||||||
|
view.reset();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer clear() {
|
||||||
|
view.clear();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer flip() {
|
||||||
|
view.flip();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer rewind() {
|
||||||
|
view.rewind();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int remaining() {
|
||||||
|
return view.remaining();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int remainingByte() {
|
||||||
|
return remaining() * getPointerSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasRemaining() {
|
||||||
|
return view.hasRemaining();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PointerBuffer allocateDirect(int capacity) {
|
||||||
|
return new PointerBuffer(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PointerBuffer newInstance(final ByteBuffer source) {
|
||||||
|
return new PointerBuffer(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer slice() {
|
||||||
|
final int pointerSize = getPointerSize();
|
||||||
|
|
||||||
|
pointers.position(view.position() * pointerSize);
|
||||||
|
pointers.limit(view.limit() * pointerSize);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return newInstance(pointers); //Buffer is sliced in constructors
|
||||||
|
} finally {
|
||||||
|
pointers.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer duplicate() {
|
||||||
|
final PointerBuffer buffer = newInstance(pointers);
|
||||||
|
|
||||||
|
buffer.position(view.position());
|
||||||
|
buffer.limit(view.limit());
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//I don't like this
|
||||||
|
public PointerBuffer asReadOnlyBuffer() {
|
||||||
|
final PointerBuffer buffer = new PointerBufferR(pointers);
|
||||||
|
|
||||||
|
buffer.position(view.position());
|
||||||
|
buffer.limit(view.limit());
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReadOnly() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long get() {
|
||||||
|
return view64.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(long l) {
|
||||||
|
view64.put(l);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(final PointerWrapper pointer) {
|
||||||
|
return put(pointer.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void put(final ByteBuffer target, long l) {
|
||||||
|
target.putLong(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long get(int index) {
|
||||||
|
return view64.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(int index, long l) {
|
||||||
|
view64.put(index, l);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(int index, PointerWrapper pointer) {
|
||||||
|
return put(index, pointer.getPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void put(final ByteBuffer target, int index, long l) {
|
||||||
|
target.putLong(index, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer get(long[] dst, int offset, int length) {
|
||||||
|
view64.get(dst, offset, length);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer get(long[] dst) {
|
||||||
|
return get(dst, 0, dst.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(PointerBuffer src) {
|
||||||
|
view64.put(src.view64);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(long[] src, int offset, int length) {
|
||||||
|
view64.put(src, offset, length);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PointerBuffer put(long[] src) {
|
||||||
|
return put(src, 0, src.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer compact() {
|
||||||
|
view64.compact();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteOrder order() {
|
||||||
|
return view64.order();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
//Use String.format instead of StringBuilder
|
||||||
|
return String.format("%s[pos=%d, lim=%d, cap=%d]", getClass().getName(), position(), limit(), capacity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int h = 1;
|
||||||
|
int p = position();
|
||||||
|
for (int i = limit() - 1; i >= p; i--) {
|
||||||
|
h = 31 * h + (int)get(i);
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object ob) {
|
||||||
|
if (!(ob instanceof PointerBuffer)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PointerBuffer that = (PointerBuffer)ob;
|
||||||
|
if (this.remaining() != that.remaining()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int p = this.position();
|
||||||
|
for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) {
|
||||||
|
long v1 = this.get(i);
|
||||||
|
long v2 = that.get(j);
|
||||||
|
if ( v1 != v2 ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
final PointerBuffer that = (PointerBuffer)o;
|
||||||
|
int n = this.position() + Math.min(this.remaining(), that.remaining());
|
||||||
|
for (int i = this.position(), j = that.position(); i < n; i++, j++) {
|
||||||
|
long v1 = this.get(i);
|
||||||
|
long v2 = that.get(j);
|
||||||
|
if ( v1 == v2 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (v1 < v2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return +1;
|
||||||
|
}
|
||||||
|
return this.remaining() - that.remaining();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkBounds(int off, int len, int size) {
|
||||||
|
if ((off | len | (off + len) | (size - (off + len))) < 0) {
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class PointerBufferR extends PointerBuffer {
|
||||||
|
PointerBufferR(final ByteBuffer source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReadOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PointerBuffer newInstance(final ByteBuffer source) {
|
||||||
|
return new PointerBufferR(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer asReadOnlyBuffer() {
|
||||||
|
return duplicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(final long l) {
|
||||||
|
throw new ReadOnlyBufferException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(final int index, final long l) {
|
||||||
|
throw new ReadOnlyBufferException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(final PointerBuffer src) {
|
||||||
|
throw new ReadOnlyBufferException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer put(final long[] src, final int offset, final int length) {
|
||||||
|
throw new ReadOnlyBufferException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerBuffer compact() {
|
||||||
|
throw new ReadOnlyBufferException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/teavm/java/net/PeytonPlayz585/PointerWrapper.java
Normal file
5
src/teavm/java/net/PeytonPlayz585/PointerWrapper.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package net.PeytonPlayz585;
|
||||||
|
|
||||||
|
public interface PointerWrapper {
|
||||||
|
long getPointer();
|
||||||
|
}
|
283
src/teavm/java/net/PeytonPlayz585/fileutils/File.java
Normal file
283
src/teavm/java/net/PeytonPlayz585/fileutils/File.java
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.Client;
|
||||||
|
import net.PeytonPlayz585.fileutils.IndexedDBFilesystem.OpenState;
|
||||||
|
|
||||||
|
public class File {
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
private transient int prefixLength;
|
||||||
|
private final char slash = '/';
|
||||||
|
private static final String pathSeperator = "/";
|
||||||
|
private static final String[] altPathSeperator = new String[] { "\\" };
|
||||||
|
|
||||||
|
public File(String pathName) {
|
||||||
|
if (pathName == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
this.path = this.normalize(pathName);
|
||||||
|
this.prefixLength = this.prefixLength(this.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File(String parent, String child) {
|
||||||
|
if (child == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parent != null) {
|
||||||
|
this.path = this.createPath(parent, child);
|
||||||
|
} else {
|
||||||
|
this.path = this.normalize(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public File(File parent, String child) {
|
||||||
|
if (child == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
if(parent != null) {
|
||||||
|
this.path = this.createPath(parent.path, child);
|
||||||
|
} else {
|
||||||
|
this.path = this.normalize(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int prefixLength(String path) {
|
||||||
|
char slash = this.slash;
|
||||||
|
int n = path.length();
|
||||||
|
if (n == 0) return 0;
|
||||||
|
char c0 = path.charAt(0);
|
||||||
|
char c1 = (n > 1) ? path.charAt(1) : 0;
|
||||||
|
if (c0 == slash) {
|
||||||
|
if (c1 == slash) return 2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (isLetter(c0) && (c1 == ':')) {
|
||||||
|
if ((n > 2) && (path.charAt(2) == slash))
|
||||||
|
return 3;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLetter(char c) {
|
||||||
|
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalize(String p) {
|
||||||
|
for(int i = 0; i < altPathSeperator.length; ++i) {
|
||||||
|
p = p.replace(altPathSeperator[i], pathSeperator);
|
||||||
|
}
|
||||||
|
if(p.startsWith(pathSeperator)) {
|
||||||
|
p = p.substring(1);
|
||||||
|
}
|
||||||
|
if(p.endsWith(pathSeperator)) {
|
||||||
|
p = p.substring(0, p.length() - pathSeperator.length());
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] splitPath(String p) {
|
||||||
|
String[] pth = normalize(p).split(pathSeperator);
|
||||||
|
for(int i = 0; i < pth.length; ++i) {
|
||||||
|
pth[i] = pth[i].trim();
|
||||||
|
}
|
||||||
|
return pth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createPath(Object... p) {
|
||||||
|
ArrayList<String> r = new ArrayList();
|
||||||
|
for(int i = 0; i < p.length; ++i) {
|
||||||
|
if(p[i] == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String gg = p[i].toString();
|
||||||
|
if(gg == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] parts = splitPath(gg);
|
||||||
|
for(int j = 0; j < parts.length; ++j) {
|
||||||
|
if(parts[j] == null || parts[j].equals(".")) {
|
||||||
|
continue;
|
||||||
|
}else if(parts[j].equals("..") && r.size() > 0) {
|
||||||
|
int k = r.size() - 1;
|
||||||
|
if(!r.get(k).equals("..")) {
|
||||||
|
r.remove(k);
|
||||||
|
}else {
|
||||||
|
r.add("..");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
r.add(parts[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(r.size() > 0) {
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
for(int i = 0; i < r.size(); ++i) {
|
||||||
|
if(i > 0) {
|
||||||
|
s.append(pathSeperator);
|
||||||
|
}
|
||||||
|
s.append(r.get(i));
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
int index = path.lastIndexOf(slash);
|
||||||
|
if (index < prefixLength) return path.substring(prefixLength);
|
||||||
|
return path.substring(index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exists() {
|
||||||
|
return exists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDirectory() {
|
||||||
|
return exists(path) && directoryExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renameTo(File newPath) {
|
||||||
|
renameFile(path, newPath.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] read() {
|
||||||
|
return readFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] data) {
|
||||||
|
writeFile(path, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
deleteFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mkdir() {
|
||||||
|
IndexedDBFilesystem.mkdir(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File[] listFiles() {
|
||||||
|
Collection<FileEntry> collection = listFiles(path, false, false);
|
||||||
|
int size = collection.size();
|
||||||
|
FileEntry[] entries = collection.toArray(new FileEntry[size]);
|
||||||
|
File[] files = new File[size];
|
||||||
|
|
||||||
|
for(int i = 0; i < size; i++) {
|
||||||
|
files[i] = new File(entries[i].path);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean fileExists(String path) {
|
||||||
|
return IndexedDBFilesystem.fileExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean directoryExists(String path) {
|
||||||
|
return IndexedDBFilesystem.directoryExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean pathExists(String path) {
|
||||||
|
return IndexedDBFilesystem.pathExists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean exists(String path) {
|
||||||
|
return IndexedDBFilesystem.exists(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void mkdir(String path) {
|
||||||
|
String[] parts = path.split("/");
|
||||||
|
String dir = parts[parts.length - 1];
|
||||||
|
|
||||||
|
if(path.endsWith("/")) {
|
||||||
|
String file = "placeholder.txt";
|
||||||
|
path = path.replace(dir + "/", "");
|
||||||
|
if(!path.endsWith("/")) {
|
||||||
|
path = path + "/";
|
||||||
|
}
|
||||||
|
writeFile(path + dir + "/" + file, "UwU".getBytes());
|
||||||
|
} else {
|
||||||
|
String file = "placeholder.txt";
|
||||||
|
path = path.replace(dir, "");
|
||||||
|
if(!path.endsWith("/")) {
|
||||||
|
path = path + "/";
|
||||||
|
}
|
||||||
|
writeFile(path + dir + "/" + file, "UwU".getBytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void writeFile(String path, byte[] data) {
|
||||||
|
IndexedDBFilesystem.writeFile(path, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final byte[] readFile(String path) {
|
||||||
|
return IndexedDBFilesystem.readFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final long getLastModified(String path) {
|
||||||
|
return IndexedDBFilesystem.getLastModified(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int getFileSize(String path) {
|
||||||
|
return IndexedDBFilesystem.getFileSize(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void renameFile(String oldPath, String newPath) {
|
||||||
|
IndexedDBFilesystem.renameFile(oldPath, newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void copyFile(String oldPath, String newPath) {
|
||||||
|
IndexedDBFilesystem.copyFile(oldPath, newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void deleteFile(String path) {
|
||||||
|
IndexedDBFilesystem.deleteFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
|
||||||
|
return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesAndDirectories(String path) {
|
||||||
|
return listFiles(path, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesRecursive(String path) {
|
||||||
|
return listFiles(path, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final FileEntry[] listFiles(String path) {
|
||||||
|
Collection<FileEntry> entries = listFilesAndDirectories(path);
|
||||||
|
FileEntry[] entryArray = new FileEntry[entries.size()];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(FileEntry entry : entries) {
|
||||||
|
entryArray[i] = entry;
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
return entryArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCompressed(byte[] b) {
|
||||||
|
if(b == null || b.length < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (b[0] == (byte) 0x1F) && (b[1] == (byte) 0x8B);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
if(IndexedDBFilesystem.initialize() != OpenState.OPENED) {
|
||||||
|
Client.showIncompatibleScreen("IndexedDB failed to initialize!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
public class FileChooserResult {
|
||||||
|
|
||||||
|
public final String fileName;
|
||||||
|
public final byte[] fileData;
|
||||||
|
|
||||||
|
public FileChooserResult(String fileName, byte[] fileData) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.fileData = fileData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/teavm/java/net/PeytonPlayz585/fileutils/FileEntry.java
Normal file
36
src/teavm/java/net/PeytonPlayz585/fileutils/FileEntry.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
public class FileEntry {
|
||||||
|
|
||||||
|
public final String path;
|
||||||
|
public final boolean isDirectory;
|
||||||
|
public final long lastModified;
|
||||||
|
|
||||||
|
public FileEntry(String path, boolean isDirectory, long lastModified) {
|
||||||
|
this.path = path;
|
||||||
|
this.isDirectory = isDirectory;
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
int i = path.indexOf('/');
|
||||||
|
if(i >= 0) {
|
||||||
|
return path.substring(i + 1);
|
||||||
|
}else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFile() {
|
||||||
|
return !isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long length() {
|
||||||
|
return File.getFileSize(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long lastModified() {
|
||||||
|
return File.getLastModified(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class FilesystemUtils {
|
||||||
|
|
||||||
|
public static void recursiveDeleteDirectory(String dir) {
|
||||||
|
Collection<FileEntry> lst = File.listFiles(dir, true, true);
|
||||||
|
for(FileEntry t : lst) {
|
||||||
|
if(!t.isDirectory) {
|
||||||
|
File.deleteFile(t.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(FileEntry t : lst) {
|
||||||
|
if(t.isDirectory) {
|
||||||
|
File.deleteFile(t.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Why THE FUCK was this even here in the first place
|
||||||
|
//File.deleteFile(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm;
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm;
|
package net.PeytonPlayz585.fileutils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -23,10 +23,6 @@ import org.teavm.jso.indexeddb.IDBVersionChangeEvent;
|
||||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||||
import org.teavm.jso.typedarrays.Uint8Array;
|
import org.teavm.jso.typedarrays.Uint8Array;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2;
|
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
|
||||||
|
|
||||||
public class IndexedDBFilesystem {
|
public class IndexedDBFilesystem {
|
||||||
|
|
||||||
public static enum OpenState {
|
public static enum OpenState {
|
||||||
|
@ -37,13 +33,7 @@ public class IndexedDBFilesystem {
|
||||||
private static IDBDatabase db = null;
|
private static IDBDatabase db = null;
|
||||||
|
|
||||||
public static final OpenState initialize() {
|
public static final OpenState initialize() {
|
||||||
DatabaseOpen dbo;
|
DatabaseOpen dbo = AsyncHandlers.openDB("_net_PeytonPlayz585_eaglercraft_Alpha_IndexedDBFilesystem_1_2_6");
|
||||||
if(GL11.dataBaseName != null) {
|
|
||||||
System.out.println("Setting custom database name to " + GL11.dataBaseName);
|
|
||||||
dbo = AsyncHandlers.openDB(GL11.dataBaseName);
|
|
||||||
} else {
|
|
||||||
dbo = AsyncHandlers.openDB("_net_lax1dude_eaglercraft_beta_IndexedDBFilesystem_1_3");
|
|
||||||
}
|
|
||||||
if(dbo == null) {
|
if(dbo == null) {
|
||||||
err = "Unknown Error";
|
err = "Unknown Error";
|
||||||
return OpenState.ERROR;
|
return OpenState.ERROR;
|
||||||
|
@ -71,11 +61,15 @@ public class IndexedDBFilesystem {
|
||||||
return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY;
|
return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final boolean exists(String path) {
|
||||||
|
return AsyncHandlers.fileGetType(db, path) != FileExists.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
public static final boolean pathExists(String path) {
|
public static final boolean pathExists(String path) {
|
||||||
return AsyncHandlers.fileExists(db, path).bool;
|
return AsyncHandlers.fileExists(db, path).bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void mkdir(String dir) {
|
public static final void mkdir(String dir) {
|
||||||
if(directoryExists(dir)) {
|
if(directoryExists(dir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,9 +291,9 @@ public class IndexedDBFilesystem {
|
||||||
private static native String readKey(JSObject k);
|
private static native String readKey(JSObject k);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<EaglerAdapterImpl2.FileEntry> lst);
|
protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<FileEntry> lst);
|
||||||
|
|
||||||
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<EaglerAdapterImpl2.FileEntry> lst, final AsyncCallback<Integer> cb) {
|
private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection<FileEntry> lst, final AsyncCallback<Integer> cb) {
|
||||||
IDBTransaction tx = db.transaction("filesystem", "readonly");
|
IDBTransaction tx = db.transaction("filesystem", "readonly");
|
||||||
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
|
final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor();
|
||||||
final int[] res = new int[1];
|
final int[] res = new int[1];
|
||||||
|
@ -317,10 +311,10 @@ public class IndexedDBFilesystem {
|
||||||
boolean dir = isRowDirectory(c.getValue());
|
boolean dir = isRowDirectory(c.getValue());
|
||||||
if(dir) {
|
if(dir) {
|
||||||
if(listDirs) {
|
if(listDirs) {
|
||||||
lst.add(new EaglerAdapterImpl2.FileEntry(k, true, -1));
|
lst.add(new FileEntry(k, true, -1));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
lst.add(new EaglerAdapterImpl2.FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue())));
|
lst.add(new FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
8328
src/teavm/java/net/PeytonPlayz585/opengl/GL11.java
Normal file
8328
src/teavm/java/net/PeytonPlayz585/opengl/GL11.java
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@ public class SoundManager {
|
||||||
|
|
||||||
file = "sounds/" + file;
|
file = "sounds/" + file;
|
||||||
if(flag) {
|
if(flag) {
|
||||||
int i1 = GL11.beginPlayback(file + ".mp3", f, g, h, i * Minecraft.getMinecraft().gameSettings.soundVolume, j);
|
int i1 = GL11.EaglerAdapterImpl2.beginPlayback(file + ".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!");
|
||||||
|
@ -52,37 +52,37 @@ public class SoundManager {
|
||||||
} else {
|
} else {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
int i1 = rand.nextInt(4 - 1 + 1) + 1;
|
int i1 = rand.nextInt(4 - 1 + 1) + 1;
|
||||||
int i2 = GL11.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.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.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.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.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.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.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.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.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!");
|
||||||
|
@ -97,7 +97,7 @@ public class SoundManager {
|
||||||
|
|
||||||
public void func_338_a(EntityPlayer player, float f) {
|
public void func_338_a(EntityPlayer player, float f) {
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
GL11.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
|
GL11.EaglerAdapterImpl2.setListenerPos(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
|
||||||
} else {
|
} else {
|
||||||
double x = player.prevPosX + (player.posX - player.prevPosX) * f;
|
double x = player.prevPosX + (player.posX - player.prevPosX) * f;
|
||||||
double y = player.prevPosY + (player.posY - player.prevPosY) * f;
|
double y = player.prevPosY + (player.posY - player.prevPosY) * f;
|
||||||
|
@ -106,7 +106,7 @@ public class SoundManager {
|
||||||
double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
double yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GL11.setListenerPos((float)x, (float)y, (float)z, (float)player.motionX, (float)player.motionY, (float)player.motionZ, (float)pitch, (float)yaw);
|
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) {
|
} catch(Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class SoundManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
volume *= 0.25F;
|
volume *= 0.25F;
|
||||||
int i = GL11.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
|
int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(sound, volume * Minecraft.getMinecraft().gameSettings.soundVolume, pitch);
|
||||||
if(i == - 1) {
|
if(i == - 1) {
|
||||||
try {
|
try {
|
||||||
throw new FileNotFoundException("Audio file " + file + " not found!");
|
throw new FileNotFoundException("Audio file " + file + " not found!");
|
||||||
|
@ -136,14 +136,14 @@ public class SoundManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSoundOptionsChanged() {
|
public void onSoundOptionsChanged() {
|
||||||
for (Map.Entry<Integer, GL11.AudioBufferSourceNodeX> entry : GL11.activeSoundEffects.entrySet()) {
|
for (Map.Entry<Integer, GL11.EaglerAdapterImpl2.AudioBufferSourceNodeX> entry : GL11.EaglerAdapterImpl2.activeSoundEffects.entrySet()) {
|
||||||
int i = entry.getKey();
|
int i = entry.getKey();
|
||||||
|
|
||||||
if(GL11.isPlaying(i)) {
|
if(GL11.EaglerAdapterImpl2.isPlaying(i)) {
|
||||||
if(i != song) {
|
if(i != song) {
|
||||||
GL11.setVolume(i, GL11.getVolume(i) * Minecraft.getMinecraft().gameSettings.soundVolume);
|
GL11.EaglerAdapterImpl2.setVolume(i, GL11.EaglerAdapterImpl2.getVolume(i) * Minecraft.getMinecraft().gameSettings.soundVolume);
|
||||||
} else {
|
} else {
|
||||||
GL11.setVolume(i, 1.0F * Minecraft.getMinecraft().gameSettings.musicVolume);
|
GL11.EaglerAdapterImpl2.setVolume(i, 1.0F * Minecraft.getMinecraft().gameSettings.musicVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,8 @@ public class SoundManager {
|
||||||
|
|
||||||
public void musicTick() throws FileNotFoundException {
|
public void musicTick() throws FileNotFoundException {
|
||||||
if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) {
|
if(Minecraft.getMinecraft().gameSettings.musicVolume == 0.0F || Minecraft.getMinecraft().theWorld == null) {
|
||||||
if(GL11.isPlaying(song)) {
|
if(GL11.EaglerAdapterImpl2.isPlaying(song)) {
|
||||||
GL11.endSound(song);
|
GL11.EaglerAdapterImpl2.endSound(song);
|
||||||
}
|
}
|
||||||
musicFlag = true;
|
musicFlag = true;
|
||||||
musicTimer = 0;
|
musicTimer = 0;
|
||||||
|
@ -163,7 +163,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && musicFlag && !musicTimerSet) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && !musicTimerSet) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
musicTimer = rand.nextInt(6 - 3 + 1) + 3;
|
musicTimer = rand.nextInt(6 - 3 + 1) + 3;
|
||||||
musicTimer = musicTimer * 60;
|
musicTimer = musicTimer * 60;
|
||||||
|
@ -174,7 +174,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && musicFlag && musicTimerSet) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && musicFlag && musicTimerSet) {
|
||||||
if(Minecraft.getMinecraft().ticksRan >= ticks) {
|
if(Minecraft.getMinecraft().ticksRan >= ticks) {
|
||||||
musicFlag = false;
|
musicFlag = false;
|
||||||
musicTimer = 0;
|
musicTimer = 0;
|
||||||
|
@ -184,7 +184,7 @@ public class SoundManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GL11.isPlaying(song) && !musicFlag) {
|
if(!GL11.EaglerAdapterImpl2.isPlaying(song) && !musicFlag) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
int i = rand.nextInt(2);
|
int i = rand.nextInt(2);
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prevSong = songToPlay;
|
prevSong = songToPlay;
|
||||||
song = GL11.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/music/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
||||||
if(song == -1) {
|
if(song == -1) {
|
||||||
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ public class SoundManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prevSong = songToPlay;
|
prevSong = songToPlay;
|
||||||
song = GL11.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
song = GL11.EaglerAdapterImpl2.beginPlaybackStatic("/newMusic/" + songToPlay + ".mp3", Minecraft.getMinecraft().gameSettings.musicVolume, 1.0F);
|
||||||
if(song == -1) {
|
if(song == -1) {
|
||||||
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
throw new FileNotFoundException("Audio file " + songToPlay + ".mp3 not found!");
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,42 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm;
|
|
||||||
|
|
||||||
import org.teavm.jso.webgl.WebGLRenderingContext;
|
|
||||||
|
|
||||||
public interface WebGL2RenderingContext extends WebGLRenderingContext {
|
|
||||||
|
|
||||||
int TEXTURE_MAX_LEVEL = 0x0000813D;
|
|
||||||
int TEXTURE_MAX_ANISOTROPY_EXT = 0x000084FE;
|
|
||||||
int UNSIGNED_INT_24_8 = 0x000084FA;
|
|
||||||
int ANY_SAMPLES_PASSED = 0x00008D6A;
|
|
||||||
int QUERY_RESULT = 0x00008866;
|
|
||||||
int QUERY_RESULT_AVAILABLE = 0x00008867;
|
|
||||||
int DEPTH24_STENCIL8 = 0x000088F0;
|
|
||||||
int DEPTH_COMPONENT32F = 0x00008CAC;
|
|
||||||
int READ_FRAMEBUFFER = 0x00008CA8;
|
|
||||||
int DRAW_FRAMEBUFFER = 0x00008CA9;
|
|
||||||
int RGB8 = 0x00008051;
|
|
||||||
int RGBA8 = 0x00008058;
|
|
||||||
|
|
||||||
WebGLQuery createQuery();
|
|
||||||
|
|
||||||
void beginQuery(int p1, WebGLQuery obj);
|
|
||||||
|
|
||||||
void endQuery(int p1);
|
|
||||||
|
|
||||||
void deleteQuery(WebGLQuery obj);
|
|
||||||
|
|
||||||
int getQueryParameter(WebGLQuery obj, int p2);
|
|
||||||
|
|
||||||
WebGLVertexArray createVertexArray();
|
|
||||||
|
|
||||||
void deleteVertexArray(WebGLVertexArray obj);
|
|
||||||
|
|
||||||
void bindVertexArray(WebGLVertexArray obj);
|
|
||||||
|
|
||||||
void renderbufferStorageMultisample(int p1, int p2, int p3, int p4, int p5);
|
|
||||||
|
|
||||||
void blitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10);
|
|
||||||
|
|
||||||
void drawBuffers(int[] p1);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm;
|
|
||||||
|
|
||||||
import org.teavm.jso.JSObject;
|
|
||||||
|
|
||||||
public interface WebGLQuery extends JSObject {
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm;
|
|
||||||
|
|
||||||
import org.teavm.jso.JSObject;
|
|
||||||
|
|
||||||
public interface WebGLVertexArray extends JSObject {
|
|
||||||
}
|
|
|
@ -1,9 +1,12 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
|
||||||
public class ChunkLoader implements IChunkLoader {
|
public class ChunkLoader implements IChunkLoader {
|
||||||
private String saveDir;
|
private String saveDir;
|
||||||
|
@ -23,7 +26,7 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
String var5 = Integer.toString(var2 & 63, 36);
|
String var5 = Integer.toString(var2 & 63, 36);
|
||||||
String var6 = saveDir + "/" + var4 + "/" + var5 + "/" + var3;
|
String var6 = saveDir + "/" + var4 + "/" + var5 + "/" + var3;
|
||||||
|
|
||||||
if(GL11.readFile(var6) != null) {
|
if(File.readFile(var6) != null) {
|
||||||
return var6;
|
return var6;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -53,7 +56,7 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
}
|
}
|
||||||
String s = this.saveDir + "/" + new String(path);
|
String s = this.saveDir + "/" + new String(path);
|
||||||
if(oldChunk) {
|
if(oldChunk) {
|
||||||
GL11.renameFile(oldChunkPath, s);
|
File.renameFile(oldChunkPath, s);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -63,11 +66,11 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String var4 = this.chunkFileForXZ(x, z);
|
String var4 = this.chunkFileForXZ(x, z);
|
||||||
byte[] data = GL11.readFile(var4);
|
byte[] data = File.readFile(var4);
|
||||||
if(data != null) {
|
if(data != null) {
|
||||||
try {
|
try {
|
||||||
NBTTagCompound var6;
|
NBTTagCompound var6;
|
||||||
if(GL11.isCompressed(data)) {
|
if(File.isCompressed(data)) {
|
||||||
var6 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
var6 = CompressedStreamTools.func_1138_a(new ByteArrayInputStream(data));
|
||||||
} else {
|
} else {
|
||||||
var6 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
var6 = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(data)));
|
||||||
|
@ -79,7 +82,7 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
if(x != xx || z != zz) {
|
if(x != xx || z != zz) {
|
||||||
System.out.println("Chunk file at " + x + "," + z + " is in the wrong location; relocating. (Expected " + x + ", " + z + ", got " + xx + ", " + zz + ")");
|
System.out.println("Chunk file at " + x + "," + z + " is in the wrong location; relocating. (Expected " + x + ", " + z + ", got " + xx + ", " + zz + ")");
|
||||||
String name = chunkFileForXZ(xx, zz);
|
String name = chunkFileForXZ(xx, zz);
|
||||||
GL11.renameFile(var4, name);
|
File.renameFile(var4, name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +101,8 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
}
|
}
|
||||||
var1.func_663_l();
|
var1.func_663_l();
|
||||||
String var3 = this.chunkFileForXZ(var2.xPosition, var2.zPosition);
|
String var3 = this.chunkFileForXZ(var2.xPosition, var2.zPosition);
|
||||||
if(GL11.readFile(var3) != null) {
|
if(File.readFile(var3) != null) {
|
||||||
var1.sizeOnDisk -= GL11.getFileSize(var3);
|
var1.sizeOnDisk -= File.getFileSize(var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -111,15 +114,15 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
this.storeChunkInCompound(var2, var1, var7);
|
this.storeChunkInCompound(var2, var1, var7);
|
||||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(var6, var5);
|
CompressedStreamTools.writeGzippedCompoundToOutputStream(var6, var5);
|
||||||
var5.flush();
|
var5.flush();
|
||||||
GL11.writeFile(var4, var5.toByteArray());
|
File.writeFile(var4, var5.toByteArray());
|
||||||
var5.close();
|
var5.close();
|
||||||
|
|
||||||
if(GL11.readFile(var3) != null) {
|
if(File.readFile(var3) != null) {
|
||||||
GL11.deleteFile(var3);
|
File.deleteFile(var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.renameFile(var4, var3);
|
File.renameFile(var4, var3);
|
||||||
var1.sizeOnDisk += GL11.getFileSize(var3);
|
var1.sizeOnDisk += File.getFileSize(var3);
|
||||||
} catch (Exception var8) {
|
} catch (Exception var8) {
|
||||||
var8.printStackTrace();
|
var8.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||||
import org.teavm.jso.typedarrays.Float32Array;
|
import org.teavm.jso.typedarrays.Float32Array;
|
||||||
import org.teavm.jso.typedarrays.Int32Array;
|
import org.teavm.jso.typedarrays.Int32Array;
|
||||||
|
@ -11,8 +13,8 @@ public class Tessellator {
|
||||||
private Int32Array intBuffer;
|
private Int32Array intBuffer;
|
||||||
private Float32Array floatBuffer;
|
private Float32Array floatBuffer;
|
||||||
private int vertexCount = 0;
|
private int vertexCount = 0;
|
||||||
private float textureU;
|
private double textureU;
|
||||||
private float textureV;
|
private double textureV;
|
||||||
private int color;
|
private int color;
|
||||||
private boolean hasColor = false;
|
private boolean hasColor = false;
|
||||||
private boolean hasTexture = false;
|
private boolean hasTexture = false;
|
||||||
|
@ -24,11 +26,13 @@ public class Tessellator {
|
||||||
private double xOffset;
|
private double xOffset;
|
||||||
private double yOffset;
|
private double yOffset;
|
||||||
private double zOffset;
|
private double zOffset;
|
||||||
public static final Tessellator instance = new Tessellator(524288);
|
public static final Tessellator instance = new Tessellator(2097152);
|
||||||
private boolean isDrawing = false;
|
private boolean isDrawing = false;
|
||||||
private int normal;
|
private int normal;
|
||||||
|
private int bufferSize;
|
||||||
|
|
||||||
private Tessellator(int par1) {
|
private Tessellator(int par1) {
|
||||||
|
this.bufferSize = par1;
|
||||||
ArrayBuffer a = ArrayBuffer.create(par1 * 4);
|
ArrayBuffer a = ArrayBuffer.create(par1 * 4);
|
||||||
this.intBuffer = Int32Array.create(a);
|
this.intBuffer = Int32Array.create(a);
|
||||||
this.floatBuffer = Float32Array.create(a);
|
this.floatBuffer = Float32Array.create(a);
|
||||||
|
@ -38,44 +42,42 @@ public class Tessellator {
|
||||||
* Draws the data set up in this tessellator and resets the state to prepare for
|
* Draws the data set up in this tessellator and resets the state to prepare for
|
||||||
* new drawing.
|
* new drawing.
|
||||||
*/
|
*/
|
||||||
public int draw() {
|
public void draw() {
|
||||||
if (!this.isDrawing) {
|
if (!this.isDrawing) {
|
||||||
return 0;
|
throw new IllegalStateException("Not tesselating!");
|
||||||
} else {
|
} else {
|
||||||
this.isDrawing = false;
|
this.isDrawing = false;
|
||||||
|
|
||||||
if (this.vertexCount > 0) {
|
if (this.vertexCount > 0) {
|
||||||
|
if(this.hasTexture) {
|
||||||
if (this.hasTexture) {
|
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasColor) {
|
if(this.hasColor) {
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasNormals) {
|
|
||||||
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glDrawArrays(this.drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
|
|
||||||
|
|
||||||
if (this.hasNormals) {
|
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasTexture) {
|
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasColor) {
|
if(this.hasNormals) {
|
||||||
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||||
|
GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 8));
|
||||||
|
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
if(this.hasTexture) {
|
||||||
|
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.hasColor) {
|
||||||
|
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.hasNormals) {
|
||||||
|
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int var1 = this.rawBufferIndex * 4;
|
|
||||||
this.reset();
|
this.reset();
|
||||||
return var1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,6 @@ public class Tessellator {
|
||||||
*/
|
*/
|
||||||
private void reset() {
|
private void reset() {
|
||||||
this.vertexCount = 0;
|
this.vertexCount = 0;
|
||||||
//this.byteBuffer.clear();
|
|
||||||
this.rawBufferIndex = 0;
|
this.rawBufferIndex = 0;
|
||||||
this.addedVertices = 0;
|
this.addedVertices = 0;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +94,7 @@ public class Tessellator {
|
||||||
* Sets draw mode in the tessellator to draw quads.
|
* Sets draw mode in the tessellator to draw quads.
|
||||||
*/
|
*/
|
||||||
public void startDrawingQuads() {
|
public void startDrawingQuads() {
|
||||||
this.startDrawing(GL11.GL_QUADS);
|
this.startDrawing(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,16 +102,17 @@ public class Tessellator {
|
||||||
* mode).
|
* mode).
|
||||||
*/
|
*/
|
||||||
public void startDrawing(int par1) {
|
public void startDrawing(int par1) {
|
||||||
if (this.isDrawing) {
|
if(this.isDrawing) {
|
||||||
this.draw();
|
throw new IllegalStateException("Already tesselating!");
|
||||||
|
} else {
|
||||||
|
this.isDrawing = true;
|
||||||
|
this.reset();
|
||||||
|
this.drawMode = par1;
|
||||||
|
this.hasNormals = false;
|
||||||
|
this.hasColor = false;
|
||||||
|
this.hasTexture = false;
|
||||||
|
this.isColorDisabled = false;
|
||||||
}
|
}
|
||||||
this.isDrawing = true;
|
|
||||||
this.reset();
|
|
||||||
this.drawMode = par1;
|
|
||||||
this.hasNormals = false;
|
|
||||||
this.hasColor = false;
|
|
||||||
this.hasTexture = false;
|
|
||||||
this.isColorDisabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,77 +124,65 @@ public class Tessellator {
|
||||||
this.textureV = (float) par3;
|
this.textureV = (float) par3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque_F(float var1, float var2, float var3) {
|
||||||
* Sets the RGB values as specified, converting from floats between 0 and 1 to
|
this.setColorOpaque((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F));
|
||||||
* integers from 0-255.
|
|
||||||
*/
|
|
||||||
public void setColorOpaque_F(float par1, float par2, float par3) {
|
|
||||||
this.setColorOpaque((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA_F(float var1, float var2, float var3, float var4) {
|
||||||
* Sets the RGBA values for the color, converting from floats between 0 and 1 to
|
this.setColorRGBA((int)(var1 * 255.0F), (int)(var2 * 255.0F), (int)(var3 * 255.0F), (int)(var4 * 255.0F));
|
||||||
* integers from 0-255.
|
|
||||||
*/
|
|
||||||
public void setColorRGBA_F(float par1, float par2, float par3, float par4) {
|
|
||||||
this.setColorRGBA((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F), (int) (par4 * 255.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque(int var1, int var2, int var3) {
|
||||||
* Sets the RGB values as specified, and sets alpha to opaque.
|
this.setColorRGBA(var1, var2, var3, 255);
|
||||||
*/
|
|
||||||
public void setColorOpaque(int par1, int par2, int par3) {
|
|
||||||
this.setColorRGBA(par1, par2, par3, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA(int var1, int var2, int var3, int var4) {
|
||||||
* Sets the RGBA values for the color. Also clamps them to 0-255.
|
if(!this.isColorDisabled) {
|
||||||
*/
|
if(var1 > 255) {
|
||||||
public void setColorRGBA(int par1, int par2, int par3, int par4) {
|
var1 = 255;
|
||||||
if (!this.isColorDisabled) {
|
|
||||||
if (par1 > 255) {
|
|
||||||
par1 = 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par2 > 255) {
|
if(var2 > 255) {
|
||||||
par2 = 255;
|
var2 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par3 > 255) {
|
if(var3 > 255) {
|
||||||
par3 = 255;
|
var3 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par4 > 255) {
|
if(var4 > 255) {
|
||||||
par4 = 255;
|
var4 = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par1 < 0) {
|
if(var1 < 0) {
|
||||||
par1 = 0;
|
var1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par2 < 0) {
|
if(var2 < 0) {
|
||||||
par2 = 0;
|
var2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par3 < 0) {
|
if(var3 < 0) {
|
||||||
par3 = 0;
|
var3 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par4 < 0) {
|
if(var4 < 0) {
|
||||||
par4 = 0;
|
var4 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasColor = true;
|
this.hasColor = true;
|
||||||
this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1;
|
if(ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
|
||||||
|
this.color = var4 << 24 | var3 << 16 | var2 << 8 | var1;
|
||||||
|
} else {
|
||||||
|
this.color = var1 << 24 | var2 << 16 | var3 << 8 | var4;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void addVertexWithUV(double var1, double var3, double var5, double var7, double var9) {
|
||||||
* Adds a vertex specifying both x,y,z and the texture u,v for it.
|
this.setTextureUV(var7, var9);
|
||||||
*/
|
this.addVertex(var1, var3, var5);
|
||||||
public void addVertexWithUV(double par1, double par3, double par5, double par7, double par9) {
|
|
||||||
this.setTextureUV(par7, par9);
|
|
||||||
this.addVertex(par1, par3, par5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,52 +192,47 @@ public class Tessellator {
|
||||||
public void addVertex(double par1, double par3, double par5) {
|
public void addVertex(double par1, double par3, double par5) {
|
||||||
if(this.addedVertices > 65534) return;
|
if(this.addedVertices > 65534) return;
|
||||||
++this.addedVertices;
|
++this.addedVertices;
|
||||||
++this.vertexCount;
|
|
||||||
|
|
||||||
int bufferIndex = this.rawBufferIndex;
|
|
||||||
Int32Array intBuffer0 = intBuffer;
|
Int32Array intBuffer0 = intBuffer;
|
||||||
Float32Array floatBuffer0 = floatBuffer;
|
Float32Array floatBuffer0 = floatBuffer;
|
||||||
|
|
||||||
|
floatBuffer0.set(this.rawBufferIndex + 0, (float)(par1 + this.xOffset));
|
||||||
|
floatBuffer0.set(this.rawBufferIndex + 1, (float)(par3 + this.yOffset));
|
||||||
|
floatBuffer0.set(this.rawBufferIndex + 2, (float)(par5 + this.zOffset));
|
||||||
|
|
||||||
floatBuffer0.set(bufferIndex + 0, (float) (par1 + this.xOffset));
|
if(this.hasTexture) {
|
||||||
floatBuffer0.set(bufferIndex + 1, (float) (par3 + this.yOffset));
|
floatBuffer0.set(this.rawBufferIndex + 3, (float)this.textureU);
|
||||||
floatBuffer0.set(bufferIndex + 2, (float) (par5 + this.zOffset));
|
floatBuffer0.set(this.rawBufferIndex + 4, (float)this.textureV);
|
||||||
|
|
||||||
if (this.hasTexture) {
|
|
||||||
floatBuffer0.set(bufferIndex + 3, this.textureU);
|
|
||||||
floatBuffer0.set(bufferIndex + 4, this.textureV);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasColor) {
|
if(this.hasColor) {
|
||||||
intBuffer0.set(bufferIndex + 5, this.color);
|
intBuffer0.set(this.rawBufferIndex + 5, this.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.hasNormals) {
|
||||||
|
intBuffer0.set(this.rawBufferIndex + 6, this.normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasNormals) {
|
this.rawBufferIndex += 8;
|
||||||
intBuffer0.set(bufferIndex + 6, this.normal);
|
++this.vertexCount;
|
||||||
|
if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32) {
|
||||||
|
this.draw();
|
||||||
|
this.isDrawing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rawBufferIndex += 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorOpaque_I(int var1) {
|
||||||
* Sets the color to the given opaque value (stored as byte values packed in an
|
int var2 = var1 >>> 16 & 255;
|
||||||
* integer).
|
int var3 = var1 >>> 8 & 255;
|
||||||
*/
|
int var4 = var1 & 255;
|
||||||
public void setColorOpaque_I(int par1) {
|
|
||||||
int var2 = par1 >>> 16 & 255;
|
|
||||||
int var3 = par1 >>> 8 & 255;
|
|
||||||
int var4 = par1 & 255;
|
|
||||||
this.setColorOpaque(var2, var3, var4);
|
this.setColorOpaque(var2, var3, var4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setColorRGBA_I(int var1, int var2) {
|
||||||
* Sets the color to the given color (packed as bytes in integer) and alpha
|
int var3 = var1 >>> 16 & 255;
|
||||||
* values.
|
int var4 = var1 >>> 8 & 255;
|
||||||
*/
|
int var5 = var1 & 255;
|
||||||
public void setColorRGBA_I(int par1, int par2) {
|
this.setColorRGBA(var3, var4, var5, var2);
|
||||||
int var3 = par1 >>> 16 & 255;
|
|
||||||
int var4 = par1 >>> 8 & 255;
|
|
||||||
int var5 = par1 & 255;
|
|
||||||
this.setColorRGBA(var3, var4, var5, par2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,8 +246,11 @@ public class Tessellator {
|
||||||
* Sets the normal for the current draw call.
|
* Sets the normal for the current draw call.
|
||||||
*/
|
*/
|
||||||
public void setNormal(float par1, float par2, float par3) {
|
public void setNormal(float par1, float par2, float par3) {
|
||||||
|
if(!this.isDrawing) {
|
||||||
|
System.out.println("But..");
|
||||||
|
}
|
||||||
|
|
||||||
this.hasNormals = true;
|
this.hasNormals = true;
|
||||||
//float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
|
|
||||||
int var4 = (int)((par1) * 127.0F) + 127;
|
int var4 = (int)((par1) * 127.0F) + 127;
|
||||||
int var5 = (int)((par2) * 127.0F) + 127;
|
int var5 = (int)((par2) * 127.0F) + 127;
|
||||||
int var6 = (int)((par3) * 127.0F) + 127;
|
int var6 = (int)((par3) * 127.0F) + 127;
|
||||||
|
|
17389
web/js/app.js
17389
web/js/app.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
web/resources.mc
BIN
web/resources.mc
Binary file not shown.
Loading…
Reference in New Issue
Block a user