This commit is contained in:
eaglercraft 2024-06-08 16:38:53 -07:00
parent cfab2e85bf
commit 16648bc6c8
94 changed files with 2126 additions and 172 deletions

View File

@ -33,8 +33,8 @@ out vec4 v_color4f;
uniform mat4 u_matrixTransform; uniform mat4 u_matrixTransform;
uniform vec3 u_texCoordSize2f_particleSize1f; uniform vec3 u_texCoordSize2f_particleSize1f;
uniform vec4 u_transformParam_1_2_3_4_f; uniform vec3 u_transformParam_1_2_5_f;
uniform float u_transformParam_5_f; uniform vec2 u_transformParam_3_4_f;
uniform vec4 u_color4f; uniform vec4 u_color4f;
uniform sampler2D u_lightmapTexture; uniform sampler2D u_lightmapTexture;
@ -51,11 +51,8 @@ void main() {
vec3 pos3f = p_position3f; vec3 pos3f = p_position3f;
vec2 spos2f = a_position2f * particleSize; vec2 spos2f = a_position2f * particleSize;
pos3f.x += u_transformParam_1_2_3_4_f.x * spos2f.x; pos3f += u_transformParam_1_2_5_f * spos2f.xyy;
pos3f.x += u_transformParam_1_2_3_4_f.w * spos2f.y; pos3f.zx += u_transformParam_3_4_f * spos2f;
pos3f.y += u_transformParam_1_2_3_4_f.y * spos2f.y;
pos3f.z += u_transformParam_1_2_3_4_f.z * spos2f.x;
pos3f.z += u_transformParam_5_f * spos2f.y;
gl_Position = u_matrixTransform * vec4(pos3f, 1.0); gl_Position = u_matrixTransform * vec4(pos3f, 1.0);
} }

View File

@ -43,8 +43,8 @@ uniform mat4 u_matrixTransform;
#endif #endif
uniform vec3 u_texCoordSize2f_particleSize1f; uniform vec3 u_texCoordSize2f_particleSize1f;
uniform vec4 u_transformParam_1_2_3_4_f; uniform vec3 u_transformParam_1_2_5_f;
uniform float u_transformParam_5_f; uniform vec2 u_transformParam_3_4_f;
void main() { void main() {
v_color4f = p_color4f.bgra; v_color4f = p_color4f.bgra;
@ -59,11 +59,8 @@ void main() {
vec3 pos3f = p_position3f; vec3 pos3f = p_position3f;
vec2 spos2f = a_position2f * particleSize; vec2 spos2f = a_position2f * particleSize;
pos3f.x += u_transformParam_1_2_3_4_f.x * spos2f.x; pos3f += u_transformParam_1_2_5_f * spos2f.xyy;
pos3f.x += u_transformParam_1_2_3_4_f.w * spos2f.y; pos3f.zx += u_transformParam_3_4_f * spos2f;
pos3f.y += u_transformParam_1_2_3_4_f.y * spos2f.y;
pos3f.z += u_transformParam_1_2_3_4_f.z * spos2f.x;
pos3f.z += u_transformParam_5_f * spos2f.y;
#ifdef COMPILE_GBUFFER_VSH #ifdef COMPILE_GBUFFER_VSH
gl_Position = u_matrixTransform * vec4(pos3f, 1.0); gl_Position = u_matrixTransform * vec4(pos3f, 1.0);

View File

@ -6,4 +6,5 @@ minecraft:torch,0,1.0000,0.5983,0.2655,10.0
minecraft:redstone_torch,0,1.0000,0.1578,0.0000,4.0 minecraft:redstone_torch,0,1.0000,0.1578,0.0000,4.0
minecraft:sea_lantern,0,0.5530,0.6468,1.0000,10.0, minecraft:sea_lantern,0,0.5530,0.6468,1.0000,10.0,
minecraft:lava_bucket,0,1.0000,0.4461,0.1054,6.0, minecraft:lava_bucket,0,1.0000,0.4461,0.1054,6.0,
minecraft:nether_star,0,0.5711,0.6611,1.0000,6.0 minecraft:nether_star,0,0.5711,0.6611,1.0000,6.0
minecraft:ender_eye,0,0.1990,0.7750,0.4130,4.0
1 item,damage,red,green,blue,intensity
6 minecraft:redstone_torch,0,1.0000,0.1578,0.0000,4.0
7 minecraft:sea_lantern,0,0.5530,0.6468,1.0000,10.0,
8 minecraft:lava_bucket,0,1.0000,0.4461,0.1054,6.0,
9 minecraft:nether_star,0,0.5711,0.6611,1.0000,6.0
10 minecraft:ender_eye,0,0.1990,0.7750,0.4130,4.0

View File

@ -1,7 +1,7 @@
{ {
"name": "§eHigh Performance PBR", "name": "§eHigh Performance PBR",
"desc": "Pack made from scratch specifically for this client, designed to give what I call the best balance between quality and performance possible in a browser but obviously that's just my opinion", "desc": "Pack made from scratch specifically for this client, designed to give what I call the best balance between quality and performance possible in a browser but obviously that's just my opinion",
"vers": "1.1.0", "vers": "1.2.0",
"author": "lax1dude", "author": "lax1dude",
"api_vers": 1, "api_vers": 1,
"features": [ "features": [

View File

@ -0,0 +1,67 @@
#line 2
/*
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
precision lowp int;
precision mediump float;
precision mediump sampler2D;
in vec4 v_position4f;
in vec2 v_texCoord2f;
in vec4 v_color4f;
in vec2 v_lightmap2f;
layout(location = 0) out vec4 output4f;
uniform sampler2D u_inputTexture;
uniform sampler2D u_lightmapTexture;
uniform mat4 u_inverseViewMatrix4f;
layout(std140) uniform u_chunkLightingData {
mediump int u_dynamicLightCount1i;
mediump int _paddingA_;
mediump int _paddingB_;
mediump int _paddingC_;
mediump vec4 u_dynamicLightArray[12];
};
void main() {
vec4 color = texture(u_inputTexture, v_texCoord2f) * v_color4f;
if(color.a < 0.004) {
discard;
}
vec4 light;
float diffuse = 0.0;
if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
worldPosition4f.xyz /= worldPosition4f.w;
vec3 normalVector3f = normalize(u_inverseViewMatrix4f[2].xyz);
int safeLightCount = u_dynamicLightCount1i > 12 ? 0 : u_dynamicLightCount1i;
for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz;
diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0);
}
}
color *= texture(u_lightmapTexture, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y));
output4f = color;
}

View File

@ -0,0 +1,61 @@
#line 2
/*
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
precision lowp int;
precision highp float;
precision mediump sampler2D;
layout(location = 0) in vec2 a_position2f;
layout(location = 1) in vec3 p_position3f;
layout(location = 2) in vec2 p_texCoords2i;
layout(location = 3) in vec2 p_lightMap2f;
layout(location = 4) in vec2 p_particleSize_texCoordsSize_2i;
layout(location = 5) in vec4 p_color4f;
out vec4 v_position4f;
out vec2 v_texCoord2f;
out vec4 v_color4f;
out vec2 v_lightmap2f;
uniform mat4 u_modelViewMatrix4f;
uniform mat4 u_projectionMatrix4f;
uniform vec3 u_texCoordSize2f_particleSize1f;
uniform vec3 u_transformParam_1_2_5_f;
uniform vec2 u_transformParam_3_4_f;
uniform vec4 u_color4f;
void main() {
v_color4f = u_color4f * p_color4f.bgra;
v_lightmap2f = p_lightMap2f;
vec2 tex2f = a_position2f * 0.5 + 0.5;
tex2f.y = 1.0 - tex2f.y;
tex2f = p_texCoords2i + tex2f * p_particleSize_texCoordsSize_2i.y;
v_texCoord2f = tex2f * u_texCoordSize2f_particleSize1f.xy;
float particleSize = u_texCoordSize2f_particleSize1f.z * p_particleSize_texCoordsSize_2i.x;
vec3 pos3f = p_position3f;
vec2 spos2f = a_position2f * particleSize;
pos3f += u_transformParam_1_2_5_f * spos2f.xyy;
pos3f.zx += u_transformParam_3_4_f * spos2f;
v_position4f = u_modelViewMatrix4f * vec4(pos3f, 1.0);
gl_Position = u_projectionMatrix4f * v_position4f;
}

View File

@ -0,0 +1,210 @@
#line 2
/*
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
in vec4 v_position4f;
#ifdef COMPILE_TEXTURE_ATTRIB
in vec2 v_texture2f;
#endif
uniform vec4 u_color4f;
#ifdef COMPILE_BLEND_ADD
uniform vec4 u_colorBlendSrc4f;
uniform vec4 u_colorBlendAdd4f;
#endif
#ifdef COMPILE_COLOR_ATTRIB
in vec4 v_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
in vec3 v_normal3f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
in vec2 v_lightmap2f;
#endif
#ifdef COMPILE_ENABLE_TEXTURE2D
uniform sampler2D u_samplerTexture;
#if !defined(COMPILE_TEXTURE_ATTRIB) && !defined(COMPILE_ENABLE_TEX_GEN)
uniform vec2 u_textureCoords01;
#endif
#endif
#ifdef COMPILE_ENABLE_LIGHTMAP
uniform sampler2D u_samplerLightmap;
#ifndef COMPILE_LIGHTMAP_ATTRIB
uniform vec2 u_textureCoords02;
#endif
#endif
#ifdef COMPILE_ENABLE_ALPHA_TEST
uniform float u_alphaTestRef1f;
#endif
#ifdef COMPILE_ENABLE_MC_LIGHTING
uniform int u_lightsEnabled1i;
uniform vec4 u_lightsDirections4fv[4];
uniform vec3 u_lightsAmbient3f;
#endif
#ifndef COMPILE_NORMAL_ATTRIB
uniform vec3 u_uniformNormal3f;
#endif
#ifdef COMPILE_ENABLE_FOG
uniform vec4 u_fogParameters4f;
uniform vec4 u_fogColor4f;
#endif
#ifdef COMPILE_ENABLE_TEX_GEN
in vec3 v_objectPosition3f;
uniform ivec4 u_texGenPlane4i;
uniform vec4 u_texGenS4f;
uniform vec4 u_texGenT4f;
uniform vec4 u_texGenR4f;
uniform vec4 u_texGenQ4f;
uniform mat4 u_textureMat4f01;
#endif
#ifdef COMPILE_ENABLE_ANISOTROPIC_FIX
uniform vec2 u_textureAnisotropicFix;
#endif
uniform mat4 u_inverseViewMatrix4f;
layout(std140) uniform u_chunkLightingData {
mediump int u_dynamicLightCount1i;
mediump int _paddingA_;
mediump int _paddingB_;
mediump int _paddingC_;
mediump vec4 u_dynamicLightArray[12];
};
layout(location = 0) out vec4 output4f;
void main() {
#ifdef COMPILE_COLOR_ATTRIB
vec4 color = v_color4f * u_color4f;
#else
vec4 color = u_color4f;
#endif
#ifdef COMPILE_ENABLE_TEX_GEN
vec4 texGenVector;
vec4 texGenPosSrc[2];
texGenPosSrc[0] = vec4(v_objectPosition3f, 1.0);
texGenPosSrc[1] = v_position4f;
texGenVector.x = dot(texGenPosSrc[u_texGenPlane4i.x], u_texGenS4f);
texGenVector.y = dot(texGenPosSrc[u_texGenPlane4i.y], u_texGenT4f);
texGenVector.z = dot(texGenPosSrc[u_texGenPlane4i.z], u_texGenR4f);
texGenVector.w = dot(texGenPosSrc[u_texGenPlane4i.w], u_texGenQ4f);
texGenVector = u_textureMat4f01 * texGenVector;
color *= texture(u_samplerTexture, texGenVector.xy / texGenVector.w);
#ifdef COMPILE_ENABLE_ALPHA_TEST
if(color.a < u_alphaTestRef1f) discard;
#endif
#else
#ifdef COMPILE_ENABLE_TEXTURE2D
#ifdef COMPILE_TEXTURE_ATTRIB
#ifdef COMPILE_ENABLE_ANISOTROPIC_FIX
// d3d11 doesn't support GL_NEAREST upscaling with anisotropic
// filtering enabled, so it needs this stupid fix to 'work'
vec2 uv = floor(v_texture2f * u_textureAnisotropicFix) + 0.5;
color *= texture(u_samplerTexture, uv / u_textureAnisotropicFix);
#else
color *= texture(u_samplerTexture, v_texture2f);
#endif
#else
color *= texture(u_samplerTexture, u_textureCoords01);
#endif
#endif
#ifdef COMPILE_NORMAL_ATTRIB
vec3 normal = normalize(v_normal3f);
#else
vec3 normal = u_uniformNormal3f;
#endif
#ifdef COMPILE_ENABLE_LIGHTMAP
float diffuse = 0.0;
vec4 light;
if(u_dynamicLightCount1i > 0) {
vec4 worldPosition4f = u_inverseViewMatrix4f * v_position4f;
worldPosition4f.xyz /= worldPosition4f.w;
vec3 normalVector3f = normalize(mat3(u_inverseViewMatrix4f) * normal);
int safeLightCount = u_dynamicLightCount1i > 12 ? 0 : u_dynamicLightCount1i;
for(int i = 0; i < safeLightCount; ++i) {
light = u_dynamicLightArray[i];
light.xyz = light.xyz - worldPosition4f.xyz;
diffuse += max(dot(normalize(light.xyz), normalVector3f) * 0.8 + 0.2, 0.0) * max(light.w - sqrt(dot(light.xyz, light.xyz)), 0.0);
}
}
#ifdef COMPILE_LIGHTMAP_ATTRIB
color *= texture(u_samplerLightmap, vec2(min(v_lightmap2f.x + diffuse * 0.066667, 1.0), v_lightmap2f.y));
#else
color *= texture(u_samplerLightmap, vec2(min(u_textureCoords02.x + diffuse * 0.066667, 1.0), u_textureCoords02.y));
#endif
#endif
#ifdef COMPILE_BLEND_ADD
color = color * u_colorBlendSrc4f + u_colorBlendAdd4f;
#endif
#ifdef COMPILE_ENABLE_ALPHA_TEST
if(color.a < u_alphaTestRef1f) discard;
#endif
#endif
#ifdef COMPILE_ENABLE_MC_LIGHTING
#ifndef COMPILE_ENABLE_LIGHTMAP
vec4 light;
float diffuse = 0.0;
#else
diffuse = 0.0;
#endif
for(int i = 0; i < u_lightsEnabled1i; ++i) {
light = u_lightsDirections4fv[i];
diffuse += max(dot(light.xyz, normal), 0.0) * light.w;
}
color.rgb *= min(u_lightsAmbient3f + vec3(diffuse), 1.0);
#endif
#ifdef COMPILE_ENABLE_FOG
vec3 fogPos = v_position4f.xyz / v_position4f.w;
float dist = sqrt(dot(fogPos, fogPos));
float fogDensity = u_fogParameters4f.y;
float fogStart = u_fogParameters4f.z;
float fogEnd = u_fogParameters4f.w;
float f = u_fogParameters4f.x > 0.0 ? 1.0 - exp(-fogDensity * dist) :
(dist - fogStart) / (fogEnd - fogStart);
color.rgb = mix(color.rgb, u_fogColor4f.rgb, clamp(f, 0.0, 1.0) * u_fogColor4f.a);
#endif
output4f = color;
}

View File

@ -0,0 +1,80 @@
#line 2
/*
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
in vec3 a_position3f;
out vec4 v_position4f;
#ifdef COMPILE_ENABLE_TEX_GEN
out vec3 v_objectPosition3f;
#endif
#ifdef COMPILE_TEXTURE_ATTRIB
in vec2 a_texture2f;
out vec2 v_texture2f;
uniform mat4 u_textureMat4f01;
#endif
#ifdef COMPILE_COLOR_ATTRIB
in vec4 a_color4f;
out vec4 v_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
in vec4 a_normal4f;
out vec3 v_normal3f;
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
in vec2 a_lightmap2f;
out vec2 v_lightmap2f;
uniform mat4 u_textureMat4f02;
#endif
uniform mat4 u_modelviewMat4f;
uniform mat4 u_projectionMat4f;
#define TEX_MAT3(mat4In) mat3(mat4In[0].xyw,mat4In[1].xyw,mat4In[3].xyw)
void main() {
#ifdef COMPILE_ENABLE_TEX_GEN
v_objectPosition3f = a_position3f;
#endif
v_position4f = u_modelviewMat4f * vec4(a_position3f, 1.0);
#ifdef COMPILE_TEXTURE_ATTRIB
vec3 v_textureTmp3f = TEX_MAT3(u_textureMat4f01) * vec3(a_texture2f, 1.0);
v_texture2f = v_textureTmp3f.xy / v_textureTmp3f.z;
#endif
#ifdef COMPILE_COLOR_ATTRIB
v_color4f = a_color4f;
#endif
#ifdef COMPILE_NORMAL_ATTRIB
v_normal3f = normalize(mat3(u_modelviewMat4f) * a_normal4f.xyz);
#endif
#ifdef COMPILE_LIGHTMAP_ATTRIB
vec3 v_lightmapTmp3f = TEX_MAT3(u_textureMat4f02) * vec3(a_lightmap2f, 1.0);
v_lightmap2f = v_lightmapTmp3f.xy / v_lightmapTmp3f.z;
#endif
gl_Position = u_projectionMat4f * v_position4f;
}

View File

@ -0,0 +1,9 @@
THESE ARE NOT DOOM/GMOD MODELS!
The FNAW skins are stored in a proprietary format created by lax1dude.
The format is a container for raw OpenGL vertex buffer and index buffer data intended to be copied directly into the GPU's memory, along with a small amount of metadata.
Data is rendered in GL_TRIANGLES mode using glDrawElements.
See "net/lax1dude/eaglercraft/v1_8/opengl/EaglerMeshLoader.java" and "net/lax1dude/eaglercraft/v1_8/opengl/HighPolyMesh.java" for more details.

View File

@ -129,6 +129,7 @@ eaglercraft.options.fastMath=Fast Math
eaglercraft.options.fastMath.0=OFF eaglercraft.options.fastMath.0=OFF
eaglercraft.options.fastMath.1=Low eaglercraft.options.fastMath.1=Low
eaglercraft.options.fastMath.2=High eaglercraft.options.fastMath.2=High
eaglercraft.options.dynamicLights=Dynamic Lights
eaglercraft.key.function=Function eaglercraft.key.function=Function
eaglercraft.key.zoomCamera=Zoom Camera eaglercraft.key.zoomCamera=Zoom Camera
@ -576,7 +577,12 @@ eaglercraft.singleplayer.demo.create.create.tooltip=Play the Minecraft 1.8 demo
eaglercraft.singleplayer.demo.create.join=Join Shared World eaglercraft.singleplayer.demo.create.join=Join Shared World
eaglercraft.singleplayer.demo.create.join.tooltip=Join someone else's world and play multiplayer eaglercraft.singleplayer.demo.create.join.tooltip=Join someone else's world and play multiplayer
eaglercraft.createWorld.seedNote=Note: Vanilla seeds do not work! eaglercraft.createWorld.seedNote=Note: Vanilla seeds now work!
eaglercraft.singleplayer.oldseedwarning.title=Old World Detected!
eaglercraft.singleplayer.oldseedwarning.msg1=Please use EaglercraftX u32 or older to "Re-Create" this world
eaglercraft.singleplayer.oldseedwarning.msg2=The world's seed will not be the same otherwise :(
eaglercraft.singleplayer.oldseedwarning.ok=OK
eaglercraft.singleplayer.outdatedLANServerKick=This is a 1.5.2 LAN world! eaglercraft.singleplayer.outdatedLANServerKick=This is a 1.5.2 LAN world!

View File

@ -1 +1 @@
{"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.3","pluginButton":"Download \"EaglerXBungee-1.2.3.jar\"","pluginFilename":"EaglerXBungee.zip"} {"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.5","pluginButton":"Download \"EaglerXBungee-1.2.5.jar\"","pluginFilename":"EaglerXBungee.zip"}

View File

@ -3,7 +3,7 @@ package net.lax1dude.eaglercraft.v1_8;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
/** /**
* Copyright (c) 2022 lax1dude. All Rights Reserved. * Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -25,19 +25,46 @@ public class EaglercraftRandom {
private static final double DOUBLE_UNIT = 0x1.0p-53; private static final double DOUBLE_UNIT = 0x1.0p-53;
private long seed = 69; private long seed = 69;
private final boolean enableScramble;
private static int yee = 0;
public EaglercraftRandom() { public EaglercraftRandom() {
this(PlatformRuntime.randomSeed()); this(PlatformRuntime.randomSeed());
} }
public EaglercraftRandom(long seed) { public EaglercraftRandom(long seed) {
this(seed, true);
}
public EaglercraftRandom(boolean scramble) {
this(PlatformRuntime.randomSeed(), scramble);
}
/**
* Older versions of EaglercraftX (and Eaglercraft) are missing the
* "initialScramble" function from their setSeed function, which was what caused
* world generation to not match vanilla. The "enableScramble" boolean is used
* when players play on an old world created before the bug was fixed.
*/
public EaglercraftRandom(long seed, boolean scramble) {
enableScramble = scramble;
setSeed(seed); setSeed(seed);
} }
private static long initialScramble(long seed) {
return (seed ^ multiplier) & mask;
}
public void setSeed(long yeed) { public void setSeed(long yeed) {
seed = yeed; if(enableScramble) {
seed = initialScramble(yeed);
}else {
seed = yeed;
}
haveNextNextGaussian = true;
}
public boolean isScramble() {
return enableScramble;
} }
protected int next(int bits) { protected int next(int bits) {

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork: /// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX"; public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u32"; public static final String projectForkVersion = "u34";
public static final String projectForkVendor = "lax1dude"; public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,7 +20,7 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX"; public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8"; public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u32"; public static final String projectOriginVersion = "u34";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
@ -31,7 +31,7 @@ public class EaglercraftVersion {
public static final boolean enableUpdateService = true; public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 32; public static final int updateBundlePackageVersionInt = 34;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -19,6 +19,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.StreamBuffer.StreamBufferInstance; import net.lax1dude.eaglercraft.v1_8.opengl.StreamBuffer.StreamBufferInstance;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f; import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f; import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -904,7 +905,9 @@ public class FixedFunctionPipeline {
_wglUniform3f(stateLightingAmbientUniform3f, r, g, b); _wglUniform3f(stateLightingAmbientUniform3f, r, g, b);
} }
} }
}
if(stateEnableMCLighting || DynamicLightsStateManager.isInDynamicLightsPass()) {
if(!stateHasAttribNormal) { if(!stateHasAttribNormal) {
serial = GlStateManager.stateNormalSerial; serial = GlStateManager.stateNormalSerial;
if(stateNormalSerial != serial) { if(stateNormalSerial != serial) {

View File

@ -808,6 +808,22 @@ public class GlStateManager {
} }
} }
public static final void getFloat(int pname, FloatBuffer params) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
modelMatrixStack[modelMatrixStackPointer].store(params);
break;
case GL_PROJECTION_MATRIX:
projectionMatrixStack[projectionMatrixStackPointer].store(params);
break;
case GL_TEXTURE_MATRIX:
textureMatrixStack[activeTexture][textureMatrixStackPointer[activeTexture]].store(params);
break;
default:
throw new UnsupportedOperationException("glGetFloat can only be used to retrieve matricies!");
}
}
public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) { public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
Matrix4f matrix; Matrix4f matrix;
switch(stateMatrixMode) { switch(stateMatrixMode) {

View File

@ -49,8 +49,8 @@ public class InstancedParticleRenderer {
private static IUniformGL u_matrixTransform = null; private static IUniformGL u_matrixTransform = null;
private static FloatBuffer matrixCopyBuffer = null; private static FloatBuffer matrixCopyBuffer = null;
private static IUniformGL u_texCoordSize2f_particleSize1f = null; private static IUniformGL u_texCoordSize2f_particleSize1f = null;
private static IUniformGL u_transformParam_1_2_3_4_f = null; private static IUniformGL u_transformParam_1_2_5_f = null;
private static IUniformGL u_transformParam_5_f = null; private static IUniformGL u_transformParam_3_4_f = null;
private static IUniformGL u_color4f = null; private static IUniformGL u_color4f = null;
private static IBufferArrayGL vertexArray = null; private static IBufferArrayGL vertexArray = null;
@ -154,8 +154,8 @@ public class InstancedParticleRenderer {
u_matrixTransform = _wglGetUniformLocation(shaderProgram, "u_matrixTransform"); u_matrixTransform = _wglGetUniformLocation(shaderProgram, "u_matrixTransform");
u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(shaderProgram, "u_texCoordSize2f_particleSize1f"); u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(shaderProgram, "u_texCoordSize2f_particleSize1f");
u_transformParam_1_2_3_4_f = _wglGetUniformLocation(shaderProgram, "u_transformParam_1_2_3_4_f"); u_transformParam_1_2_5_f = _wglGetUniformLocation(shaderProgram, "u_transformParam_1_2_5_f");
u_transformParam_5_f = _wglGetUniformLocation(shaderProgram, "u_transformParam_5_f"); u_transformParam_3_4_f = _wglGetUniformLocation(shaderProgram, "u_transformParam_3_4_f");
u_color4f = _wglGetUniformLocation(shaderProgram, "u_color4f"); u_color4f = _wglGetUniformLocation(shaderProgram, "u_color4f");
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0); _wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0);
@ -260,17 +260,17 @@ public class InstancedParticleRenderer {
} }
if (transformParam1 != stateTransformParam1 || transformParam2 != stateTransformParam2 if (transformParam1 != stateTransformParam1 || transformParam2 != stateTransformParam2
|| transformParam3 != stateTransformParam3 || transformParam4 != stateTransformParam4) { || transformParam5 != stateTransformParam5) {
_wglUniform4f(u_transformParam_1_2_3_4_f, transformParam1, transformParam2, transformParam3, transformParam4); _wglUniform3f(u_transformParam_1_2_5_f, transformParam1, transformParam2, transformParam5);
stateTransformParam1 = transformParam1; stateTransformParam1 = transformParam1;
stateTransformParam2 = transformParam2; stateTransformParam2 = transformParam2;
stateTransformParam3 = transformParam3; stateTransformParam5 = transformParam5;
stateTransformParam4 = transformParam4;
} }
if (transformParam5 != stateTransformParam5) { if (transformParam3 != stateTransformParam3 || transformParam4 != stateTransformParam4) {
_wglUniform1f(u_transformParam_5_f, transformParam5); _wglUniform2f(u_transformParam_3_4_f, transformParam3, transformParam4);
stateTransformParam5 = transformParam5; stateTransformParam3 = transformParam3;
stateTransformParam4 = transformParam4;
} }
int serial = GlStateManager.stateColorSerial; int serial = GlStateManager.stateColorSerial;
@ -319,4 +319,8 @@ public class InstancedParticleRenderer {
_wglDrawArraysInstanced(GL_TRIANGLES, 0, 6, particleCount); _wglDrawArraysInstanced(GL_TRIANGLES, 0, 6, particleCount);
} }
public static void stupidColorSetHack(IUniformGL color4f) {
_wglUniform4f(color4f, GlStateManager.stateColorR, GlStateManager.stateColorG, GlStateManager.stateColorB, GlStateManager.stateColorA);
}
} }

View File

@ -107,7 +107,7 @@ public class DeferredStateManager {
} }
public static final boolean isInDeferredPass() { public static final boolean isInDeferredPass() {
return GlStateManager.isExtensionPipeline(); return EaglerDeferredPipeline.instance != null && GlStateManager.isExtensionPipeline();
} }
public static final boolean isInForwardPass() { public static final boolean isInForwardPass() {
@ -153,10 +153,17 @@ public class DeferredStateManager {
} }
public static final void reportForwardRenderObjectPosition2(float x, float y, float z) { public static final void reportForwardRenderObjectPosition2(float x, float y, float z) {
float posX = (float)((x + TileEntityRendererDispatcher.staticPlayerX) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerX / 16.0) << 4)); EaglerDeferredPipeline instance = EaglerDeferredPipeline.instance;
float posY = (float)((y + TileEntityRendererDispatcher.staticPlayerY) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerY / 16.0) << 4)); if(instance != null && enableForwardRender) {
float posZ = (float)((z + TileEntityRendererDispatcher.staticPlayerZ) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerZ / 16.0) << 4)); EaglerDeferredConfig cfg = instance.config;
reportForwardRenderObjectPosition((int)posX, (int)posY, (int)posZ); if(!cfg.is_rendering_dynamicLights || !cfg.shaderPackInfo.DYNAMIC_LIGHTS) {
return;
}
float posX = (float)((x + TileEntityRendererDispatcher.staticPlayerX) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerX / 16.0) << 4));
float posY = (float)((y + TileEntityRendererDispatcher.staticPlayerY) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerY / 16.0) << 4));
float posZ = (float)((z + TileEntityRendererDispatcher.staticPlayerZ) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerZ / 16.0) << 4));
instance.loadLightSourceBucket((int)posX, (int)posY, (int)posZ);
}
} }
public static final void setHDRTranslucentPassBlendFunc() { public static final void setHDRTranslucentPassBlendFunc() {

View File

@ -2049,6 +2049,8 @@ public class EaglerDeferredPipeline {
} }
} }
truncateOverflowingLightBuffers();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER DYNAMIC LIGHTS"); DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER DYNAMIC LIGHTS");
} }
@ -2305,6 +2307,19 @@ public class EaglerDeferredPipeline {
return radius2 >= 0.0f; return radius2 >= 0.0f;
} }
private void truncateOverflowingLightBuffers() {
for(int i = 0; i < this.lightSourceBuckets.length; ++i) {
List<DynamicLightInstance> lst = this.lightSourceBuckets[i];
int k = lst.size();
if(k > MAX_LIGHTS_PER_CHUNK) {
lst.sort(comparatorLightRadius);
for(int l = MAX_LIGHTS_PER_CHUNK - 1; l >= MAX_LIGHTS_PER_CHUNK; --l) {
lst.remove(l);
}
}
}
}
public void updateLightSourceUBO() { public void updateLightSourceUBO() {
if(currentLightSourceBucket == null) { if(currentLightSourceBucket == null) {
currentBoundLightSourceBucket = null; currentBoundLightSourceBucket = null;
@ -2332,7 +2347,6 @@ public class EaglerDeferredPipeline {
} }
} }
private static final List<DynamicLightInstance> tmpListLights = new ArrayList(32);
private static final Comparator<DynamicLightInstance> comparatorLightRadius = (l1, l2) -> { private static final Comparator<DynamicLightInstance> comparatorLightRadius = (l1, l2) -> {
return l1.radius < l2.radius ? 1 : -1; return l1.radius < l2.radius ? 1 : -1;
}; };
@ -2340,10 +2354,6 @@ public class EaglerDeferredPipeline {
private void populateLightSourceUBOFromBucket(List<DynamicLightInstance> lights) { private void populateLightSourceUBOFromBucket(List<DynamicLightInstance> lights) {
int max = lights.size(); int max = lights.size();
if(max > MAX_LIGHTS_PER_CHUNK) { if(max > MAX_LIGHTS_PER_CHUNK) {
tmpListLights.clear();
tmpListLights.addAll(lights);
lights = tmpListLights;
lights.sort(comparatorLightRadius);
max = MAX_LIGHTS_PER_CHUNK; max = MAX_LIGHTS_PER_CHUNK;
} }
chunkLightingDataCopyBuffer.clear(); chunkLightingDataCopyBuffer.clear();

View File

@ -124,8 +124,13 @@ public class ForwardAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
shaderProgram.useProgram(); shaderProgram.useProgram();
_wglUniform3f(shaderProgram.uniforms.u_texCoordSize2f_particleSize1f, texCoordWidth, texCoordHeight, 0.0625f); _wglUniform3f(shaderProgram.uniforms.u_texCoordSize2f_particleSize1f, texCoordWidth, texCoordHeight, 0.0625f);
_wglUniform4f(shaderProgram.uniforms.u_transformParam_1_2_3_4_f, f1, f5, f2, f3); if(shaderProgram.uniforms.u_transformParam_1_2_5_f != null) {
_wglUniform1f(shaderProgram.uniforms.u_transformParam_5_f, f4); _wglUniform3f(shaderProgram.uniforms.u_transformParam_1_2_5_f, f1, f5, f4);
_wglUniform2f(shaderProgram.uniforms.u_transformParam_3_4_f, f2, f3);
}else {
_wglUniform4f(shaderProgram.uniforms.u_transformParam_1_2_3_4_f, f1, f5, f2, f3);
_wglUniform1f(shaderProgram.uniforms.u_transformParam_5_f, f4);
}
if(isMaterialNormalTexture) { if(isMaterialNormalTexture) {
_wglUniform2f(shaderProgram.uniforms.u_textureYScale2f, 0.5f, 0.5f); _wglUniform2f(shaderProgram.uniforms.u_textureYScale2f, 0.5f, 0.5f);
}else { }else {

View File

@ -124,8 +124,13 @@ public class GBufferAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
shaderProgram.useProgram(); shaderProgram.useProgram();
_wglUniform3f(shaderProgram.uniforms.u_texCoordSize2f_particleSize1f, texCoordWidth, texCoordHeight, 0.0625f); _wglUniform3f(shaderProgram.uniforms.u_texCoordSize2f_particleSize1f, texCoordWidth, texCoordHeight, 0.0625f);
_wglUniform4f(shaderProgram.uniforms.u_transformParam_1_2_3_4_f, f1, f5, f2, f3); if(shaderProgram.uniforms.u_transformParam_1_2_5_f != null) {
_wglUniform1f(shaderProgram.uniforms.u_transformParam_5_f, f4); _wglUniform3f(shaderProgram.uniforms.u_transformParam_1_2_5_f, f1, f5, f4);
_wglUniform2f(shaderProgram.uniforms.u_transformParam_3_4_f, f2, f3);
}else {
_wglUniform4f(shaderProgram.uniforms.u_transformParam_1_2_3_4_f, f1, f5, f2, f3);
_wglUniform1f(shaderProgram.uniforms.u_transformParam_5_f, f4);
}
if(isMaterialNormalTexture) { if(isMaterialNormalTexture) {
_wglUniform2f(shaderProgram.uniforms.u_textureYScale2f, 0.5f, 0.5f); _wglUniform2f(shaderProgram.uniforms.u_textureYScale2f, 0.5f, 0.5f);
}else { }else {

View File

@ -69,6 +69,8 @@ public class PipelineShaderAccelParticleForward extends ShaderProgram<PipelineSh
public IUniformGL u_texCoordSize2f_particleSize1f = null; public IUniformGL u_texCoordSize2f_particleSize1f = null;
public IUniformGL u_transformParam_1_2_3_4_f = null; public IUniformGL u_transformParam_1_2_3_4_f = null;
public IUniformGL u_transformParam_5_f = null; public IUniformGL u_transformParam_5_f = null;
public IUniformGL u_transformParam_1_2_5_f = null;
public IUniformGL u_transformParam_3_4_f = null;
public IUniformGL u_textureYScale2f = null; public IUniformGL u_textureYScale2f = null;
public int u_chunkLightingDataBlockBinding = -1; public int u_chunkLightingDataBlockBinding = -1;
@ -85,6 +87,8 @@ public class PipelineShaderAccelParticleForward extends ShaderProgram<PipelineSh
u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(prog, "u_texCoordSize2f_particleSize1f"); u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(prog, "u_texCoordSize2f_particleSize1f");
u_transformParam_1_2_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_3_4_f"); u_transformParam_1_2_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_3_4_f");
u_transformParam_5_f = _wglGetUniformLocation(prog, "u_transformParam_5_f"); u_transformParam_5_f = _wglGetUniformLocation(prog, "u_transformParam_5_f");
u_transformParam_1_2_5_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_5_f");
u_transformParam_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_3_4_f");
u_textureYScale2f = _wglGetUniformLocation(prog, "u_textureYScale2f"); u_textureYScale2f = _wglGetUniformLocation(prog, "u_textureYScale2f");
_wglUniform1i(_wglGetUniformLocation(prog, "u_diffuseTexture"), 0); _wglUniform1i(_wglGetUniformLocation(prog, "u_diffuseTexture"), 0);
_wglUniform1i(_wglGetUniformLocation(prog, "u_samplerNormalMaterial"), 2); _wglUniform1i(_wglGetUniformLocation(prog, "u_samplerNormalMaterial"), 2);

View File

@ -53,6 +53,8 @@ public class PipelineShaderAccelParticleGBuffer extends ShaderProgram<PipelineSh
public IUniformGL u_texCoordSize2f_particleSize1f = null; public IUniformGL u_texCoordSize2f_particleSize1f = null;
public IUniformGL u_transformParam_1_2_3_4_f = null; public IUniformGL u_transformParam_1_2_3_4_f = null;
public IUniformGL u_transformParam_5_f = null; public IUniformGL u_transformParam_5_f = null;
public IUniformGL u_transformParam_1_2_5_f = null;
public IUniformGL u_transformParam_3_4_f = null;
public IUniformGL u_textureYScale2f = null; public IUniformGL u_textureYScale2f = null;
private Uniforms() { private Uniforms() {
@ -64,6 +66,8 @@ public class PipelineShaderAccelParticleGBuffer extends ShaderProgram<PipelineSh
u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(prog, "u_texCoordSize2f_particleSize1f"); u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(prog, "u_texCoordSize2f_particleSize1f");
u_transformParam_1_2_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_3_4_f"); u_transformParam_1_2_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_3_4_f");
u_transformParam_5_f = _wglGetUniformLocation(prog, "u_transformParam_5_f"); u_transformParam_5_f = _wglGetUniformLocation(prog, "u_transformParam_5_f");
u_transformParam_1_2_5_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_5_f");
u_transformParam_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_3_4_f");
u_textureYScale2f = _wglGetUniformLocation(prog, "u_textureYScale2f"); u_textureYScale2f = _wglGetUniformLocation(prog, "u_textureYScale2f");
_wglUniform1i(_wglGetUniformLocation(prog, "u_diffuseTexture"), 0); _wglUniform1i(_wglGetUniformLocation(prog, "u_diffuseTexture"), 0);
_wglUniform1i(_wglGetUniformLocation(prog, "u_samplerNormalMaterial"), 2); _wglUniform1i(_wglGetUniformLocation(prog, "u_samplerNormalMaterial"), 2);

View File

@ -92,6 +92,11 @@ public class ShaderSource {
public static final ResourceLocation post_fxaa_fsh = new ResourceLocation("eagler:glsl/deferred/post_fxaa.fsh"); public static final ResourceLocation post_fxaa_fsh = new ResourceLocation("eagler:glsl/deferred/post_fxaa.fsh");
public static final ResourceLocation hand_depth_mask_fsh = new ResourceLocation("eagler:glsl/deferred/hand_depth_mask.fsh"); public static final ResourceLocation hand_depth_mask_fsh = new ResourceLocation("eagler:glsl/deferred/hand_depth_mask.fsh");
public static final ResourceLocation core_dynamiclights_vsh = new ResourceLocation("eagler:glsl/dynamiclights/core_dynamiclights.vsh");
public static final ResourceLocation core_dynamiclights_fsh = new ResourceLocation("eagler:glsl/dynamiclights/core_dynamiclights.fsh");
public static final ResourceLocation accel_particle_dynamiclights_vsh = new ResourceLocation("eagler:glsl/dynamiclights/accel_particle_dynamiclights.vsh");
public static final ResourceLocation accel_particle_dynamiclights_fsh = new ResourceLocation("eagler:glsl/dynamiclights/accel_particle_dynamiclights.fsh");
private static final Map<ResourceLocation, String> sourceCache = new HashMap(); private static final Map<ResourceLocation, String> sourceCache = new HashMap();
private static boolean isHighP = false; private static boolean isHighP = false;

View File

@ -0,0 +1,287 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ArrayListSerial;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredPipeline;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ListSerial;
import net.minecraft.util.MathHelper;
/**
* Copyright (c) 2023-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightBucketLoader {
public IBufferGL buffer_chunkLightingData;
private ByteBuffer chunkLightingDataCopyBuffer;
private boolean isChunkLightingEnabled = false;
public ListSerial<DynamicLightInstance> currentBoundLightSourceBucket;
public final ListSerial<DynamicLightInstance>[] lightSourceBuckets;
public ListSerial<DynamicLightInstance> currentLightSourceBucket;
public static final int MAX_LIGHTS_PER_CHUNK = 12;
private final int lightSourceBucketsWidth;
private final int lightSourceBucketsHeight;
private double currentRenderX = 0.0;
private double currentRenderY = 0.0;
private double currentRenderZ = 0.0;
public DynamicLightBucketLoader() {
this.lightSourceBucketsWidth = 5;
this.lightSourceBucketsHeight = 3;
int cnt = 5 * 3 * 5;
this.lightSourceBuckets = new ListSerial[cnt];
}
public void initialize() {
destroy();
buffer_chunkLightingData = _wglGenBuffers();
EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData);
int lightingDataLength = 4 * MAX_LIGHTS_PER_CHUNK + 4;
chunkLightingDataCopyBuffer = EagRuntime.allocateByteBuffer(lightingDataLength << 2);
for(int i = 0; i < lightingDataLength; ++i) {
chunkLightingDataCopyBuffer.putInt(0);
}
chunkLightingDataCopyBuffer.flip();
_wglBufferData(_GL_UNIFORM_BUFFER, chunkLightingDataCopyBuffer, GL_DYNAMIC_DRAW);
for(int i = 0; i < this.lightSourceBuckets.length; ++i) {
this.lightSourceBuckets[i] = new ArrayListSerial(16);
}
}
public void clearBuckets() {
for(int i = 0; i < this.lightSourceBuckets.length; ++i) {
this.lightSourceBuckets[i].clear();
}
}
public void loadLightSourceBucket(int relativeBlockX, int relativeBlockY, int relativeBlockZ) {
int hw = lightSourceBucketsWidth / 2;
int hh = lightSourceBucketsHeight / 2;
int bucketX = (relativeBlockX >> 4) + hw;
int bucketY = (relativeBlockY >> 4) + hh;
int bucketZ = (relativeBlockZ >> 4) + hw;
if(bucketX >= 0 && bucketY >= 0 && bucketZ >= 0 && bucketX < lightSourceBucketsWidth
&& bucketY < lightSourceBucketsHeight && bucketZ < lightSourceBucketsWidth) {
currentLightSourceBucket = lightSourceBuckets[bucketY * lightSourceBucketsWidth * lightSourceBucketsWidth
+ bucketZ * lightSourceBucketsWidth + bucketX];
}else {
currentLightSourceBucket = null;
}
updateLightSourceUBO();
}
public ListSerial<DynamicLightInstance> getLightSourceBucketRelativeChunkCoords(int cx, int cy, int cz) {
int hw = lightSourceBucketsWidth / 2;
int hh = lightSourceBucketsHeight / 2;
cx += hw;
cy += hh;
cz += hw;
if(cx < 0 || cx >= lightSourceBucketsWidth || cy < 0 || cy >= lightSourceBucketsHeight || cz < 0
|| cz >= lightSourceBucketsWidth) {
return null;
}else {
return lightSourceBuckets[cy * lightSourceBucketsWidth * lightSourceBucketsWidth
+ cz * lightSourceBucketsWidth + cx];
}
}
public void addLightSourceToBucket(int cx, int cy, int cz, DynamicLightInstance dl) {
ListSerial<DynamicLightInstance> lst = getLightSourceBucketRelativeChunkCoords(cx, cy, cz);
if(lst != null) {
lst.add(dl);
}
}
public void bucketLightSource(float x, float y, float z, DynamicLightInstance dl) {
int bucketX = MathHelper.floor_float(x / 16.0f);
int bucketY = MathHelper.floor_float(y / 16.0f);
int bucketZ = MathHelper.floor_float(z / 16.0f);
addLightSourceToBucket(bucketX, bucketY, bucketZ, dl);
int minX = bucketX, maxX = bucketX;
int minY = bucketY, maxY = bucketY;
int minZ = bucketZ, maxZ = bucketZ;
float lightLocalX = x - (bucketX << 4);
float lightLocalY = y - (bucketY << 4);
float lightLocalZ = z - (bucketZ << 4);
float radius = dl.radius;
boolean outOfBounds = false;
if(lightLocalX - radius < 0.0f) {
minX -= 1;
outOfBounds = true;
addLightSourceToBucket(bucketX - 1, bucketY, bucketZ, dl);
}
if(lightLocalY - radius < 0.0f) {
minY -= 1;
outOfBounds = true;
addLightSourceToBucket(bucketX, bucketY - 1, bucketZ, dl);
}
if(lightLocalZ - radius < 0.0f) {
minZ -= 1;
outOfBounds = true;
addLightSourceToBucket(bucketX, bucketY, bucketZ - 1, dl);
}
if(lightLocalX + radius >= 16.0f) {
maxX += 1;
outOfBounds = true;
addLightSourceToBucket(bucketX + 1, bucketY, bucketZ, dl);
}
if(lightLocalY + radius >= 16.0f) {
maxY += 1;
outOfBounds = true;
addLightSourceToBucket(bucketX, bucketY + 1, bucketZ, dl);
}
if(lightLocalZ + radius >= 16.0f) {
maxZ += 1;
outOfBounds = true;
addLightSourceToBucket(bucketX, bucketY, bucketZ + 1, dl);
}
if(!outOfBounds) {
return;
}
radius *= radius;
for(int yy = minY; yy <= maxY; ++yy) {
for(int zz = minZ; zz <= maxZ; ++zz) {
for(int xx = minX; xx <= maxX; ++xx) {
if((xx == bucketX ? 1 : 0) + (yy == bucketY ? 1 : 0) + (zz == bucketZ ? 1 : 0) > 1) {
continue;
}
List<DynamicLightInstance> lst = getLightSourceBucketRelativeChunkCoords(xx, yy, zz);
if(lst != null) {
int bucketBoundsX = xx << 4;
int bucketBoundsY = yy << 4;
int bucketBoundsZ = zz << 4;
if (EaglerDeferredPipeline.testAabSphere(bucketBoundsX, bucketBoundsY, bucketBoundsZ,
bucketBoundsX + 16, bucketBoundsY + 16, bucketBoundsZ + 16, x, y, z, radius)) {
lst.add(dl);
}
}
}
}
}
}
public void truncateOverflowingBuffers() {
for(int i = 0; i < this.lightSourceBuckets.length; ++i) {
List<DynamicLightInstance> lst = this.lightSourceBuckets[i];
int k = lst.size();
if(k > MAX_LIGHTS_PER_CHUNK) {
lst.sort(comparatorLightRadius);
for(int l = MAX_LIGHTS_PER_CHUNK - 1; l >= MAX_LIGHTS_PER_CHUNK; --l) {
lst.remove(l);
}
}
}
}
public void updateLightSourceUBO() {
if(currentLightSourceBucket == null) {
currentBoundLightSourceBucket = null;
if(isChunkLightingEnabled) {
isChunkLightingEnabled = false;
EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData);
chunkLightingDataCopyBuffer.clear();
chunkLightingDataCopyBuffer.putInt(0);
chunkLightingDataCopyBuffer.flip();
_wglBufferSubData(_GL_UNIFORM_BUFFER, 0, chunkLightingDataCopyBuffer);
}
}else {
boolean isNew;
if(!isChunkLightingEnabled) {
isChunkLightingEnabled = true;
isNew = true;
}else {
isNew = currentLightSourceBucket != currentBoundLightSourceBucket;
}
currentBoundLightSourceBucket = currentLightSourceBucket;
if(isNew || currentBoundLightSourceBucket.eaglerCheck()) {
populateLightSourceUBOFromBucket(currentBoundLightSourceBucket);
currentBoundLightSourceBucket.eaglerResetCheck();
}
}
}
private static final Comparator<DynamicLightInstance> comparatorLightRadius = (l1, l2) -> {
return l1.radius < l2.radius ? 1 : -1;
};
private void populateLightSourceUBOFromBucket(List<DynamicLightInstance> lights) {
int max = lights.size();
if(max > MAX_LIGHTS_PER_CHUNK) {
//tmpListLights.clear();
//tmpListLights.addAll(lights);
//lights = tmpListLights;
//lights.sort(comparatorLightRadius);
max = MAX_LIGHTS_PER_CHUNK;
}
chunkLightingDataCopyBuffer.clear();
chunkLightingDataCopyBuffer.putInt(max);
if(max > 0) {
chunkLightingDataCopyBuffer.putInt(0); //padding
chunkLightingDataCopyBuffer.putInt(0); //padding
chunkLightingDataCopyBuffer.putInt(0); //padding
for(int i = 0; i < max; ++i) {
DynamicLightInstance dl = lights.get(i);
chunkLightingDataCopyBuffer.putFloat((float)(dl.posX - currentRenderX));
chunkLightingDataCopyBuffer.putFloat((float)(dl.posY - currentRenderY));
chunkLightingDataCopyBuffer.putFloat((float)(dl.posZ - currentRenderZ));
chunkLightingDataCopyBuffer.putFloat(dl.radius);
}
}
chunkLightingDataCopyBuffer.flip();
EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData);
_wglBufferSubData(_GL_UNIFORM_BUFFER, 0, chunkLightingDataCopyBuffer);
}
public void setRenderPos(double currentRenderX, double currentRenderY, double currentRenderZ) {
this.currentRenderX = currentRenderX;
this.currentRenderY = currentRenderY;
this.currentRenderZ = currentRenderZ;
}
public void bindUniformBuffer(int index) {
EaglercraftGPU.bindGLUniformBuffer(buffer_chunkLightingData);
EaglercraftGPU.bindUniformBufferRange(index, buffer_chunkLightingData, 0, chunkLightingDataCopyBuffer.capacity());
}
public void destroy() {
if(chunkLightingDataCopyBuffer != null) {
EagRuntime.freeByteBuffer(chunkLightingDataCopyBuffer);
chunkLightingDataCopyBuffer = null;
}
if(buffer_chunkLightingData != null) {
_wglDeleteBuffers(buffer_chunkLightingData);
buffer_chunkLightingData = null;
}
for(int i = 0; i < this.lightSourceBuckets.length; ++i) {
this.lightSourceBuckets[i] = null;
}
}
}

View File

@ -0,0 +1,48 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
class DynamicLightInstance {
public final String lightName;
long lastCacheHit = 0l;
double posX;
double posY;
double posZ;
float radius;
public DynamicLightInstance(String lightName) {
this.lightName = lightName;
}
public void updateLight(double posX, double posY, double posZ, float radius) {
this.lastCacheHit = System.currentTimeMillis();
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.radius = radius;
}
public void destroy() {
}
public float getRadiusInWorld() {
return radius;
}
}

View File

@ -0,0 +1,230 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.InstancedParticleRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.AbstractAcceleratedEffectRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program.DynamicLightsAccelParticleShader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightsAcceleratedEffectRenderer extends AbstractAcceleratedEffectRenderer {
private static final Logger logger = LogManager.getLogger("DynamicLightsAcceleratedEffectRenderer");
private ByteBuffer particleBuffer = null;
private int particleCount = 0;
private boolean particlesHasOverflowed = false;
private static final int BYTES_PER_PARTICLE = 24;
private static final int PARTICLE_LIMIT = 5461;
private DynamicLightsAccelParticleShader shaderProgram = null;
private IBufferArrayGL vertexArray = null;
private IBufferGL vertexBuffer = null;
private IBufferGL instancesBuffer = null;
private float f1;
private float f2;
private float f3;
private float f4;
private float f5;
public static boolean isMaterialNormalTexture = false;
public void initialize() {
destroy();
if(DynamicLightsPipelineCompiler.matrixCopyBuffer == null) {
DynamicLightsPipelineCompiler.matrixCopyBuffer = GLAllocation.createDirectFloatBuffer(16);
}
shaderProgram = DynamicLightsAccelParticleShader.compile();
shaderProgram.loadUniforms();
particleBuffer = EagRuntime.allocateByteBuffer(PARTICLE_LIMIT * BYTES_PER_PARTICLE);
vertexArray = _wglGenVertexArrays();
vertexBuffer = _wglGenBuffers();
instancesBuffer = _wglGenBuffers();
FloatBuffer verts = EagRuntime.allocateFloatBuffer(12);
verts.put(new float[] {
-1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLArrayBuffer(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
EagRuntime.freeFloatBuffer(verts);
_wglEnableVertexAttribArray(0);
_wglVertexAttribPointer(0, 2, GL_FLOAT, false, 8, 0);
_wglVertexAttribDivisor(0, 0);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
_wglBufferData(GL_ARRAY_BUFFER, particleBuffer.remaining(), GL_STREAM_DRAW);
_wglEnableVertexAttribArray(1);
_wglVertexAttribPointer(1, 3, GL_FLOAT, false, 24, 0);
_wglVertexAttribDivisor(1, 1);
_wglEnableVertexAttribArray(2);
_wglVertexAttribPointer(2, 2, GL_UNSIGNED_SHORT, false, 24, 12);
_wglVertexAttribDivisor(2, 1);
_wglEnableVertexAttribArray(3);
_wglVertexAttribPointer(3, 2, GL_UNSIGNED_BYTE, true, 24, 16);
_wglVertexAttribDivisor(3, 1);
_wglEnableVertexAttribArray(4);
_wglVertexAttribPointer(4, 2, GL_UNSIGNED_BYTE, false, 24, 18);
_wglVertexAttribDivisor(4, 1);
_wglEnableVertexAttribArray(5);
_wglVertexAttribPointer(5, 4, GL_UNSIGNED_BYTE, true, 24, 20);
_wglVertexAttribDivisor(5, 1);
}
@Override
public void draw(float texCoordWidth, float texCoordHeight) {
if(particleCount == 0) {
return;
}
shaderProgram.useProgram();
_wglUniform3f(shaderProgram.uniforms.u_texCoordSize2f_particleSize1f, texCoordWidth, texCoordHeight, 0.0625f);
_wglUniform3f(shaderProgram.uniforms.u_transformParam_1_2_5_f, f1, f5, f4);
_wglUniform2f(shaderProgram.uniforms.u_transformParam_3_4_f, f2, f3);
InstancedParticleRenderer.stupidColorSetHack(shaderProgram.uniforms.u_color4f);
FloatBuffer buf = DynamicLightsPipelineCompiler.matrixCopyBuffer;
buf.clear();
GlStateManager.getFloat(GL_MODELVIEW_MATRIX, buf);
buf.flip();
_wglUniformMatrix4fv(shaderProgram.uniforms.u_modelViewMatrix4f, false, buf);
buf.clear();
GlStateManager.getFloat(GL_PROJECTION_MATRIX, buf);
buf.flip();
_wglUniformMatrix4fv(shaderProgram.uniforms.u_projectionMatrix4f, false, buf);
buf.clear();
DynamicLightsStateManager.inverseViewMatrix.store(buf);
buf.flip();
_wglUniformMatrix4fv(shaderProgram.uniforms.u_inverseViewMatrix4f, false, buf);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
int p = particleBuffer.position();
int l = particleBuffer.limit();
particleBuffer.flip();
_wglBufferSubData(GL_ARRAY_BUFFER, 0, particleBuffer);
particleBuffer.position(p);
particleBuffer.limit(l);
_wglDrawArraysInstanced(GL_TRIANGLES, 0, 6, particleCount);
}
@Override
public void begin(float partialTicks) {
this.partialTicks = partialTicks;
particleBuffer.clear();
particleCount = 0;
particlesHasOverflowed = false;
Entity et = Minecraft.getMinecraft().getRenderViewEntity();
if(et != null) {
f1 = MathHelper.cos(et.rotationYaw * 0.017453292F);
f2 = MathHelper.sin(et.rotationYaw * 0.017453292F);
f3 = -f2 * MathHelper.sin(et.rotationPitch * 0.017453292F);
f4 = f1 * MathHelper.sin(et.rotationPitch * 0.017453292F);
f5 = MathHelper.cos(et.rotationPitch * 0.017453292F);
}
}
@Override
public void drawParticle(float posX, float posY, float posZ, int particleIndexX, int particleIndexY,
int lightMapData, int texSize, float particleSize, int rgba) {
if(particlesHasOverflowed) {
return;
}
if(particleCount >= PARTICLE_LIMIT) {
particlesHasOverflowed = true;
logger.error("Particle buffer has overflowed! Exceeded {} particles, no more particles will be rendered.", PARTICLE_LIMIT);
return;
}
++particleCount;
ByteBuffer buf = particleBuffer;
buf.putFloat(posX);
buf.putFloat(posY);
buf.putFloat(posZ);
buf.putShort((short)particleIndexX);
buf.putShort((short)particleIndexY);
buf.put((byte)(lightMapData & 0xFF));
buf.put((byte)((lightMapData >> 16) & 0xFF));
buf.put((byte)(particleSize * 16.0f));
buf.put((byte)texSize);
buf.putInt(rgba);
}
public void destroy() {
if(particleBuffer != null) {
EagRuntime.freeByteBuffer(particleBuffer);
particleBuffer = null;
}
if(shaderProgram != null) {
shaderProgram.destroy();
shaderProgram = null;
}
if(vertexArray != null) {
_wglDeleteVertexArrays(vertexArray);
vertexArray = null;
}
if(vertexBuffer != null) {
_wglDeleteBuffers(vertexBuffer);
vertexBuffer = null;
}
if(instancesBuffer != null) {
_wglDeleteBuffers(instancesBuffer);
instancesBuffer = null;
}
}
}

View File

@ -0,0 +1,105 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionShader.FixedFunctionState;
import net.lax1dude.eaglercraft.v1_8.opengl.IExtPipelineCompiler;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program.DynamicLightsExtPipelineShader;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.minecraft.client.renderer.GLAllocation;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightsPipelineCompiler implements IExtPipelineCompiler {
static FloatBuffer matrixCopyBuffer = null;
private static class PipelineInstance {
private final int coreBits;
private final int extBits;
private DynamicLightsExtPipelineShader shader;
public PipelineInstance(int coreBits, int extBits) {
this.coreBits = coreBits;
this.extBits = extBits;
}
}
@Override
public String[] getShaderSource(int stateCoreBits, int stateExtBits, Object[] userPointer) {
if(matrixCopyBuffer == null) {
matrixCopyBuffer = GLAllocation.createDirectFloatBuffer(16);
}
userPointer[0] = new PipelineInstance(stateCoreBits, stateExtBits);
return new String[] {
ShaderSource.getSourceFor(ShaderSource.core_dynamiclights_vsh),
ShaderSource.getSourceFor(ShaderSource.core_dynamiclights_fsh)
};
}
@Override
public int getExtensionStatesCount() {
return 0;
}
@Override
public int getCurrentExtensionStateBits(int stateCoreBits) {
return 0;
}
@Override
public int getCoreStateMask(int stateExtBits) {
return 0xFFFFFFFF;
}
@Override
public void initializeNewShader(IProgramGL compiledProg, int stateCoreBits, int stateExtBits,
Object[] userPointer) {
DynamicLightsExtPipelineShader newShader = new DynamicLightsExtPipelineShader(compiledProg, stateCoreBits);
((PipelineInstance)userPointer[0]).shader = newShader;
newShader.loadUniforms();
}
@Override
public void updatePipeline(IProgramGL compiledProg, int stateCoreBits, int stateExtBits, Object[] userPointer) {
if((stateCoreBits & FixedFunctionState.STATE_ENABLE_LIGHTMAP) != 0) {
DynamicLightsExtPipelineShader.Uniforms uniforms = ((PipelineInstance)userPointer[0]).shader.uniforms;
if(uniforms.u_inverseViewMatrix4f != null) {
int serial = DynamicLightsStateManager.inverseViewMatrixSerial;
if(uniforms.inverseViewMatrixSerial != serial) {
uniforms.inverseViewMatrixSerial = serial;
FloatBuffer buf = matrixCopyBuffer;
buf.clear();
DynamicLightsStateManager.inverseViewMatrix.store(buf);
buf.flip();
_wglUniformMatrix4fv(uniforms.u_inverseViewMatrix4f, false, buf);
}
}
}
}
@Override
public void destroyPipeline(IProgramGL shaderProgram, int stateCoreBits, int stateExtBits, Object[] userPointer) {
}
}

View File

@ -0,0 +1,169 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionPipeline;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.MathHelper;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightsStateManager {
static final DynamicLightsPipelineCompiler deferredExtPipeline = new DynamicLightsPipelineCompiler();
static final Map<String, DynamicLightInstance> lightRenderers = new HashMap();
static final List<DynamicLightInstance> lightRenderList = new LinkedList();
static final Matrix4f inverseViewMatrix = new Matrix4f();
static int inverseViewMatrixSerial = 0;
static DynamicLightBucketLoader bucketLoader = null;
static DynamicLightsAcceleratedEffectRenderer accelParticleRenderer = null;
static int lastTotal = 0;
static long renderTimeout = 5000l;
private static long lastTick = 0l;
public static final void enableDynamicLightsRender() {
if(bucketLoader == null) {
bucketLoader = new DynamicLightBucketLoader();
bucketLoader.initialize();
bucketLoader.bindUniformBuffer(0);
FixedFunctionPipeline.loadExtensionPipeline(deferredExtPipeline);
}
if(accelParticleRenderer == null) {
accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer();
accelParticleRenderer.initialize();
}
}
public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
renderer.acceleratedParticleRenderer = accelParticleRenderer;
}
public static final void disableDynamicLightsRender(boolean unloadPipeline) {
if(bucketLoader != null) {
bucketLoader.destroy();
bucketLoader = null;
if(unloadPipeline) {
FixedFunctionPipeline.loadExtensionPipeline(null);
}
}
if(accelParticleRenderer != null) {
accelParticleRenderer.destroy();
accelParticleRenderer = null;
}
destroyAll();
lightRenderList.clear();
}
public static final boolean isDynamicLightsRender() {
return bucketLoader != null;
}
public static final boolean isInDynamicLightsPass() {
return GlStateManager.isExtensionPipeline() && bucketLoader != null;
}
public static final void reportForwardRenderObjectPosition(int centerX, int centerY, int centerZ) {
if(bucketLoader != null) {
bucketLoader.loadLightSourceBucket(centerX, centerY, centerZ);
}
}
public static final void reportForwardRenderObjectPosition2(float x, float y, float z) {
if(bucketLoader != null) {
float posX = (float)((x + TileEntityRendererDispatcher.staticPlayerX) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerX / 16.0) << 4));
float posY = (float)((y + TileEntityRendererDispatcher.staticPlayerY) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerY / 16.0) << 4));
float posZ = (float)((z + TileEntityRendererDispatcher.staticPlayerZ) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerZ / 16.0) << 4));
bucketLoader.loadLightSourceBucket((int)posX, (int)posY, (int)posZ);
}
}
public static final void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) {
if(bucketLoader != null) {
DynamicLightInstance dl = lightRenderers.get(lightName);
if(dl == null) {
lightRenderers.put(lightName, dl = new DynamicLightInstance(lightName));
}
dl.updateLight(posX, posY, posZ, radius);
lightRenderList.add(dl);
}
}
public static final void clearRenderList() {
lightRenderList.clear();
}
public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) {
updateTimers();
lastTotal = lightRenderList.size();
if(bucketLoader != null) {
bucketLoader.clearBuckets();
int entityChunkOriginX = MathHelper.floor_double(renderPosX / 16.0) << 4;
int entityChunkOriginY = MathHelper.floor_double(renderPosY / 16.0) << 4;
int entityChunkOriginZ = MathHelper.floor_double(renderPosZ / 16.0) << 4;
Iterator<DynamicLightInstance> itr = lightRenderList.iterator();
while(itr.hasNext()) {
DynamicLightInstance dl = itr.next();
float lightChunkPosX = (float)(dl.posX - entityChunkOriginX);
float lightChunkPosY = (float)(dl.posY - entityChunkOriginY);
float lightChunkPosZ = (float)(dl.posZ - entityChunkOriginZ);
bucketLoader.bucketLightSource(lightChunkPosX, lightChunkPosY, lightChunkPosZ, dl);
}
bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ);
bucketLoader.truncateOverflowingBuffers();
}
lightRenderList.clear();
}
public static final void setupInverseViewMatrix() {
Matrix4f.invert(GlStateManager.getModelViewReference(), inverseViewMatrix);
inverseViewMatrixSerial = GlStateManager.getModelViewSerial();
}
private static final void updateTimers() {
long millis = System.currentTimeMillis();
if(millis - lastTick > 1000l) {
lastTick = millis;
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator();
while(itr.hasNext()) {
DynamicLightInstance dl = itr.next();
if(millis - dl.lastCacheHit > renderTimeout) {
dl.destroy();
itr.remove();
}
}
}
}
public static final void destroyAll() {
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator();
while(itr.hasNext()) {
itr.next().destroy();
}
lightRenderers.clear();
}
public static String getF3String() {
return "DynamicLightsTotal: " + lastTotal;
}
}

View File

@ -0,0 +1,95 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_FRAGMENT_SHADER;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_VERTEX_SHADER;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.IProgramUniforms;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderCompiler;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderProgram;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightsAccelParticleShader extends ShaderProgram<DynamicLightsAccelParticleShader.Uniforms> {
public static DynamicLightsAccelParticleShader compile() {
IShaderGL accelParticleVSH = ShaderCompiler.compileShader("accel_particle_dynamiclights", GL_VERTEX_SHADER,
ShaderSource.accel_particle_dynamiclights_vsh);
IShaderGL accelParticleFSH = null;
try {
accelParticleFSH = ShaderCompiler.compileShader("accel_particle_dynamiclights", GL_FRAGMENT_SHADER,
ShaderSource.accel_particle_dynamiclights_fsh);
IProgramGL prog = ShaderCompiler.linkProgram("accel_particle_dynamiclights", accelParticleVSH, accelParticleFSH);
return new DynamicLightsAccelParticleShader(prog);
}finally {
if(accelParticleVSH != null) {
accelParticleVSH.free();
}
if(accelParticleFSH != null) {
accelParticleFSH.free();
}
}
}
private DynamicLightsAccelParticleShader(IProgramGL prog) {
super(prog, new Uniforms());
}
public static class Uniforms implements IProgramUniforms {
public IUniformGL u_color4f = null;
public IUniformGL u_modelViewMatrix4f = null;
public IUniformGL u_projectionMatrix4f = null;
public IUniformGL u_inverseViewMatrix4f = null;
public IUniformGL u_texCoordSize2f_particleSize1f = null;
public IUniformGL u_transformParam_1_2_5_f = null;
public IUniformGL u_transformParam_3_4_f = null;
public int u_chunkLightingDataBlockBinding = -1;
private Uniforms() {
}
@Override
public void loadUniforms(IProgramGL prog) {
u_modelViewMatrix4f = _wglGetUniformLocation(prog, "u_modelViewMatrix4f");
u_projectionMatrix4f = _wglGetUniformLocation(prog, "u_projectionMatrix4f");
u_inverseViewMatrix4f = _wglGetUniformLocation(prog, "u_inverseViewMatrix4f");
u_texCoordSize2f_particleSize1f = _wglGetUniformLocation(prog, "u_texCoordSize2f_particleSize1f");
u_transformParam_1_2_5_f = _wglGetUniformLocation(prog, "u_transformParam_1_2_5_f");
u_transformParam_3_4_f = _wglGetUniformLocation(prog, "u_transformParam_3_4_f");
u_color4f = _wglGetUniformLocation(prog, "u_color4f");
_wglUniform1i(_wglGetUniformLocation(prog, "u_inputTexture"), 0);
_wglUniform1i(_wglGetUniformLocation(prog, "u_lightmapTexture"), 1);
int blockIndex = _wglGetUniformBlockIndex(prog, "u_chunkLightingData");
if(blockIndex != -1) {
_wglUniformBlockBinding(prog, blockIndex, 0);
u_chunkLightingDataBlockBinding = 0;
}else {
u_chunkLightingDataBlockBinding = -1;
}
}
}
}

View File

@ -0,0 +1,58 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.IProgramUniforms;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderProgram;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DynamicLightsExtPipelineShader extends ShaderProgram<DynamicLightsExtPipelineShader.Uniforms> {
public final int coreState;
public DynamicLightsExtPipelineShader(IProgramGL program, int coreState) {
super(program, new Uniforms());
this.coreState = coreState;
}
public static class Uniforms implements IProgramUniforms {
public int u_chunkLightingDataBlockBinding = -1;
public int inverseViewMatrixSerial = -1;
public IUniformGL u_inverseViewMatrix4f = null;
Uniforms() {
}
@Override
public void loadUniforms(IProgramGL prog) {
u_inverseViewMatrix4f = _wglGetUniformLocation(prog, "u_inverseViewMatrix4f");
int blockIndex = _wglGetUniformBlockIndex(prog, "u_chunkLightingData");
if(blockIndex != -1) {
_wglUniformBlockBinding(prog, blockIndex, 0);
u_chunkLightingDataBlockBinding = 0;
}else {
u_chunkLightingDataBlockBinding = -1;
}
}
}
}

View File

@ -70,6 +70,8 @@ public class SingleplayerServerController implements ISaveFormat {
public static final ClientIntegratedServerNetworkManager localPlayerNetworkManager = new ClientIntegratedServerNetworkManager(PLAYER_CHANNEL); public static final ClientIntegratedServerNetworkManager localPlayerNetworkManager = new ClientIntegratedServerNetworkManager(PLAYER_CHANNEL);
private static final List<String> openLANChannels = new ArrayList(); private static final List<String> openLANChannels = new ArrayList();
private static final IPCPacketManager packetManagerInstance = new IPCPacketManager();
private SingleplayerServerController() { private SingleplayerServerController() {
} }
@ -247,7 +249,7 @@ public class SingleplayerServerController implements ISaveFormat {
if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) { if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) {
IPCPacketBase ipc; IPCPacketBase ipc;
try { try {
ipc = IPCPacketManager.IPCDeserialize(packetData.contents); ipc = packetManagerInstance.IPCDeserialize(packetData.contents);
}catch(IOException ex) { }catch(IOException ex) {
throw new RuntimeException("Failed to deserialize IPC packet", ex); throw new RuntimeException("Failed to deserialize IPC packet", ex);
} }
@ -402,7 +404,7 @@ public class SingleplayerServerController implements ISaveFormat {
public static void sendIPCPacket(IPCPacketBase ipc) { public static void sendIPCPacket(IPCPacketBase ipc) {
byte[] pkt; byte[] pkt;
try { try {
pkt = IPCPacketManager.IPCSerialize(ipc); pkt = packetManagerInstance.IPCSerialize(ipc);
}catch (IOException ex) { }catch (IOException ex) {
throw new RuntimeException("Failed to serialize IPC packet", ex); throw new RuntimeException("Failed to serialize IPC packet", ex);
} }

View File

@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.storage.WorldInfo; import net.minecraft.world.storage.WorldInfo;
/** /**
@ -38,6 +39,7 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
private GuiButton worldConvert = null; private GuiButton worldConvert = null;
private GuiButton worldBackup = null; private GuiButton worldBackup = null;
private long worldSeed; private long worldSeed;
private boolean oldRNG;
private NBTTagCompound levelDat; private NBTTagCompound levelDat;
private String worldName; private String worldName;
@ -47,6 +49,7 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
this.worldName = worldName; this.worldName = worldName;
this.levelDat = levelDat; this.levelDat = levelDat;
this.worldSeed = levelDat.getCompoundTag("Data").getLong("RandomSeed"); this.worldSeed = levelDat.getCompoundTag("Data").getLong("RandomSeed");
this.oldRNG = levelDat.getCompoundTag("Data").getInteger("eaglerVersionSerial") == 0;
} }
public void initGui() { public void initGui() {
@ -62,7 +65,11 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
this.drawDefaultBackground(); this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.title", worldName), this.width / 2, this.height / 5 - 35, 16777215); this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.title", worldName), this.width / 2, this.height / 5 - 35, 16777215);
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 62, 0xAAAAFF); if(oldRNG) {
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed + " " + EnumChatFormatting.RED + "(pre-u34)", this.width / 2, this.height / 5 + 62, 0xAAAAFF);
}else {
this.drawCenteredString(this.fontRendererObj, I18n.format("singleplayer.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 62, 0xAAAAFF);
}
int toolTipColor = 0xDDDDAA; int toolTipColor = 0xDDDDAA;
if(worldRecreate.isMouseOver()) { if(worldRecreate.isMouseOver()) {
@ -85,8 +92,13 @@ public class GuiScreenBackupWorldSelection extends GuiScreen {
this.mc.displayGuiScreen(selectWorld); this.mc.displayGuiScreen(selectWorld);
}else if(par1GuiButton.id == 1) { }else if(par1GuiButton.id == 1) {
GuiCreateWorld cw = new GuiCreateWorld(selectWorld); GuiCreateWorld cw = new GuiCreateWorld(selectWorld);
cw.func_146318_a(new WorldInfo(this.levelDat.getCompoundTag("Data"))); WorldInfo inf = new WorldInfo(this.levelDat.getCompoundTag("Data"));
this.mc.displayGuiScreen(cw); cw.func_146318_a(inf);
if(inf.isOldEaglercraftRandom()) {
this.mc.displayGuiScreen(new GuiScreenOldSeedWarning(cw));
}else {
this.mc.displayGuiScreen(cw);
}
}else if(par1GuiButton.id == 2) { }else if(par1GuiButton.id == 2) {
this.mc.displayGuiScreen(new GuiRenameWorld(this.selectWorld, this.worldName, true)); this.mc.displayGuiScreen(new GuiRenameWorld(this.selectWorld, this.worldName, true));
}else if(par1GuiButton.id == 3) { }else if(par1GuiButton.id == 3) {

View File

@ -0,0 +1,48 @@
package net.lax1dude.eaglercraft.v1_8.sp.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenOldSeedWarning extends GuiScreen {
private final GuiScreen cont;
public GuiScreenOldSeedWarning(GuiScreen cont) {
this.cont = cont;
}
public void initGui() {
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 96, I18n.format("singleplayer.oldseedwarning.ok")));
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.title"), this.width / 2, 70, 11184810);
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.msg1"), this.width / 2, 90, 16777215);
this.drawCenteredString(fontRendererObj, I18n.format("singleplayer.oldseedwarning.msg2"), this.width / 2, 105, 16777215);
super.drawScreen(par1, par2, par3);
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
this.mc.displayGuiScreen(cont);
}
}
}

View File

@ -25,11 +25,11 @@ public class IPCPacketManager {
public static final HashMap<Integer, Supplier<IPCPacketBase>> mappings = new HashMap(); public static final HashMap<Integer, Supplier<IPCPacketBase>> mappings = new HashMap();
public static final IPCInputStream IPC_INPUT_STREAM = new IPCInputStream(); public final IPCInputStream IPC_INPUT_STREAM = new IPCInputStream();
public static final IPCOutputStream IPC_OUTPUT_STREAM = new IPCOutputStream(); public final IPCOutputStream IPC_OUTPUT_STREAM = new IPCOutputStream();
public static final DataInputStream IPC_DATA_INPUT_STREAM = new DataInputStream(IPC_INPUT_STREAM); public final DataInputStream IPC_DATA_INPUT_STREAM = new DataInputStream(IPC_INPUT_STREAM);
public static final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM); public final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM);
static { static {
mappings.put(IPCPacket00StartServer.ID, IPCPacket00StartServer::new); mappings.put(IPCPacket00StartServer.ID, IPCPacket00StartServer::new);
@ -60,7 +60,7 @@ public class IPCPacketManager {
mappings.put(IPCPacketFFProcessKeepAlive.ID, IPCPacketFFProcessKeepAlive::new); mappings.put(IPCPacketFFProcessKeepAlive.ID, IPCPacketFFProcessKeepAlive::new);
} }
public static byte[] IPCSerialize(IPCPacketBase pkt) throws IOException { public byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {
IPC_OUTPUT_STREAM.feedBuffer(new byte[pkt.size() + 1], pkt.getClass().getSimpleName()); IPC_OUTPUT_STREAM.feedBuffer(new byte[pkt.size() + 1], pkt.getClass().getSimpleName());
IPC_OUTPUT_STREAM.write(pkt.id()); IPC_OUTPUT_STREAM.write(pkt.id());
@ -69,7 +69,7 @@ public class IPCPacketManager {
return IPC_OUTPUT_STREAM.returnBuffer(); return IPC_OUTPUT_STREAM.returnBuffer();
} }
public static IPCPacketBase IPCDeserialize(byte[] pkt) throws IOException { public IPCPacketBase IPCDeserialize(byte[] pkt) throws IOException {
IPC_INPUT_STREAM.feedBuffer(pkt); IPC_INPUT_STREAM.feedBuffer(pkt);
int i = IPC_INPUT_STREAM.read(); int i = IPC_INPUT_STREAM.read();

View File

@ -60,6 +60,8 @@ public class EaglerIntegratedServerWorker {
private static final Map<String, IntegratedServerPlayerNetworkManager> openChannels = new HashMap(); private static final Map<String, IntegratedServerPlayerNetworkManager> openChannels = new HashMap();
private static final IPCPacketManager packetManagerInstance = new IPCPacketManager();
private static void processAsyncMessageQueue() { private static void processAsyncMessageQueue() {
List<IPCPacketData> pktList = ServerPlatformSingleplayer.recieveAllPacket(); List<IPCPacketData> pktList = ServerPlatformSingleplayer.recieveAllPacket();
if(pktList != null) { if(pktList != null) {
@ -69,7 +71,7 @@ public class EaglerIntegratedServerWorker {
if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) { if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) {
IPCPacketBase ipc; IPCPacketBase ipc;
try { try {
ipc = IPCPacketManager.IPCDeserialize(packetData.contents); ipc = packetManagerInstance.IPCDeserialize(packetData.contents);
}catch(IOException ex) { }catch(IOException ex) {
throw new RuntimeException("Failed to deserialize IPC packet", ex); throw new RuntimeException("Failed to deserialize IPC packet", ex);
} }
@ -422,7 +424,7 @@ public class EaglerIntegratedServerWorker {
public static void sendIPCPacket(IPCPacketBase ipc) { public static void sendIPCPacket(IPCPacketBase ipc) {
byte[] pkt; byte[] pkt;
try { try {
pkt = IPCPacketManager.IPCSerialize(ipc); pkt = packetManagerInstance.IPCSerialize(ipc);
}catch (IOException ex) { }catch (IOException ex) {
throw new RuntimeException("Failed to serialize IPC packet", ex); throw new RuntimeException("Failed to serialize IPC packet", ex);
} }

View File

@ -12,6 +12,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker;
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat; import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.WorldInfo;
/** /**
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved. * Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
@ -66,6 +67,9 @@ public class WorldConverterEPK {
NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b)); NBTTagCompound worldDatNBT = CompressedStreamTools.readCompressed(new EaglerInputStream(b));
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName); worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis()); worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
if(has152Format) {
WorldInfo.initEaglerVersion(worldDatNBT.getCompoundTag("Data"));
}
EaglerOutputStream tmp = new EaglerOutputStream(); EaglerOutputStream tmp = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(worldDatNBT, tmp); CompressedStreamTools.writeCompressed(worldDatNBT, tmp);
b = tmp.toByteArray(); b = tmp.toByteArray();

View File

@ -20,6 +20,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerChunkLoader;
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker; import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker;
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat; import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerSaveFormat;
import net.minecraft.world.chunk.storage.RegionFile; import net.minecraft.world.chunk.storage.RegionFile;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -98,9 +99,9 @@ public class WorldConverterMCA {
gameRulesNBT.setString("colorCodes", s); gameRulesNBT.setString("colorCodes", s);
gameRulesNBT.setString("doSignEditing", s); gameRulesNBT.setString("doSignEditing", s);
worldDatNBT.getCompoundTag("Data").setTag("GameRules", gameRulesNBT); worldDatNBT.getCompoundTag("Data").setTag("GameRules", gameRulesNBT);
worldDatNBT.getCompoundTag("Data").setString("LevelName", newName); worldDatNBT.getCompoundTag("Data").setString("LevelName", newName);
worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis()); worldDatNBT.getCompoundTag("Data").setLong("LastPlayed", System.currentTimeMillis());
WorldInfo.initEaglerVersion(worldDatNBT.getCompoundTag("Data"));
EaglerOutputStream bo = new EaglerOutputStream(); EaglerOutputStream bo = new EaglerOutputStream();
CompressedStreamTools.writeCompressed(worldDatNBT, bo); CompressedStreamTools.writeCompressed(worldDatNBT, bo);
b = bo.toByteArray(); b = bo.toByteArray();

View File

@ -750,7 +750,18 @@ public class Minecraft implements IThreadListener {
} }
this.mcSoundHandler.unloadSounds(); this.mcSoundHandler.unloadSounds();
SingleplayerServerController.shutdownEaglercraftServer(); if (SingleplayerServerController.isWorldRunning()) {
SingleplayerServerController.shutdownEaglercraftServer();
while (SingleplayerServerController.getStatusState() == IntegratedServerState.WORLD_UNLOADING) {
EagUtils.sleep(50l);
SingleplayerServerController.runTick();
}
}
if (SingleplayerServerController.isIntegratedServerWorkerAlive()
&& SingleplayerServerController.canKillWorker()) {
SingleplayerServerController.killWorker();
EagUtils.sleep(50l);
}
} finally { } finally {
EagRuntime.destroy(); EagRuntime.destroy();
if (!this.hasCrashed) { if (!this.hasCrashed) {

View File

@ -20,6 +20,7 @@ import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformType; import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformType;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU; import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController; import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -394,6 +395,9 @@ public class GuiOverlayDebug extends Gui {
new Object[] { enumfacing, s, new Object[] { enumfacing, s,
Float.valueOf(MathHelper.wrapAngleTo180_float(entity.rotationYaw)), Float.valueOf(MathHelper.wrapAngleTo180_float(entity.rotationYaw)),
Float.valueOf(MathHelper.wrapAngleTo180_float(entity.rotationPitch)) }) }); Float.valueOf(MathHelper.wrapAngleTo180_float(entity.rotationPitch)) }) });
if (DynamicLightsStateManager.isDynamicLightsRender()) {
arraylist.add(6, DynamicLightsStateManager.getF3String());
}
if (this.mc.theWorld != null && this.mc.theWorld.isBlockLoaded(blockpos)) { if (this.mc.theWorld != null && this.mc.theWorld.isBlockLoaded(blockpos)) {
Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(blockpos); Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(blockpos);
arraylist.add("Biome: " + chunk.getBiome(blockpos, null).biomeName); arraylist.add("Biome: " + chunk.getBiome(blockpos, null).biomeName);

View File

@ -42,10 +42,10 @@ public class GuiVideoSettings extends GuiScreen {
GameSettings.Options.VIEW_BOBBING, GameSettings.Options.GUI_SCALE, GameSettings.Options.GAMMA, GameSettings.Options.VIEW_BOBBING, GameSettings.Options.GUI_SCALE, GameSettings.Options.GAMMA,
GameSettings.Options.RENDER_CLOUDS, GameSettings.Options.PARTICLES, GameSettings.Options.FXAA, GameSettings.Options.RENDER_CLOUDS, GameSettings.Options.PARTICLES, GameSettings.Options.FXAA,
GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.BLOCK_ALTERNATIVES, GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.BLOCK_ALTERNATIVES,
GameSettings.Options.ENTITY_SHADOWS, GameSettings.Options.FOG, GameSettings.Options.FULLSCREEN, GameSettings.Options.ENTITY_SHADOWS, GameSettings.Options.FOG, GameSettings.Options.EAGLER_DYNAMIC_LIGHTS,
GameSettings.Options.FNAW_SKINS, GameSettings.Options.HUD_FPS, GameSettings.Options.HUD_COORDS, GameSettings.Options.FULLSCREEN, GameSettings.Options.FNAW_SKINS, GameSettings.Options.HUD_FPS,
GameSettings.Options.HUD_PLAYER, GameSettings.Options.HUD_STATS, GameSettings.Options.HUD_WORLD, GameSettings.Options.HUD_COORDS, GameSettings.Options.HUD_PLAYER, GameSettings.Options.HUD_STATS,
GameSettings.Options.HUD_24H, GameSettings.Options.CHUNK_FIX }; GameSettings.Options.HUD_WORLD, GameSettings.Options.HUD_24H, GameSettings.Options.CHUNK_FIX };
public GuiVideoSettings(GuiScreen parentScreenIn, GameSettings gameSettingsIn) { public GuiVideoSettings(GuiScreen parentScreenIn, GameSettings gameSettingsIn) {
this.parentGuiScreen = parentScreenIn; this.parentGuiScreen = parentScreenIn;

View File

@ -280,4 +280,8 @@ public class EntityFX extends Entity {
+ this.particleRed + "," + this.particleGreen + "," + this.particleBlue + "," + this.particleAlpha + this.particleRed + "," + this.particleGreen + "," + this.particleBlue + "," + this.particleAlpha
+ "), Age " + this.particleAge; + "), Age " + this.particleAge;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 0.0f;
}
} }

View File

@ -4,6 +4,7 @@ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.BlockVertexIDs; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.BlockVertexIDs;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -55,6 +56,7 @@ public class BlockFluidRenderer {
WorldRenderer worldRendererIn) { WorldRenderer worldRendererIn) {
BlockPos tmp = new BlockPos(0, 0, 0); BlockPos tmp = new BlockPos(0, 0, 0);
boolean deferred = DeferredStateManager.isDeferredRenderer(); boolean deferred = DeferredStateManager.isDeferredRenderer();
boolean isDynamicLights = deferred || DynamicLightsStateManager.isDynamicLightsRender();
BlockLiquid blockliquid = (BlockLiquid) blockStateIn.getBlock(); BlockLiquid blockliquid = (BlockLiquid) blockStateIn.getBlock();
boolean lava = blockliquid.getMaterial() == Material.lava; boolean lava = blockliquid.getMaterial() == Material.lava;
boolean realistic = !lava && DeferredStateManager.isRenderingRealisticWater(); boolean realistic = !lava && DeferredStateManager.isRenderingRealisticWater();
@ -151,7 +153,7 @@ public class BlockFluidRenderer {
.tex((double) f15, (double) f19).lightmap(l2, i3).endVertex(); .tex((double) f15, (double) f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double) f10, d2 + 0.0D).color(f24, f25, f26, 1.0F) worldRendererIn.pos(d0 + 1.0D, d1 + (double) f10, d2 + 0.0D).color(f24, f25, f26, 1.0F)
.tex((double) f16, (double) f20).lightmap(l2, i3).endVertex(); .tex((double) f16, (double) f20).lightmap(l2, i3).endVertex();
if (deferred) if (isDynamicLights)
worldRendererIn.genNormals(true, f12 <= -999.0F ? BlockVertexIDs.builtin_water_still_vertex_id worldRendererIn.genNormals(true, f12 <= -999.0F ? BlockVertexIDs.builtin_water_still_vertex_id
: BlockVertexIDs.builtin_water_flow_vertex_id); : BlockVertexIDs.builtin_water_flow_vertex_id);
@ -164,7 +166,7 @@ public class BlockFluidRenderer {
.tex((double) f15, (double) f19).lightmap(l2, i3).endVertex(); .tex((double) f15, (double) f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double) f8, d2 + 1.0D).color(f24, f25, f26, 1.0F) worldRendererIn.pos(d0 + 0.0D, d1 + (double) f8, d2 + 1.0D).color(f24, f25, f26, 1.0F)
.tex((double) f14, (double) f18).lightmap(l2, i3).endVertex(); .tex((double) f14, (double) f18).lightmap(l2, i3).endVertex();
if (deferred) if (isDynamicLights)
worldRendererIn.genNormals(true, f12 <= -999.0F ? BlockVertexIDs.builtin_water_still_vertex_id worldRendererIn.genNormals(true, f12 <= -999.0F ? BlockVertexIDs.builtin_water_still_vertex_id
: BlockVertexIDs.builtin_water_flow_vertex_id); : BlockVertexIDs.builtin_water_flow_vertex_id);
} }
@ -186,7 +188,7 @@ public class BlockFluidRenderer {
.lightmap(i2, j2).endVertex(); .lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double) f36, (double) f38) worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double) f36, (double) f38)
.lightmap(i2, j2).endVertex(); .lightmap(i2, j2).endVertex();
if (deferred) if (isDynamicLights)
worldRendererIn.putNormal(0.0f, -1.0f, 0.0f, BlockVertexIDs.builtin_water_still_vertex_id); worldRendererIn.putNormal(0.0f, -1.0f, 0.0f, BlockVertexIDs.builtin_water_still_vertex_id);
flag2 = true; flag2 = true;
} }
@ -272,7 +274,7 @@ public class BlockFluidRenderer {
.lightmap(k, l).endVertex(); .lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F).tex((double) f41, (double) f30) worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F).tex((double) f41, (double) f30)
.lightmap(k, l).endVertex(); .lightmap(k, l).endVertex();
if (deferred) if (isDynamicLights)
worldRendererIn.putNormal(j1, 0.0f, k1, BlockVertexIDs.builtin_water_flow_vertex_id); worldRendererIn.putNormal(j1, 0.0f, k1, BlockVertexIDs.builtin_water_flow_vertex_id);
if (!realistic) { if (!realistic) {
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F) worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F)
@ -283,7 +285,7 @@ public class BlockFluidRenderer {
.tex((double) f27, (double) f29).lightmap(k, l).endVertex(); .tex((double) f27, (double) f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + (double) f39, d4).color(f32, f33, f34, 1.0F) worldRendererIn.pos(d3, d1 + (double) f39, d4).color(f32, f33, f34, 1.0F)
.tex((double) f41, (double) f28).lightmap(k, l).endVertex(); .tex((double) f41, (double) f28).lightmap(k, l).endVertex();
if (deferred) if (isDynamicLights)
worldRendererIn.putNormal(-j1, 0.0f, -k1, BlockVertexIDs.builtin_water_flow_vertex_id); worldRendererIn.putNormal(-j1, 0.0f, -k1, BlockVertexIDs.builtin_water_flow_vertex_id);
} }
} }

View File

@ -7,6 +7,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.VertexMarkerState; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.VertexMarkerState;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -139,6 +140,7 @@ public class BlockModelRenderer {
WorldRenderer worldRendererIn, List<BakedQuad> listQuadsIn, float[] quadBounds, BitSet boundsFlags, WorldRenderer worldRendererIn, List<BakedQuad> listQuadsIn, float[] quadBounds, BitSet boundsFlags,
BlockModelRenderer.AmbientOcclusionFace aoFaceIn) { BlockModelRenderer.AmbientOcclusionFace aoFaceIn) {
boolean isDeferred = DeferredStateManager.isDeferredRenderer(); boolean isDeferred = DeferredStateManager.isDeferredRenderer();
boolean isDynamicLights = isDeferred || DynamicLightsStateManager.isDynamicLightsRender();
double d0 = (double) blockPosIn.getX(); double d0 = (double) blockPosIn.getX();
double d1 = (double) blockPosIn.getY(); double d1 = (double) blockPosIn.getY();
double d2 = (double) blockPosIn.getZ(); double d2 = (double) blockPosIn.getZ();
@ -154,8 +156,9 @@ public class BlockModelRenderer {
for (int i = 0, l = listQuadsIn.size(); i < l; ++i) { for (int i = 0, l = listQuadsIn.size(); i < l; ++i) {
BakedQuad bakedquad = listQuadsIn.get(i); BakedQuad bakedquad = listQuadsIn.get(i);
int[] vertData = isDeferred ? bakedquad.getVertexDataWithNormals() : bakedquad.getVertexData(); int[] vertData = isDynamicLights ? bakedquad.getVertexDataWithNormals() : bakedquad.getVertexData();
this.fillQuadBounds(blockIn, vertData, bakedquad.getFace(), quadBounds, boundsFlags, isDeferred ? 8 : 7); this.fillQuadBounds(blockIn, vertData, bakedquad.getFace(), quadBounds, boundsFlags,
isDynamicLights ? 8 : 7);
aoFaceIn.updateVertexBrightness(blockAccessIn, blockIn, blockPosIn, bakedquad.getFace(), quadBounds, aoFaceIn.updateVertexBrightness(blockAccessIn, blockIn, blockPosIn, bakedquad.getFace(), quadBounds,
boundsFlags); boundsFlags);
worldRendererIn.addVertexData(vertData); worldRendererIn.addVertexData(vertData);
@ -272,6 +275,7 @@ public class BlockModelRenderer {
EnumFacing faceIn, int brightnessIn, boolean ownBrightness, WorldRenderer worldRendererIn, EnumFacing faceIn, int brightnessIn, boolean ownBrightness, WorldRenderer worldRendererIn,
List<BakedQuad> listQuadsIn, BitSet boundsFlags, float[] quadBounds) { List<BakedQuad> listQuadsIn, BitSet boundsFlags, float[] quadBounds) {
boolean isDeferred = DeferredStateManager.isDeferredRenderer(); boolean isDeferred = DeferredStateManager.isDeferredRenderer();
boolean isDynamicLights = isDeferred || DynamicLightsStateManager.isDynamicLightsRender();
double d0 = (double) blockPosIn.getX(); double d0 = (double) blockPosIn.getX();
double d1 = (double) blockPosIn.getY(); double d1 = (double) blockPosIn.getY();
double d2 = (double) blockPosIn.getZ(); double d2 = (double) blockPosIn.getZ();
@ -291,9 +295,9 @@ public class BlockModelRenderer {
for (int m = 0, n = listQuadsIn.size(); m < n; ++m) { for (int m = 0, n = listQuadsIn.size(); m < n; ++m) {
BakedQuad bakedquad = listQuadsIn.get(m); BakedQuad bakedquad = listQuadsIn.get(m);
EnumFacing facingIn = bakedquad.getFace(); EnumFacing facingIn = bakedquad.getFace();
int[] vertData = isDeferred ? bakedquad.getVertexDataWithNormals() : bakedquad.getVertexData(); int[] vertData = isDynamicLights ? bakedquad.getVertexDataWithNormals() : bakedquad.getVertexData();
blockPosIn.offsetEvenFaster(facingIn, blockpos0); blockPosIn.offsetEvenFaster(facingIn, blockpos0);
this.fillQuadBounds(blockIn, vertData, facingIn, quadBounds, boundsFlags, isDeferred ? 8 : 7); this.fillQuadBounds(blockIn, vertData, facingIn, quadBounds, boundsFlags, isDynamicLights ? 8 : 7);
boolean boundsFlags0 = boundsFlags.get(0); boolean boundsFlags0 = boundsFlags.get(0);
if (ownBrightness) { if (ownBrightness) {
brightnessIn = boundsFlags0 ? blockIn.getMixedBrightnessForBlock(blockAccessIn, blockpos0) brightnessIn = boundsFlags0 ? blockIn.getMixedBrightnessForBlock(blockAccessIn, blockpos0)

View File

@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.client.renderer.chunk.RenderChunk; import net.minecraft.client.renderer.chunk.RenderChunk;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.EnumWorldBlockLayer;
@ -53,10 +54,15 @@ public abstract class ChunkRenderContainer {
float posZ = (float) ((double) blockpos.getZ() - this.viewEntityZ); float posZ = (float) ((double) blockpos.getZ() - this.viewEntityZ);
GlStateManager.translate(posX, posY, posZ); GlStateManager.translate(posX, posY, posZ);
if (DeferredStateManager.isInForwardPass()) { if (DeferredStateManager.isInForwardPass()) {
posX = (float) (blockpos.getX() - (MathHelper.floor_double(this.viewEntityX / 16.0) << 4)); // TODO posX = (float) (blockpos.getX() - (MathHelper.floor_double(this.viewEntityX / 16.0) << 4));
posY = (float) (blockpos.getY() - (MathHelper.floor_double(this.viewEntityY / 16.0) << 4)); posY = (float) (blockpos.getY() - (MathHelper.floor_double(this.viewEntityY / 16.0) << 4));
posZ = (float) (blockpos.getZ() - (MathHelper.floor_double(this.viewEntityZ / 16.0) << 4)); posZ = (float) (blockpos.getZ() - (MathHelper.floor_double(this.viewEntityZ / 16.0) << 4));
DeferredStateManager.reportForwardRenderObjectPosition((int) posX, (int) posY, (int) posZ); DeferredStateManager.reportForwardRenderObjectPosition((int) posX, (int) posY, (int) posZ);
} else if (DynamicLightsStateManager.isInDynamicLightsPass()) {
posX = (float) (blockpos.getX() - (MathHelper.floor_double(this.viewEntityX / 16.0) << 4));
posY = (float) (blockpos.getY() - (MathHelper.floor_double(this.viewEntityY / 16.0) << 4));
posZ = (float) (blockpos.getZ() - (MathHelper.floor_double(this.viewEntityZ / 16.0) << 4));
DynamicLightsStateManager.reportForwardRenderObjectPosition((int) posX, (int) posY, (int) posZ);
} }
} }

View File

@ -33,6 +33,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.NameTagRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ShadersRenderPassFuture; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ShadersRenderPassFuture;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.gui.GuiShaderConfig; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.gui.GuiShaderConfig;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.EmissiveItems; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.EmissiveItems;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f; import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.lax1dude.eaglercraft.v1_8.voice.VoiceTagRenderer; import net.lax1dude.eaglercraft.v1_8.voice.VoiceTagRenderer;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f; import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
@ -653,6 +654,9 @@ public class EntityRenderer implements IResourceManagerReloadListener {
*/ */
private void renderHand(float partialTicks, int xOffset) { private void renderHand(float partialTicks, int xOffset) {
if (!this.debugView) { if (!this.debugView) {
if (DynamicLightsStateManager.isInDynamicLightsPass()) {
DynamicLightsStateManager.reportForwardRenderObjectPosition2(0.0f, 0.0f, 0.0f);
}
GlStateManager.matrixMode(GL_PROJECTION); GlStateManager.matrixMode(GL_PROJECTION);
GlStateManager.loadIdentity(); GlStateManager.loadIdentity();
float f = 0.07F; float f = 0.07F;
@ -848,7 +852,8 @@ public class EntityRenderer implements IResourceManagerReloadListener {
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
this.mc.getTextureManager().bindTexture(this.locationLightMap); this.mc.getTextureManager().bindTexture(this.locationLightMap);
if (mc.gameSettings.fancyGraphics || mc.gameSettings.ambientOcclusion > 0) { if (mc.gameSettings.fancyGraphics || mc.gameSettings.ambientOcclusion > 0
|| DynamicLightsStateManager.isDynamicLightsRender()) {
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else { } else {
@ -1098,14 +1103,27 @@ public class EntityRenderer implements IResourceManagerReloadListener {
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
GlStateManager.alphaFunc(GL_GREATER, 0.5F); GlStateManager.alphaFunc(GL_GREATER, 0.5F);
this.mc.mcProfiler.startSection("center"); this.mc.mcProfiler.startSection("center");
boolean dlights = DynamicLightsStateManager.isDynamicLightsRender();
if (dlights) {
updateDynamicLightListEagler(partialTicks);
}
if (this.mc.gameSettings.anaglyph && !this.mc.gameSettings.shaders) { if (this.mc.gameSettings.anaglyph && !this.mc.gameSettings.shaders) {
anaglyphField = 0; if (dlights) {
GlStateManager.colorMask(false, true, true, false); GlStateManager.enableExtensionPipeline();
this.renderWorldPass(0, partialTicks, finishTimeNano); }
anaglyphField = 1; try {
GlStateManager.colorMask(true, false, false, false); anaglyphField = 0;
this.renderWorldPass(1, partialTicks, finishTimeNano); GlStateManager.colorMask(false, true, true, false);
GlStateManager.colorMask(true, true, true, false); this.renderWorldPass(0, partialTicks, finishTimeNano);
anaglyphField = 1;
GlStateManager.colorMask(true, false, false, false);
this.renderWorldPass(1, partialTicks, finishTimeNano);
GlStateManager.colorMask(true, true, true, false);
} finally {
if (dlights) {
GlStateManager.disableExtensionPipeline();
}
}
} else { } else {
if (this.mc.gameSettings.shaders) { if (this.mc.gameSettings.shaders) {
try { try {
@ -1121,7 +1139,16 @@ public class EntityRenderer implements IResourceManagerReloadListener {
mc.effectRenderer.acceleratedParticleRenderer = EffectRenderer.vanillaAcceleratedParticleRenderer; mc.effectRenderer.acceleratedParticleRenderer = EffectRenderer.vanillaAcceleratedParticleRenderer;
} else { } else {
mc.effectRenderer.acceleratedParticleRenderer = EffectRenderer.vanillaAcceleratedParticleRenderer; mc.effectRenderer.acceleratedParticleRenderer = EffectRenderer.vanillaAcceleratedParticleRenderer;
this.renderWorldPass(2, partialTicks, finishTimeNano); if (dlights) {
GlStateManager.enableExtensionPipeline();
}
try {
this.renderWorldPass(2, partialTicks, finishTimeNano);
} finally {
if (dlights) {
GlStateManager.disableExtensionPipeline();
}
}
} }
} }
@ -1143,6 +1170,10 @@ public class EntityRenderer implements IResourceManagerReloadListener {
GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this.mc.mcProfiler.endStartSection("camera"); this.mc.mcProfiler.endStartSection("camera");
this.setupCameraTransform(partialTicks, pass); this.setupCameraTransform(partialTicks, pass);
boolean isDynamicLights = DynamicLightsStateManager.isDynamicLightsRender();
if (isDynamicLights) {
DynamicLightsStateManager.setupInverseViewMatrix();
}
ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2); ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2);
this.mc.mcProfiler.endStartSection("culling"); this.mc.mcProfiler.endStartSection("culling");
Frustum frustum = new Frustum(); Frustum frustum = new Frustum();
@ -1150,6 +1181,9 @@ public class EntityRenderer implements IResourceManagerReloadListener {
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks; double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks; double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks; double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
TileEntityRendererDispatcher.staticPlayerX = d0; // hack, needed for some eagler stuff
TileEntityRendererDispatcher.staticPlayerY = d1;
TileEntityRendererDispatcher.staticPlayerZ = d2;
frustum.setPosition(d0, d1, d2); frustum.setPosition(d0, d1, d2);
if (this.mc.gameSettings.renderDistanceChunks >= 4) { if (this.mc.gameSettings.renderDistanceChunks >= 4) {
this.setupFog(-1, partialTicks); this.setupFog(-1, partialTicks);
@ -1215,8 +1249,14 @@ public class EntityRenderer implements IResourceManagerReloadListener {
EntityPlayer entityplayer = (EntityPlayer) entity; EntityPlayer entityplayer = (EntityPlayer) entity;
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
this.mc.mcProfiler.endStartSection("outline"); this.mc.mcProfiler.endStartSection("outline");
if (isDynamicLights) {
GlStateManager.disableExtensionPipeline();
}
renderglobal.drawSelectionBox(entityplayer, this.mc.objectMouseOver, 0, partialTicks); renderglobal.drawSelectionBox(entityplayer, this.mc.objectMouseOver, 0, partialTicks);
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
if (isDynamicLights) {
GlStateManager.enableExtensionPipeline();
}
} }
} }
@ -1225,9 +1265,15 @@ public class EntityRenderer implements IResourceManagerReloadListener {
if (flag && this.mc.objectMouseOver != null && !entity.isInsideOfMaterial(Material.water)) { if (flag && this.mc.objectMouseOver != null && !entity.isInsideOfMaterial(Material.water)) {
EntityPlayer entityplayer1 = (EntityPlayer) entity; EntityPlayer entityplayer1 = (EntityPlayer) entity;
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
if (isDynamicLights) {
GlStateManager.disableExtensionPipeline();
}
this.mc.mcProfiler.endStartSection("outline"); this.mc.mcProfiler.endStartSection("outline");
renderglobal.drawSelectionBox(entityplayer1, this.mc.objectMouseOver, 0, partialTicks); renderglobal.drawSelectionBox(entityplayer1, this.mc.objectMouseOver, 0, partialTicks);
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
if (isDynamicLights) {
GlStateManager.enableExtensionPipeline();
}
} }
this.mc.mcProfiler.endStartSection("destroyProgress"); this.mc.mcProfiler.endStartSection("destroyProgress");
@ -1245,7 +1291,14 @@ public class EntityRenderer implements IResourceManagerReloadListener {
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
this.setupFog(0, partialTicks); this.setupFog(0, partialTicks);
this.mc.mcProfiler.endStartSection("particles"); this.mc.mcProfiler.endStartSection("particles");
if (isDynamicLights) {
DynamicLightsStateManager.bindAcceleratedEffectRenderer(effectrenderer);
DynamicLightsStateManager.reportForwardRenderObjectPosition2(0.0f, 0.0f, 0.0f);
}
effectrenderer.renderParticles(entity, partialTicks, 2); effectrenderer.renderParticles(entity, partialTicks, 2);
if (isDynamicLights) {
effectrenderer.acceleratedParticleRenderer = null;
}
this.disableLightmap(); this.disableLightmap();
} }
@ -1285,6 +1338,20 @@ public class EntityRenderer implements IResourceManagerReloadListener {
} }
private void updateDynamicLightListEagler(float partialTicks) {
DynamicLightsStateManager.clearRenderList();
Entity entity = this.mc.getRenderViewEntity();
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
AxisAlignedBB entityAABB = new AxisAlignedBB(d0 - 48.0, d1 - 32.0, d2 - 48.0, d0 + 48.0, d1 + 32.0, d2 + 48.0);
List<Entity> entities = this.mc.theWorld.getEntitiesWithinAABB(Entity.class, entityAABB);
for (int i = 0, l = entities.size(); i < l; ++i) {
entities.get(i).renderDynamicLightsEaglerSimple(partialTicks);
}
DynamicLightsStateManager.commitLightSourceBuckets(d0, d1, d2);
}
private void renderCloudsCheck(RenderGlobal renderGlobalIn, float partialTicks, int pass) { private void renderCloudsCheck(RenderGlobal renderGlobalIn, float partialTicks, int pass) {
if (this.mc.gameSettings.func_181147_e() != 0) { if (this.mc.gameSettings.func_181147_e() != 0) {
this.mc.mcProfiler.endStartSection("clouds"); this.mc.mcProfiler.endStartSection("clouds");
@ -1398,6 +1465,9 @@ public class EntityRenderer implements IResourceManagerReloadListener {
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GlStateManager.alphaFunc(GL_GREATER, 0.1F); GlStateManager.alphaFunc(GL_GREATER, 0.1F);
if (DynamicLightsStateManager.isInDynamicLightsPass()) {
DynamicLightsStateManager.reportForwardRenderObjectPosition2(0.0f, 0.0f, 0.0f);
}
} else { } else {
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
DeferredStateManager.setHDRTranslucentPassBlendFunc(); DeferredStateManager.setHDRTranslucentPassBlendFunc();

View File

@ -32,6 +32,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DynamicLightManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredConfig; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredConfig;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredPipeline; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredPipeline;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.SharedPipelineShaders; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.SharedPipelineShaders;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f; import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f; import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -466,6 +467,16 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
} }
SharedPipelineShaders.free(); SharedPipelineShaders.free();
} }
if (DeferredStateManager.isDeferredRenderer()) {
DynamicLightsStateManager.disableDynamicLightsRender(false);
} else {
if (mc.gameSettings.enableDynamicLights) {
DynamicLightsStateManager.enableDynamicLightsRender();
} else {
DynamicLightsStateManager.disableDynamicLightsRender(true);
}
}
} }
} }
@ -1948,8 +1959,10 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
if (!this.damagedBlocks.isEmpty()) { if (!this.damagedBlocks.isEmpty()) {
this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
this.preRenderDamagedBlocks(); this.preRenderDamagedBlocks();
worldRendererIn.begin(7, DeferredStateManager.isDeferredRenderer() ? VertexFormat.BLOCK_SHADERS worldRendererIn.begin(7,
: DefaultVertexFormats.BLOCK); (DeferredStateManager.isDeferredRenderer() || DynamicLightsStateManager.isDynamicLightsRender())
? VertexFormat.BLOCK_SHADERS
: DefaultVertexFormats.BLOCK);
worldRendererIn.setTranslation(-d0, -d1, -d2); worldRendererIn.setTranslation(-d0, -d1, -d2);
worldRendererIn.markDirty(); worldRendererIn.markDirty();
Iterator iterator = this.damagedBlocks.values().iterator(); Iterator iterator = this.damagedBlocks.values().iterator();
@ -1971,6 +1984,10 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
int i = destroyblockprogress.getPartialBlockDamage(); int i = destroyblockprogress.getPartialBlockDamage();
EaglerTextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i]; EaglerTextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i];
BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher(); BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
if (DynamicLightsStateManager.isInDynamicLightsPass()) {
DynamicLightsStateManager.reportForwardRenderObjectPosition2(blockpos.x, blockpos.y,
blockpos.z);
}
blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite,
this.theWorld); this.theWorld);
} }

View File

@ -5,6 +5,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.VertexMarkerState;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f; import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f; import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f; import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EnumFaceDirection; import net.minecraft.client.renderer.EnumFaceDirection;
import net.minecraft.client.resources.model.ModelRotation; import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -119,7 +120,9 @@ public class FaceBakery {
float[] sprite, EaglerTextureAtlasSprite modelRotationIn, ModelRotation partRotation, float[] sprite, EaglerTextureAtlasSprite modelRotationIn, ModelRotation partRotation,
BlockPartRotation uvLocked, boolean shade, boolean parFlag2, Vector3f calcNormal) { BlockPartRotation uvLocked, boolean shade, boolean parFlag2, Vector3f calcNormal) {
EnumFacing enumfacing = partRotation.rotateFace(facing); EnumFacing enumfacing = partRotation.rotateFace(facing);
int i = (parFlag2 && stride != 8) ? this.getFaceShadeColor(enumfacing) : -1; int i = (parFlag2 && (stride != 8 || !Minecraft.getMinecraft().gameSettings.shaders))
? this.getFaceShadeColor(enumfacing)
: -1;
EnumFaceDirection.VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.getFacing(facing) EnumFaceDirection.VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.getFacing(facing)
.func_179025_a(vertexIndex); .func_179025_a(vertexIndex);
Vector3f vector3f = new Vector3f(sprite[enumfacedirection$vertexinformation.field_179184_a], Vector3f vector3f = new Vector3f(sprite[enumfacedirection$vertexinformation.field_179184_a],
@ -139,9 +142,15 @@ public class FaceBakery {
faceData[i + 4 + 1] = Float faceData[i + 4 + 1] = Float
.floatToRawIntBits(sprite.getInterpolatedV((double) faceUV.func_178346_b(vertexIndex))); .floatToRawIntBits(sprite.getInterpolatedV((double) faceUV.func_178346_b(vertexIndex)));
if (stride == 8) { if (stride == 8) {
faceData[i] = Float.floatToRawIntBits(position.x * VertexMarkerState.localCoordDeriveHackX); if (!Minecraft.getMinecraft().gameSettings.shaders) {
faceData[i + 1] = Float.floatToRawIntBits(position.y * VertexMarkerState.localCoordDeriveHackY); faceData[i] = Float.floatToRawIntBits(position.x);
faceData[i + 2] = Float.floatToRawIntBits(position.z * VertexMarkerState.localCoordDeriveHackZ); faceData[i + 1] = Float.floatToRawIntBits(position.y);
faceData[i + 2] = Float.floatToRawIntBits(position.z);
} else {
faceData[i] = Float.floatToRawIntBits(position.x * VertexMarkerState.localCoordDeriveHackX);
faceData[i + 1] = Float.floatToRawIntBits(position.y * VertexMarkerState.localCoordDeriveHackY);
faceData[i + 2] = Float.floatToRawIntBits(position.z * VertexMarkerState.localCoordDeriveHackZ);
}
if (calcNormal != null) { if (calcNormal != null) {
int x = (byte) ((int) (calcNormal.x * 127.0F)) & 255; int x = (byte) ((int) (calcNormal.x * 127.0F)) & 255;
int y = (byte) ((int) (calcNormal.y * 127.0F)) & 255; int y = (byte) ((int) (calcNormal.y * 127.0F)) & 255;

View File

@ -13,6 +13,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat; import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -246,7 +247,9 @@ public class RenderChunk {
private void preRenderBlocks(WorldRenderer worldRendererIn, BlockPos pos) { private void preRenderBlocks(WorldRenderer worldRendererIn, BlockPos pos) {
worldRendererIn.begin(7, worldRendererIn.begin(7,
DeferredStateManager.isDeferredRenderer() ? VertexFormat.BLOCK_SHADERS : DefaultVertexFormats.BLOCK); (DeferredStateManager.isDeferredRenderer() || DynamicLightsStateManager.isDynamicLightsRender())
? VertexFormat.BLOCK_SHADERS
: DefaultVertexFormats.BLOCK);
worldRendererIn.setTranslation((double) (-pos.getX()), (double) (-pos.getY()), (double) (-pos.getZ())); worldRendererIn.setTranslation((double) (-pos.getX()), (double) (-pos.getY()), (double) (-pos.getZ()));
} }

View File

@ -4,6 +4,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat; import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -66,8 +67,10 @@ public class RenderFallingBlock extends Render<EntityFallingBlock> {
GlStateManager.disableLighting(); GlStateManager.disableLighting();
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer(); WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DeferredStateManager.isDeferredRenderer() ? VertexFormat.BLOCK_SHADERS worldrenderer.begin(7,
: DefaultVertexFormats.BLOCK); (DeferredStateManager.isDeferredRenderer()
|| DynamicLightsStateManager.isDynamicLightsRender()) ? VertexFormat.BLOCK_SHADERS
: DefaultVertexFormats.BLOCK);
int i = blockpos.getX(); int i = blockpos.getX();
int j = blockpos.getY(); int j = blockpos.getY();
int k = blockpos.getZ(); int k = blockpos.getZ();

View File

@ -9,6 +9,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper; import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.lax1dude.eaglercraft.v1_8.profile.RenderHighPoly; import net.lax1dude.eaglercraft.v1_8.profile.RenderHighPoly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockBed; import net.minecraft.block.BlockBed;
@ -332,6 +333,10 @@ public class RenderManager {
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks; double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks; double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks; double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
if (DynamicLightsStateManager.isInDynamicLightsPass()) {
DynamicLightsStateManager.reportForwardRenderObjectPosition2((float) (d0 - viewerPosX),
(float) (d1 - viewerPosY), (float) (d2 - viewerPosZ));
}
float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks; float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;
int i = entity.getBrightnessForRender(partialTicks); int i = entity.getBrightnessForRender(partialTicks);
if (entity.isBurning()) { if (entity.isBurning()) {

View File

@ -93,6 +93,8 @@ public class LayerSpiderEyes implements LayerRenderer<EntitySpider> {
this.spiderRenderer.bindTexture(SPIDER_EYES); this.spiderRenderer.bindTexture(SPIDER_EYES);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
GlStateManager.enablePolygonOffset();
GlStateManager.doPolygonOffset(-0.025f, 1.0f);
GlStateManager.blendFunc(GL_ONE, GL_ONE); GlStateManager.blendFunc(GL_ONE, GL_ONE);
if (entityspider.isInvisible()) { if (entityspider.isInvisible()) {
GlStateManager.depthMask(false); GlStateManager.depthMask(false);
@ -113,6 +115,7 @@ public class LayerSpiderEyes implements LayerRenderer<EntitySpider> {
this.spiderRenderer.func_177105_a(entityspider, f2); this.spiderRenderer.func_177105_a(entityspider, f2);
GlStateManager.disableBlend(); GlStateManager.disableBlend();
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
GlStateManager.disablePolygonOffset();
} }
public boolean shouldCombineTextures() { public boolean shouldCombineTextures() {

View File

@ -6,6 +6,7 @@ import com.google.common.collect.Maps;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper; import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
@ -146,6 +147,9 @@ public class TileEntityRendererDispatcher {
TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRenderer(tileEntityIn); TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRenderer(tileEntityIn);
if (tileentityspecialrenderer != null) { if (tileentityspecialrenderer != null) {
try { try {
if (DynamicLightsStateManager.isInDynamicLightsPass()) {
DynamicLightsStateManager.reportForwardRenderObjectPosition2((float) x, (float) y, (float) z);
}
tileentityspecialrenderer.renderTileEntityAt(tileEntityIn, x, y, z, partialTicks, destroyStage); tileentityspecialrenderer.renderTileEntityAt(tileEntityIn, x, y, z, partialTicks, destroyStage);
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Block Entity"); CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Block Entity");

View File

@ -202,6 +202,7 @@ public class GameSettings {
public EaglerDeferredConfig deferredShaderConf = new EaglerDeferredConfig(); public EaglerDeferredConfig deferredShaderConf = new EaglerDeferredConfig();
public boolean enableUpdateSvc = true; public boolean enableUpdateSvc = true;
public boolean enableFNAWSkins = true; public boolean enableFNAWSkins = true;
public boolean enableDynamicLights = false;
public int voiceListenRadius = 16; public int voiceListenRadius = 16;
public float voiceListenVolume = 0.5f; public float voiceListenVolume = 0.5f;
@ -465,6 +466,11 @@ public class GameSettings {
this.enableVsync = !this.enableVsync; this.enableVsync = !this.enableVsync;
} }
if (parOptions == GameSettings.Options.EAGLER_DYNAMIC_LIGHTS) {
this.enableDynamicLights = !this.enableDynamicLights;
this.mc.renderGlobal.loadRenderers();
}
this.saveOptions(); this.saveOptions();
} }
@ -541,6 +547,8 @@ public class GameSettings {
return this.enableFNAWSkins; return this.enableFNAWSkins;
case EAGLER_VSYNC: case EAGLER_VSYNC:
return this.enableVsync; return this.enableVsync;
case EAGLER_DYNAMIC_LIGHTS:
return this.enableDynamicLights;
default: default:
return false; return false;
} }
@ -986,6 +994,10 @@ public class GameSettings {
this.enableFNAWSkins = astring[1].equals("true"); this.enableFNAWSkins = astring[1].equals("true");
} }
if (astring[0].equals("enableDynamicLights")) {
this.enableDynamicLights = astring[1].equals("true");
}
deferredShaderConf.readOption(astring[0], astring[1]); deferredShaderConf.readOption(astring[0], astring[1]);
} catch (Exception var8) { } catch (Exception var8) {
logger.warn("Skipping bad option: " + s); logger.warn("Skipping bad option: " + s);
@ -1104,6 +1116,7 @@ public class GameSettings {
printwriter.println("voiceSpeakVolume:" + this.voiceSpeakVolume); printwriter.println("voiceSpeakVolume:" + this.voiceSpeakVolume);
printwriter.println("voicePTTKey:" + this.voicePTTKey); printwriter.println("voicePTTKey:" + this.voicePTTKey);
printwriter.println("enableFNAWSkins:" + this.enableFNAWSkins); printwriter.println("enableFNAWSkins:" + this.enableFNAWSkins);
printwriter.println("enableDynamicLights:" + this.enableDynamicLights);
for (KeyBinding keybinding : this.keyBindings) { for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1206,7 +1219,7 @@ public class GameSettings {
INVERT_MOUSE("options.invertMouse", false, true), SENSITIVITY("options.sensitivity", true, false), INVERT_MOUSE("options.invertMouse", false, true), SENSITIVITY("options.sensitivity", true, false),
FOV("options.fov", true, false, 30.0F, 110.0F, 1.0F), GAMMA("options.gamma", true, false), FOV("options.fov", true, false, 30.0F, 110.0F, 1.0F), GAMMA("options.gamma", true, false),
SATURATION("options.saturation", true, false), SATURATION("options.saturation", true, false),
RENDER_DISTANCE("options.renderDistance", true, false, 1.0F, 16.0F, 1.0F), RENDER_DISTANCE("options.renderDistance", true, false, 1.0F, 18.0F, 1.0F),
VIEW_BOBBING("options.viewBobbing", false, true), ANAGLYPH("options.anaglyph", false, true), VIEW_BOBBING("options.viewBobbing", false, true), ANAGLYPH("options.anaglyph", false, true),
FRAMERATE_LIMIT("options.framerateLimit", true, false, 10.0F, 260.0F, 10.0F), FRAMERATE_LIMIT("options.framerateLimit", true, false, 10.0F, 260.0F, 10.0F),
FBO_ENABLE("options.fboEnable", false, true), RENDER_CLOUDS("options.renderClouds", false, false), FBO_ENABLE("options.fboEnable", false, true), RENDER_CLOUDS("options.renderClouds", false, false),
@ -1238,7 +1251,7 @@ public class GameSettings {
FOG("options.fog", false, true), FXAA("options.fxaa", false, false), FOG("options.fog", false, true), FXAA("options.fxaa", false, false),
FULLSCREEN("options.fullscreen", false, true), FULLSCREEN("options.fullscreen", false, true),
FNAW_SKINS("options.skinCustomisation.enableFNAWSkins", false, true), FNAW_SKINS("options.skinCustomisation.enableFNAWSkins", false, true),
EAGLER_VSYNC("options.vsync", false, true); EAGLER_VSYNC("options.vsync", false, true), EAGLER_DYNAMIC_LIGHTS("options.dynamicLights", false, true);
private final boolean enumFloat; private final boolean enumFloat;
private final boolean enumBoolean; private final boolean enumBoolean;

View File

@ -5,6 +5,7 @@ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.lax1dude.eaglercraft.v1_8.HString; import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DynamicLightManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DynamicLightManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.DynamicLightsStateManager;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -1013,7 +1014,12 @@ public abstract class Entity implements ICommandSender {
public int getBrightnessForRender(float var1) { public int getBrightnessForRender(float var1) {
BlockPos blockpos = new BlockPos(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ); BlockPos blockpos = new BlockPos(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ);
return this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getCombinedLight(blockpos, 0) : 0; int i = 0;
if (DynamicLightsStateManager.isDynamicLightsRender()) {
i += (int) (getEaglerDynamicLightsValueSimple(var1) * 15.0f);
}
return this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getCombinedLight(blockpos, -i)
: (i > 15 ? 240 : (i << 4));
} }
/**+ /**+
@ -1021,7 +1027,11 @@ public abstract class Entity implements ICommandSender {
*/ */
public float getBrightness(float var1) { public float getBrightness(float var1) {
BlockPos blockpos = new BlockPos(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ); BlockPos blockpos = new BlockPos(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ);
return this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getLightBrightness(blockpos) : 0.0F; float f = this.worldObj.isBlockLoaded(blockpos) ? this.worldObj.getLightBrightness(blockpos) : 0.0F;
if (DynamicLightsStateManager.isDynamicLightsRender()) {
f = Math.min(f + getEaglerDynamicLightsValueSimple(var1), 1.0f);
}
return f;
} }
/**+ /**+
@ -2380,7 +2390,8 @@ public abstract class Entity implements ICommandSender {
double entityX2 = entityX - TileEntityRendererDispatcher.staticPlayerX; double entityX2 = entityX - TileEntityRendererDispatcher.staticPlayerX;
double entityY2 = entityY - TileEntityRendererDispatcher.staticPlayerY; double entityY2 = entityY - TileEntityRendererDispatcher.staticPlayerY;
double entityZ2 = entityZ - TileEntityRendererDispatcher.staticPlayerZ; double entityZ2 = entityZ - TileEntityRendererDispatcher.staticPlayerZ;
if (Math.sqrt(entityX2 * entityX2 + entityY2 * entityY2 + entityZ2 * entityZ2) < 48.0 * 48.0) { if (entityX2 * entityX2 + entityY2 * entityY2
+ entityZ2 * entityZ2 < (isInFrustum ? (64.0 * 64.0) : (24.0 * 24.0))) {
renderDynamicLightsEaglerAt(entityX, entityY, entityZ, entityX2, entityY2, entityZ2, partialTicks, renderDynamicLightsEaglerAt(entityX, entityY, entityZ, entityX2, entityY2, entityZ2, partialTicks,
isInFrustum); isInFrustum);
} }
@ -2388,14 +2399,41 @@ public abstract class Entity implements ICommandSender {
protected void renderDynamicLightsEaglerAt(double entityX, double entityY, double entityZ, double renderX, protected void renderDynamicLightsEaglerAt(double entityX, double entityY, double entityZ, double renderX,
double renderY, double renderZ, float partialTicks, boolean isInFrustum) { double renderY, double renderZ, float partialTicks, boolean isInFrustum) {
float size = Math.max(width, height);
if (size < 1.0f && !isInFrustum) {
return;
}
if (this.isBurning()) { if (this.isBurning()) {
float size = Math.max(width, height);
if (size < 1.0f && !isInFrustum) {
return;
}
float mag = 5.0f * size; float mag = 5.0f * size;
DynamicLightManager.renderDynamicLight("entity_" + entityId + "_fire", entityX, entityY + height * 0.75, DynamicLightManager.renderDynamicLight("entity_" + entityId + "_fire", entityX, entityY + height * 0.75,
entityZ, mag, 0.487f * mag, 0.1411f * mag, false); entityZ, mag, 0.487f * mag, 0.1411f * mag, false);
} }
} }
public void renderDynamicLightsEaglerSimple(float partialTicks) {
double entityX = prevPosX + (posX - prevPosX) * (double) partialTicks;
double entityY = prevPosY + (posY - prevPosY) * (double) partialTicks;
double entityZ = prevPosZ + (posZ - prevPosZ) * (double) partialTicks;
renderDynamicLightsEaglerSimpleAt(entityX, entityY, entityZ, partialTicks);
}
protected void renderDynamicLightsEaglerSimpleAt(double entityX, double entityY, double entityZ,
float partialTicks) {
float renderBrightness = this.getEaglerDynamicLightsValueSimple(partialTicks);
if (renderBrightness > 0.1f) {
DynamicLightsStateManager.renderDynamicLight("entity_" + entityId + "_lightmap", entityX,
entityY + height * 0.85, entityZ, renderBrightness * 13.0f);
}
}
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float size = Math.max(width, height);
if (size < 1.0f) {
return 0.0f;
}
if (this.isBurning()) {
return size / 2.0f;
}
return 0.0f;
}
} }

View File

@ -1911,4 +1911,16 @@ public abstract class EntityLivingBase extends Entity {
} }
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
ItemStack itm = this.getHeldItem();
if (itm != null && itm.stackSize > 0) {
Item item = itm.getItem();
if (item != null) {
float f2 = item.getHeldItemBrightnessEagler();
f = Math.min(f + f2 * 0.5f, 1.0f) + f2 * 0.5f;
}
}
return f;
}
} }

View File

@ -520,6 +520,10 @@ public class EntityWither extends EntityMob implements IBossDisplayData, IRanged
return 15728880; return 15728880;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 1.0f;
}
public void fall(float var1, float var2) { public void fall(float var1, float var2) {
} }

View File

@ -1,5 +1,6 @@
package net.minecraft.entity.item; package net.minecraft.entity.item;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DynamicLightManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -211,6 +212,21 @@ public class EntityEnderEye extends Entity {
return 1.0F; return 1.0F;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 0.5f;
}
protected void renderDynamicLightsEaglerAt(double entityX, double entityY, double entityZ, double renderX,
double renderY, double renderZ, float partialTicks, boolean isInFrustum) {
super.renderDynamicLightsEaglerAt(entityX, entityY, entityZ, renderX, renderY, renderZ, partialTicks,
isInFrustum);
if (isInFrustum && renderX * renderX + renderY * renderY + renderZ * renderZ < 150.0) {
float mag = 0.5f;
DynamicLightManager.renderDynamicLight("entity_" + getEntityId() + "_endereye", entityX, entityY + 0.2,
entityZ, mag * 0.1990f, mag * 0.7750f, mag * 0.4130f, false);
}
}
public int getBrightnessForRender(float var1) { public int getBrightnessForRender(float var1) {
return 15728880; return 15728880;
} }

View File

@ -196,6 +196,10 @@ public class EntityFireworkRocket extends Entity {
return super.getBrightness(f); return super.getBrightness(f);
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 1.0f;
}
public int getBrightnessForRender(float f) { public int getBrightnessForRender(float f) {
return super.getBrightnessForRender(f); return super.getBrightnessForRender(f);
} }

View File

@ -475,4 +475,17 @@ public class EntityItem extends Entity {
isInFrustum); isInFrustum);
eaglerEmissiveFlag = Minecraft.getMinecraft().entityRenderer.renderItemEntityLight(this, 0.1f); eaglerEmissiveFlag = Minecraft.getMinecraft().entityRenderer.renderItemEntityLight(this, 0.1f);
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
ItemStack itm = this.getEntityItem();
if (itm != null && itm.stackSize > 0) {
Item item = itm.getItem();
if (item != null) {
float f2 = item.getHeldItemBrightnessEagler() * 0.75f;
f = Math.min(f + f2 * 0.5f, 1.0f) + f2 * 0.5f;
}
}
return f;
}
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.entity.EntityHanging;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMap; import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -252,4 +253,17 @@ public class EntityItemFrame extends EntityHanging {
isInFrustum); isInFrustum);
eaglerEmissiveFlag = Minecraft.getMinecraft().entityRenderer.renderItemEntityLight(this, 0.1f); eaglerEmissiveFlag = Minecraft.getMinecraft().entityRenderer.renderItemEntityLight(this, 0.1f);
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
ItemStack itm = this.getDisplayedItem();
if (itm != null && itm.stackSize > 0) {
Item item = itm.getItem();
if (item != null) {
float f2 = item.getHeldItemBrightnessEagler() * 0.75f;
f = Math.min(f + f2 * 0.5f, 1.0f) + f2 * 0.5f;
}
}
return f;
}
} }

View File

@ -227,4 +227,12 @@ public class EntityMinecartTNT extends EntityMinecart {
entityZ, dynamicLightMag, dynamicLightMag * 0.7792f, dynamicLightMag * 0.618f, false); entityZ, dynamicLightMag, dynamicLightMag * 0.7792f, dynamicLightMag * 0.618f, false);
} }
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
if (minecartTNTFuse > -1 && minecartTNTFuse / 5 % 2 == 0) {
f = Math.min(f + 0.75f, 1.25f);
}
return f;
}
} }

View File

@ -145,4 +145,12 @@ public class EntityTNTPrimed extends Entity {
entityZ, dynamicLightMag, dynamicLightMag * 0.7792f, dynamicLightMag * 0.618f, false); entityZ, dynamicLightMag, dynamicLightMag * 0.7792f, dynamicLightMag * 0.618f, false);
} }
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
if (fuse / 5 % 2 == 0) {
f = Math.min(f + 0.75f, 1.25f);
}
return f;
}
} }

View File

@ -84,6 +84,10 @@ public class EntityXPOrb extends Entity {
return j | k << 16; return j | k << 16;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 0.25f;
}
/**+ /**+
* Called to update the entity's position/logic. * Called to update the entity's position/logic.
*/ */

View File

@ -104,6 +104,10 @@ public class EntityBlaze extends EntityMob {
return 1.0F; return 1.0F;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 1.0f;
}
/**+ /**+
* Called frequently so the entity can update its state every * Called frequently so the entity can update its state every
* tick as required. For example, zombies and skeletons use this * tick as required. For example, zombies and skeletons use this

View File

@ -306,4 +306,13 @@ public class EntityCreeper extends EntityMob {
DeferredStateManager.setEmissionConstant(1.0f); DeferredStateManager.setEmissionConstant(1.0f);
} }
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
float f = super.getEaglerDynamicLightsValueSimple(partialTicks);
float ff = getCreeperFlashIntensity(partialTicks);
if ((int) (ff * 10.0F) % 2 != 0) {
f = Math.min(f + 0.5f, 1.15f);
}
return f;
}
} }

View File

@ -75,6 +75,10 @@ public class EntityMagmaCube extends EntitySlime {
return 1.0F; return 1.0F;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 1.0f;
}
protected EnumParticleTypes getParticleType() { protected EnumParticleTypes getParticleType() {
return EnumParticleTypes.FLAME; return EnumParticleTypes.FLAME;
} }

View File

@ -331,6 +331,10 @@ public abstract class EntityFireball extends Entity {
return 1.0F; return 1.0F;
} }
protected float getEaglerDynamicLightsValueSimple(float partialTicks) {
return 1.0f;
}
public int getBrightnessForRender(float var1) { public int getBrightnessForRender(float var1) {
return 15728880; return 15728880;
} }

View File

@ -1113,4 +1113,8 @@ public class Item {
: (this == IRON ? Items.iron_ingot : (this == EMERALD ? Items.diamond : null)))); : (this == IRON ? Items.iron_ingot : (this == EMERALD ? Items.diamond : null))));
} }
} }
public float getHeldItemBrightnessEagler() {
return 0.0f;
}
} }

View File

@ -167,4 +167,8 @@ public class ItemBlock extends Item {
public Block getBlock() { public Block getBlock() {
return this.block; return this.block;
} }
public float getHeldItemBrightnessEagler() {
return this.block.getLightValue() * 0.06667f;
}
} }

View File

@ -169,6 +169,11 @@ public abstract class MinecraftServer implements Runnable, ICommandSender, IThre
worldsettings = new WorldSettings(worldinfo); worldsettings = new WorldSettings(worldinfo);
} }
if (worldinfo.isOldEaglercraftRandom()) {
LogManager.getLogger("EaglerMinecraftServer")
.info("Detected a pre-u34 world, using old EaglercraftRandom implementation for world generation");
}
for (int j = 0; j < this.worldServers.length; ++j) { for (int j = 0; j < this.worldServers.length; ++j) {
byte b0 = 0; byte b0 = 0;
if (j == 1) { if (j == 1) {

View File

@ -50,7 +50,7 @@ public class Teleporter {
public Teleporter(WorldServer worldIn) { public Teleporter(WorldServer worldIn) {
this.worldServerInstance = worldIn; this.worldServerInstance = worldIn;
this.random = new EaglercraftRandom(worldIn.getSeed()); this.random = new EaglercraftRandom(worldIn.getSeed(), !worldIn.getWorldInfo().isOldEaglercraftRandom());
} }
public void placeInPortal(Entity entityIn, float rotationYaw) { public void placeInPortal(Entity entityIn, float rotationYaw) {

View File

@ -681,7 +681,12 @@ public abstract class World implements IBlockAccess {
public int getCombinedLight(BlockPos pos, int lightValue) { public int getCombinedLight(BlockPos pos, int lightValue) {
int i = this.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos); int i = this.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos);
int j = this.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos); int j = this.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos);
if (j < lightValue) { if (lightValue < 0) {
j += -lightValue;
if (j > 15) {
j = 15;
}
} else if (j < lightValue) {
j = lightValue; j = lightValue;
} }

View File

@ -135,8 +135,9 @@ public abstract class WorldProvider {
--f; --f;
} }
float f2 = f;
f = 1.0F - (float) ((Math.cos((double) f * 3.141592653589793D) + 1.0D) / 2.0D); f = 1.0F - (float) ((Math.cos((double) f * 3.141592653589793D) + 1.0D) / 2.0D);
f = f + (f - f) / 3.0F; f = f2 + (f - f2) / 3.0F;
return f; return f;
} }

View File

@ -84,11 +84,12 @@ public class BiomeGenMesa extends BiomeGenBase {
public void genTerrainBlocks(World world, EaglercraftRandom random, ChunkPrimer chunkprimer, int i, int j, public void genTerrainBlocks(World world, EaglercraftRandom random, ChunkPrimer chunkprimer, int i, int j,
double d0) { double d0) {
if (this.field_150621_aC == null || this.field_150622_aD != world.getSeed()) { if (this.field_150621_aC == null || this.field_150622_aD != world.getSeed()) {
this.func_150619_a(world.getSeed()); this.func_150619_a(world.getSeed(), !world.getWorldInfo().isOldEaglercraftRandom());
} }
if (this.field_150623_aE == null || this.field_150624_aF == null || this.field_150622_aD != world.getSeed()) { if (this.field_150623_aE == null || this.field_150624_aF == null || this.field_150622_aD != world.getSeed()) {
EaglercraftRandom random1 = new EaglercraftRandom(this.field_150622_aD); EaglercraftRandom random1 = new EaglercraftRandom(this.field_150622_aD,
!world.getWorldInfo().isOldEaglercraftRandom());
this.field_150623_aE = new NoiseGeneratorPerlin(random1, 4); this.field_150623_aE = new NoiseGeneratorPerlin(random1, 4);
this.field_150624_aF = new NoiseGeneratorPerlin(random1, 1); this.field_150624_aF = new NoiseGeneratorPerlin(random1, 1);
} }
@ -197,10 +198,10 @@ public class BiomeGenMesa extends BiomeGenBase {
} }
private void func_150619_a(long parLong1) { private void func_150619_a(long parLong1, boolean scrambleRNG) {
this.field_150621_aC = new IBlockState[64]; this.field_150621_aC = new IBlockState[64];
Arrays.fill(this.field_150621_aC, Blocks.hardened_clay.getDefaultState()); Arrays.fill(this.field_150621_aC, Blocks.hardened_clay.getDefaultState());
EaglercraftRandom random = new EaglercraftRandom(parLong1); EaglercraftRandom random = new EaglercraftRandom(parLong1, scrambleRNG);
this.field_150625_aG = new NoiseGeneratorPerlin(random, 1); this.field_150625_aG = new NoiseGeneratorPerlin(random, 1);
for (int l1 = 0; l1 < 64; ++l1) { for (int l1 = 0; l1 < 64; ++l1) {

View File

@ -927,7 +927,7 @@ public class Chunk {
public EaglercraftRandom getRandomWithSeed(long i) { public EaglercraftRandom getRandomWithSeed(long i) {
return new EaglercraftRandom(this.worldObj.getSeed() + (long) (this.xPosition * this.xPosition * 4987142) return new EaglercraftRandom(this.worldObj.getSeed() + (long) (this.xPosition * this.xPosition * 4987142)
+ (long) (this.xPosition * 5947611) + (long) (this.zPosition * this.zPosition) * 4392871L + (long) (this.xPosition * 5947611) + (long) (this.zPosition * this.zPosition) * 4392871L
+ (long) (this.zPosition * 389711) ^ i); + (long) (this.zPosition * 389711) ^ i, !this.worldObj.getWorldInfo().isOldEaglercraftRandom());
} }
public boolean isEmpty() { public boolean isEmpty() {

View File

@ -163,9 +163,11 @@ public class EmptyChunk extends Chunk {
} }
public EaglercraftRandom getRandomWithSeed(long seed) { public EaglercraftRandom getRandomWithSeed(long seed) {
return new EaglercraftRandom(this.getWorld().getSeed() + (long) (this.xPosition * this.xPosition * 4987142) return new EaglercraftRandom(
+ (long) (this.xPosition * 5947611) + (long) (this.zPosition * this.zPosition) * 4392871L this.getWorld().getSeed() + (long) (this.xPosition * this.xPosition * 4987142)
+ (long) (this.zPosition * 389711) ^ seed); + (long) (this.xPosition * 5947611) + (long) (this.zPosition * this.zPosition) * 4392871L
+ (long) (this.zPosition * 389711) ^ seed,
!this.getWorld().getWorldInfo().isOldEaglercraftRandom());
} }
public boolean isEmpty() { public boolean isEmpty() {

View File

@ -54,7 +54,7 @@ public class ChunkProviderEnd implements IChunkProvider {
public ChunkProviderEnd(World worldIn, long parLong1) { public ChunkProviderEnd(World worldIn, long parLong1) {
this.endWorld = worldIn; this.endWorld = worldIn;
this.endRNG = new EaglercraftRandom(parLong1); this.endRNG = new EaglercraftRandom(parLong1, !worldIn.getWorldInfo().isOldEaglercraftRandom());
this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16); this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16);
this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16); this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16);
this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8); this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8);

View File

@ -57,7 +57,8 @@ public class ChunkProviderFlat implements IChunkProvider {
public ChunkProviderFlat(World worldIn, long seed, boolean generateStructures, String flatGeneratorSettings) { public ChunkProviderFlat(World worldIn, long seed, boolean generateStructures, String flatGeneratorSettings) {
this.worldObj = worldIn; this.worldObj = worldIn;
this.random = new EaglercraftRandom(seed); boolean scramble = !worldIn.getWorldInfo().isOldEaglercraftRandom();
this.random = new EaglercraftRandom(seed, scramble);
this.flatWorldGenInfo = FlatGeneratorInfo.createFlatGeneratorFromString(flatGeneratorSettings); this.flatWorldGenInfo = FlatGeneratorInfo.createFlatGeneratorFromString(flatGeneratorSettings);
if (generateStructures) { if (generateStructures) {
Map map = this.flatWorldGenInfo.getWorldFeatures(); Map map = this.flatWorldGenInfo.getWorldFeatures();
@ -67,23 +68,23 @@ public class ChunkProviderFlat implements IChunkProvider {
map1.put("size", "1"); map1.put("size", "1");
} }
this.structureGenerators.add(new MapGenVillage(map1)); this.structureGenerators.add(new MapGenVillage(map1, scramble));
} }
if (map.containsKey("biome_1")) { if (map.containsKey("biome_1")) {
this.structureGenerators.add(new MapGenScatteredFeature((Map) map.get("biome_1"))); this.structureGenerators.add(new MapGenScatteredFeature((Map) map.get("biome_1"), scramble));
} }
if (map.containsKey("mineshaft")) { if (map.containsKey("mineshaft")) {
this.structureGenerators.add(new MapGenMineshaft((Map) map.get("mineshaft"))); this.structureGenerators.add(new MapGenMineshaft((Map) map.get("mineshaft"), scramble));
} }
if (map.containsKey("stronghold")) { if (map.containsKey("stronghold")) {
this.structureGenerators.add(new MapGenStronghold((Map) map.get("stronghold"))); this.structureGenerators.add(new MapGenStronghold((Map) map.get("stronghold"), scramble));
} }
if (map.containsKey("oceanmonument")) { if (map.containsKey("oceanmonument")) {
this.structureGenerators.add(new StructureOceanMonument((Map) map.get("oceanmonument"))); this.structureGenerators.add(new StructureOceanMonument((Map) map.get("oceanmonument"), scramble));
} }
} }

View File

@ -62,25 +62,13 @@ public class ChunkProviderGenerate implements IChunkProvider {
private ChunkProviderSettings settings; private ChunkProviderSettings settings;
private Block field_177476_s = Blocks.water; private Block field_177476_s = Blocks.water;
private double[] stoneNoise = new double[256]; private double[] stoneNoise = new double[256];
private MapGenBase caveGenerator = new MapGenCaves(); private MapGenBase caveGenerator;
/**+ private MapGenStronghold strongholdGenerator;
* Holds Stronghold Generator private MapGenVillage villageGenerator;
*/ private MapGenMineshaft mineshaftGenerator;
private MapGenStronghold strongholdGenerator = new MapGenStronghold(); private MapGenScatteredFeature scatteredFeatureGenerator;
/**+ private MapGenBase ravineGenerator;
* Holds Village Generator private StructureOceanMonument oceanMonumentGenerator;
*/
private MapGenVillage villageGenerator = new MapGenVillage();
/**+
* Holds Mineshaft Generator
*/
private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
/**+
* Holds ravine generator
*/
private MapGenBase ravineGenerator = new MapGenRavine();
private StructureOceanMonument oceanMonumentGenerator = new StructureOceanMonument();
private BiomeGenBase[] biomesForGeneration; private BiomeGenBase[] biomesForGeneration;
double[] field_147427_d; double[] field_147427_d;
double[] field_147428_e; double[] field_147428_e;
@ -91,7 +79,15 @@ public class ChunkProviderGenerate implements IChunkProvider {
this.worldObj = worldIn; this.worldObj = worldIn;
this.mapFeaturesEnabled = parFlag; this.mapFeaturesEnabled = parFlag;
this.field_177475_o = worldIn.getWorldInfo().getTerrainType(); this.field_177475_o = worldIn.getWorldInfo().getTerrainType();
this.rand = new EaglercraftRandom(parLong1); boolean scramble = !worldIn.getWorldInfo().isOldEaglercraftRandom();
this.rand = new EaglercraftRandom(parLong1, scramble);
this.caveGenerator = new MapGenCaves(scramble);
this.strongholdGenerator = new MapGenStronghold(scramble);
this.villageGenerator = new MapGenVillage(scramble);
this.mineshaftGenerator = new MapGenMineshaft(scramble);
this.scatteredFeatureGenerator = new MapGenScatteredFeature(scramble);
this.ravineGenerator = new MapGenRavine(scramble);
this.oceanMonumentGenerator = new StructureOceanMonument(scramble);
this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16); this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16);
this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16); this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16);
this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8); this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8);

View File

@ -77,8 +77,8 @@ public class ChunkProviderHell implements IChunkProvider {
private final WorldGenHellLava field_177472_y = new WorldGenHellLava(Blocks.flowing_lava, false); private final WorldGenHellLava field_177472_y = new WorldGenHellLava(Blocks.flowing_lava, false);
private final GeneratorBushFeature field_177471_z = new GeneratorBushFeature(Blocks.brown_mushroom); private final GeneratorBushFeature field_177471_z = new GeneratorBushFeature(Blocks.brown_mushroom);
private final GeneratorBushFeature field_177465_A = new GeneratorBushFeature(Blocks.red_mushroom); private final GeneratorBushFeature field_177465_A = new GeneratorBushFeature(Blocks.red_mushroom);
private final MapGenNetherBridge genNetherBridge = new MapGenNetherBridge(); private final MapGenNetherBridge genNetherBridge;
private final MapGenBase netherCaveGenerator = new MapGenCavesHell(); private final MapGenBase netherCaveGenerator;
double[] noiseData1; double[] noiseData1;
double[] noiseData2; double[] noiseData2;
double[] noiseData3; double[] noiseData3;
@ -88,7 +88,10 @@ public class ChunkProviderHell implements IChunkProvider {
public ChunkProviderHell(World worldIn, boolean parFlag, long parLong1) { public ChunkProviderHell(World worldIn, boolean parFlag, long parLong1) {
this.worldObj = worldIn; this.worldObj = worldIn;
this.field_177466_i = parFlag; this.field_177466_i = parFlag;
this.hellRNG = new EaglercraftRandom(parLong1); boolean scramble = !worldIn.getWorldInfo().isOldEaglercraftRandom();
this.hellRNG = new EaglercraftRandom(parLong1, scramble);
this.genNetherBridge = new MapGenNetherBridge(scramble);
this.netherCaveGenerator = new MapGenCavesHell(scramble);
this.netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16); this.netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16);
this.netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16); this.netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16);
this.netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8); this.netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8);

View File

@ -30,12 +30,17 @@ public class MapGenBase {
* The number of Chunks to gen-check in any given direction. * The number of Chunks to gen-check in any given direction.
*/ */
protected int range = 8; protected int range = 8;
/**+ protected EaglercraftRandom rand;
* The RNG used by the MapGen classes.
*/
protected EaglercraftRandom rand = new EaglercraftRandom();
protected World worldObj; protected World worldObj;
public MapGenBase() {
this(true);
}
public MapGenBase(boolean scramble) {
rand = new EaglercraftRandom(scramble);
}
public void generate(IChunkProvider chunkProviderIn, World worldIn, int x, int z, ChunkPrimer chunkPrimerIn) { public void generate(IChunkProvider chunkProviderIn, World worldIn, int x, int z, ChunkPrimer chunkPrimerIn) {
int i = this.range; int i = this.range;
this.worldObj = worldIn; this.worldObj = worldIn;

View File

@ -32,6 +32,11 @@ import net.minecraft.world.chunk.ChunkPrimer;
* *
*/ */
public class MapGenCaves extends MapGenBase { public class MapGenCaves extends MapGenBase {
public MapGenCaves(boolean scramble) {
super(scramble);
}
protected void func_180703_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1, protected void func_180703_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1,
double parDouble2, double parDouble3) { double parDouble2, double parDouble3) {
this.func_180702_a(parLong1, parInt1, parInt2, parChunkPrimer, parDouble1, parDouble2, parDouble3, this.func_180702_a(parLong1, parInt1, parInt2, parChunkPrimer, parDouble1, parDouble2, parDouble3,
@ -45,7 +50,7 @@ public class MapGenCaves extends MapGenBase {
double d1 = (double) (parInt2 * 16 + 8); double d1 = (double) (parInt2 * 16 + 8);
float f = 0.0F; float f = 0.0F;
float f1 = 0.0F; float f1 = 0.0F;
EaglercraftRandom random = new EaglercraftRandom(parLong1); EaglercraftRandom random = new EaglercraftRandom(parLong1, this.rand.isScramble());
if (parInt4 <= 0) { if (parInt4 <= 0) {
int i = this.range * 16 - 16; int i = this.range * 16 - 16;
parInt4 = i - random.nextInt(i / 4); parInt4 = i - random.nextInt(i / 4);

View File

@ -28,6 +28,11 @@ import net.minecraft.world.chunk.ChunkPrimer;
* *
*/ */
public class MapGenCavesHell extends MapGenBase { public class MapGenCavesHell extends MapGenBase {
public MapGenCavesHell(boolean scramble) {
super(scramble);
}
protected void func_180705_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1, protected void func_180705_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1,
double parDouble2, double parDouble3) { double parDouble2, double parDouble3) {
this.func_180704_a(parLong1, parInt1, parInt2, parChunkPrimer, parDouble1, parDouble2, parDouble3, this.func_180704_a(parLong1, parInt1, parInt2, parChunkPrimer, parDouble1, parDouble2, parDouble3,
@ -41,7 +46,7 @@ public class MapGenCavesHell extends MapGenBase {
double d1 = (double) (parInt2 * 16 + 8); double d1 = (double) (parInt2 * 16 + 8);
float f = 0.0F; float f = 0.0F;
float f1 = 0.0F; float f1 = 0.0F;
EaglercraftRandom random = new EaglercraftRandom(parLong1); EaglercraftRandom random = new EaglercraftRandom(parLong1, this.rand.isScramble());
if (parInt4 <= 0) { if (parInt4 <= 0) {
int i = this.range * 16 - 16; int i = this.range * 16 - 16;
parInt4 = i - random.nextInt(i / 4); parInt4 = i - random.nextInt(i / 4);

View File

@ -31,10 +31,14 @@ import net.minecraft.world.chunk.ChunkPrimer;
public class MapGenRavine extends MapGenBase { public class MapGenRavine extends MapGenBase {
private float[] field_75046_d = new float[1024]; private float[] field_75046_d = new float[1024];
public MapGenRavine(boolean scramble) {
super(scramble);
}
protected void func_180707_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1, protected void func_180707_a(long parLong1, int parInt1, int parInt2, ChunkPrimer parChunkPrimer, double parDouble1,
double parDouble2, double parDouble3, float parFloat1, float parFloat2, float parFloat3, int parInt3, double parDouble2, double parDouble3, float parFloat1, float parFloat2, float parFloat3, int parInt3,
int parInt4, double parDouble4) { int parInt4, double parDouble4) {
EaglercraftRandom random = new EaglercraftRandom(parLong1); EaglercraftRandom random = new EaglercraftRandom(parLong1, this.rand.isScramble());
double d0 = (double) (parInt1 * 16 + 8); double d0 = (double) (parInt1 * 16 + 8);
double d1 = (double) (parInt2 * 16 + 8); double d1 = (double) (parInt2 * 16 + 8);
float f = 0.0F; float f = 0.0F;

View File

@ -287,7 +287,7 @@ public class WorldGenBigTree extends WorldGenAbstractTree {
public boolean generate(World worldIn, EaglercraftRandom rand, BlockPos position) { public boolean generate(World worldIn, EaglercraftRandom rand, BlockPos position) {
this.world = worldIn; this.world = worldIn;
this.basePos = position; this.basePos = position;
this.rand = new EaglercraftRandom(rand.nextLong()); this.rand = new EaglercraftRandom(rand.nextLong(), !worldIn.getWorldInfo().isOldEaglercraftRandom());
if (this.heightLimit == 0) { if (this.heightLimit == 0) {
this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit); this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit);
} }

View File

@ -27,14 +27,16 @@ import net.minecraft.util.MathHelper;
public class MapGenMineshaft extends MapGenStructure { public class MapGenMineshaft extends MapGenStructure {
private double field_82673_e = 0.004D; private double field_82673_e = 0.004D;
public MapGenMineshaft() { public MapGenMineshaft(boolean scramble) {
super(scramble);
} }
public String getStructureName() { public String getStructureName() {
return "Mineshaft"; return "Mineshaft";
} }
public MapGenMineshaft(Map<String, String> parMap) { public MapGenMineshaft(Map<String, String> parMap, boolean scramble) {
super(scramble);
for (Entry entry : parMap.entrySet()) { for (Entry entry : parMap.entrySet()) {
if (((String) entry.getKey()).equals("chance")) { if (((String) entry.getKey()).equals("chance")) {
this.field_82673_e = MathHelper.parseDoubleWithDefault((String) entry.getValue(), this.field_82673_e); this.field_82673_e = MathHelper.parseDoubleWithDefault((String) entry.getValue(), this.field_82673_e);

View File

@ -33,7 +33,8 @@ import net.minecraft.world.biome.BiomeGenBase;
public class MapGenNetherBridge extends MapGenStructure { public class MapGenNetherBridge extends MapGenStructure {
private List<BiomeGenBase.SpawnListEntry> spawnList = Lists.newArrayList(); private List<BiomeGenBase.SpawnListEntry> spawnList = Lists.newArrayList();
public MapGenNetherBridge() { public MapGenNetherBridge(boolean scramble) {
super(scramble);
this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityBlaze.class, 10, 2, 3)); this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityBlaze.class, 10, 2, 3));
this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 5, 4, 4)); this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 5, 4, 4));
this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 10, 4, 4)); this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 10, 4, 4));

View File

@ -39,15 +39,16 @@ public class MapGenScatteredFeature extends MapGenStructure {
private int maxDistanceBetweenScatteredFeatures; private int maxDistanceBetweenScatteredFeatures;
private int minDistanceBetweenScatteredFeatures; private int minDistanceBetweenScatteredFeatures;
public MapGenScatteredFeature() { public MapGenScatteredFeature(boolean scramble) {
super(scramble);
this.scatteredFeatureSpawnList = Lists.newArrayList(); this.scatteredFeatureSpawnList = Lists.newArrayList();
this.maxDistanceBetweenScatteredFeatures = 32; this.maxDistanceBetweenScatteredFeatures = 32;
this.minDistanceBetweenScatteredFeatures = 8; this.minDistanceBetweenScatteredFeatures = 8;
this.scatteredFeatureSpawnList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 1, 1, 1)); this.scatteredFeatureSpawnList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 1, 1, 1));
} }
public MapGenScatteredFeature(Map<String, String> parMap) { public MapGenScatteredFeature(Map<String, String> parMap, boolean scramble) {
this(); this(scramble);
for (Entry entry : parMap.entrySet()) { for (Entry entry : parMap.entrySet()) {
if (((String) entry.getKey()).equals("distance")) { if (((String) entry.getKey()).equals("distance")) {

View File

@ -39,7 +39,8 @@ public class MapGenStronghold extends MapGenStructure {
private double field_82671_h; private double field_82671_h;
private int field_82672_i; private int field_82672_i;
public MapGenStronghold() { public MapGenStronghold(boolean scramble) {
super(scramble);
this.structureCoords = new ChunkCoordIntPair[3]; this.structureCoords = new ChunkCoordIntPair[3];
this.field_82671_h = 32.0D; this.field_82671_h = 32.0D;
this.field_82672_i = 3; this.field_82672_i = 3;
@ -55,8 +56,8 @@ public class MapGenStronghold extends MapGenStructure {
} }
public MapGenStronghold(Map<String, String> parMap) { public MapGenStronghold(Map<String, String> parMap, boolean scramble) {
this(); this(scramble);
for (Entry entry : parMap.entrySet()) { for (Entry entry : parMap.entrySet()) {
if (((String) entry.getKey()).equals("distance")) { if (((String) entry.getKey()).equals("distance")) {
@ -79,7 +80,7 @@ public class MapGenStronghold extends MapGenStructure {
protected boolean canSpawnStructureAtCoords(int i, int j) { protected boolean canSpawnStructureAtCoords(int i, int j) {
if (!this.ranBiomeCheck) { if (!this.ranBiomeCheck) {
EaglercraftRandom random = new EaglercraftRandom(); EaglercraftRandom random = new EaglercraftRandom(!this.worldObj.getWorldInfo().isOldEaglercraftRandom());
random.setSeed(this.worldObj.getSeed()); random.setSeed(this.worldObj.getSeed());
double d0 = random.nextDouble() * 3.141592653589793D * 2.0D; double d0 = random.nextDouble() * 3.141592653589793D * 2.0D;
int k = 1; int k = 1;

View File

@ -46,6 +46,14 @@ public abstract class MapGenStructure extends MapGenBase {
public abstract String getStructureName(); public abstract String getStructureName();
public MapGenStructure() {
super();
}
public MapGenStructure(boolean scramble) {
super(scramble);
}
/**+ /**+
* Recursively called by generate() * Recursively called by generate()
*/ */

View File

@ -40,13 +40,14 @@ public class MapGenVillage extends MapGenStructure {
private int field_82665_g; private int field_82665_g;
private int field_82666_h; private int field_82666_h;
public MapGenVillage() { public MapGenVillage(boolean scramble) {
super(scramble);
this.field_82665_g = 32; this.field_82665_g = 32;
this.field_82666_h = 8; this.field_82666_h = 8;
} }
public MapGenVillage(Map<String, String> parMap) { public MapGenVillage(Map<String, String> parMap, boolean scramble) {
this(); this(scramble);
for (Entry entry : parMap.entrySet()) { for (Entry entry : parMap.entrySet()) {
if (((String) entry.getKey()).equals("size")) { if (((String) entry.getKey()).equals("size")) {

View File

@ -45,13 +45,14 @@ public class StructureOceanMonument extends MapGenStructure {
BiomeGenBase.deepOcean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver }); BiomeGenBase.deepOcean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver });
private static final List<BiomeGenBase.SpawnListEntry> field_175803_h = Lists.newArrayList(); private static final List<BiomeGenBase.SpawnListEntry> field_175803_h = Lists.newArrayList();
public StructureOceanMonument() { public StructureOceanMonument(boolean scramble) {
super(scramble);
this.field_175800_f = 32; this.field_175800_f = 32;
this.field_175801_g = 5; this.field_175801_g = 5;
} }
public StructureOceanMonument(Map<String, String> parMap) { public StructureOceanMonument(Map<String, String> parMap, boolean scramble) {
this(); this(scramble);
for (Entry entry : parMap.entrySet()) { for (Entry entry : parMap.entrySet()) {
if (((String) entry.getKey()).equals("spacing")) { if (((String) entry.getKey()).equals("spacing")) {

View File

@ -71,6 +71,9 @@ public class WorldInfo {
private int borderWarningTime = 15; private int borderWarningTime = 15;
private GameRules theGameRules = new GameRules(); private GameRules theGameRules = new GameRules();
public static final int eaglerVersionCurrent = 1;
private int eaglerVersion = eaglerVersionCurrent;
protected WorldInfo() { protected WorldInfo() {
} }
@ -187,6 +190,7 @@ public class WorldInfo {
this.borderWarningTime = nbt.getInteger("BorderWarningTime"); this.borderWarningTime = nbt.getInteger("BorderWarningTime");
} }
this.eaglerVersion = nbt.getInteger("eaglerVersionSerial");
} }
public WorldInfo(WorldSettings settings, String name) { public WorldInfo(WorldSettings settings, String name) {
@ -296,6 +300,7 @@ public class WorldInfo {
nbt.setDouble("BorderSizeLerpTarget", this.borderSizeLerpTarget); nbt.setDouble("BorderSizeLerpTarget", this.borderSizeLerpTarget);
nbt.setDouble("BorderWarningBlocks", (double) this.borderWarningDistance); nbt.setDouble("BorderWarningBlocks", (double) this.borderWarningDistance);
nbt.setDouble("BorderWarningTime", (double) this.borderWarningTime); nbt.setDouble("BorderWarningTime", (double) this.borderWarningTime);
nbt.setInteger("eaglerVersionSerial", this.eaglerVersion);
if (this.difficulty != null) { if (this.difficulty != null) {
nbt.setByte("Difficulty", (byte) this.difficulty.getDifficultyId()); nbt.setByte("Difficulty", (byte) this.difficulty.getDifficultyId());
} }
@ -712,6 +717,20 @@ public class WorldInfo {
this.difficultyLocked = flag; this.difficultyLocked = flag;
} }
public int getEaglerVersion() {
return this.eaglerVersion;
}
public boolean isOldEaglercraftRandom() {
return this.eaglerVersion == 0;
}
public static void initEaglerVersion(NBTTagCompound compound) {
if (!compound.hasKey("eaglerVersionSerial", 99)) {
compound.setInteger("eaglerVersionSerial", eaglerVersionCurrent);
}
}
/**+ /**+
* Adds this WorldInfo instance to the crash report. * Adds this WorldInfo instance to the crash report.
*/ */