1
0
Fork 0

add colored lighting

This commit is contained in:
Sen 2025-08-30 14:10:58 +02:00
parent 16d20fb31d
commit d4c7c5bbea
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
23 changed files with 234 additions and 323 deletions

View file

@ -428,8 +428,8 @@ public class Client implements IThreadListener {
Client.this.renderer.checkBlockLight(pos);
}
public int getCombinedLight(BlockPos pos, int lightValue) {
return Client.this.renderer.getCombinedLight(pos, lightValue);
public int getCombinedLight(BlockPos pos) {
return Client.this.renderer.getCombinedLight(pos);
}
}
@ -2053,7 +2053,7 @@ public class Client implements IThreadListener {
String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos),
Color.stripCodes(this.world.dimension.getDisplay()),
this.dimensionName) + "\n" +
"Licht: " + chunk.getLightSub(pos, 0) + " (" + (this.world.dimension.hasSkyLight() ? + Renderer.getSkyLightFor(pos.getY()) + " Himmel, " : "")
String.format("Licht: %06x", chunk.getLight(pos)) + " (" + (this.world.dimension.hasSkyLight() ? + Renderer.getSkyLightFor(pos.getY()) + " Himmel, " : "")
+ chunk.getLight(pos) + " Blöcke, " + String.format(
"%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
+ String.format("%.1f ° (%.1f, %.1f)", this.renderer.getCelestialAngle(1.0f), !this.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos((-90.0f + this.renderer.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI),

View file

@ -78,7 +78,7 @@ public class EffectRenderer {
public int getBrightness(float partial) {
BlockPos pos = new BlockPos(this.posX, this.posY, this.posZ);
return world.isBlockLoaded(pos) ? world.getCombinedLight(pos, 0) : 0;
return world.isBlockLoaded(pos) ? world.getCombinedLight(pos) : 0;
}
}

View file

@ -126,7 +126,7 @@ public class ItemRenderer
private void setLightMapFromPlayer(EntityNPC clientPlayer)
{
int i = this.gm.world.getCombinedLight(new BlockPos(clientPlayer.posX, clientPlayer.posY + (double)clientPlayer.getEyeHeight(), clientPlayer.posZ), 0);
int i = this.gm.world.getCombinedLight(new BlockPos(clientPlayer.posX, clientPlayer.posY + (double)clientPlayer.getEyeHeight(), clientPlayer.posZ));
float f = (float)(i & 65535);
float f1 = (float)(i >> 16);
GL46.glMultiTexCoord2f(GL46.GL_TEXTURE1, f, f1);

View file

@ -69,14 +69,14 @@ public class RegionRenderCache implements IWorldAccess
return this.chunks[i][j].getTileEntity(pos, TileEntity.CreateMode.QUEUED);
}
public int getCombinedLight(BlockPos pos, int lightValue)
public int getCombinedLight(BlockPos pos)
{
int i = this.getPositionIndex(pos);
int j = this.combinedLights[i];
if (j == -1)
{
j = this.getLight(pos, lightValue);
j = this.getBlockLightExt(pos);
this.combinedLights[i] = j;
}
@ -124,43 +124,37 @@ public class RegionRenderCache implements IWorldAccess
return this.empty;
}
public int getLight(BlockPos pos, int lightValue)
{
int i = this.sky ? Renderer.getSkyLightFor(pos.getY()) : 0;
int j = this.getBlockLightExt(pos);
if (j < lightValue)
{
j = lightValue;
}
return i << 20 | j << 4;
}
private int getBlockLightExt(BlockPos pos)
{
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{
if (this.getState(pos).getBlock().getSumBrightness())
{
int l = 0;
int r = 0;
int g = 0;
int b = 0;
for (Facing enumfacing : Facing.values())
{
int k = this.getBlockLight(pos.offset(enumfacing));
int light = this.getBlockLight(pos.offset(enumfacing));
int lr = (light >> 16) & 255;
int lg = (light >> 8) & 255;
int lb = light & 255;
if (k > l)
{
l = k;
}
if(lr > r)
r = lr;
if(lg > g)
g = lg;
if(lb > b)
b = lb;
if (l >= 15)
if (r >= 255 && g >= 255 && b >= 255)
{
return l;
return 0xffffff;
}
}
return l;
return (r > 255 ? 255 : r) << 16 | (g > 255 ? 255 : g) << 16 | (b > 255 ? 255 : b);
}
else
{

View file

@ -454,12 +454,4 @@ public class RenderBuffer
this.putColor(argb, i + 1);
}
}
public void putColorRGB_F4(float red, float green, float blue)
{
for (int i = 0; i < 4; ++i)
{
this.putColorRGB_F(red, green, blue, i + 1);
}
}
}

View file

@ -140,8 +140,6 @@ public class Renderer {
private float fogColorRed;
private float fogColorGreen;
private float fogColorBlue;
private float lastFogMult;
private float fogMult;
private double cameraYaw;
private double cameraPitch;
private int frameCount;
@ -189,10 +187,6 @@ public class Renderer {
private float moonColorRed;
private float moonColorGreen;
private float moonColorBlue;
private float blockColorRed;
private float blockColorGreen;
private float blockColorBlue;
private int subtract;
private final int[] lightUpdate = new int[32768];
public Renderer(Client gm, ModelManager manager)
@ -266,7 +260,6 @@ public class Renderer {
{
this.updateFovModifierHand();
this.updateTorchFlicker();
this.lastFogMult = this.fogMult;
this.thirdPersonDistanceTemp = this.thirdPersonDistance;
if (this.gm.getRenderViewEntity() == null)
@ -274,10 +267,6 @@ public class Renderer {
this.gm.setRenderViewEntity(this.gm.player);
}
float light = this.getLightBrightness(new BlockPos(this.gm.getRenderViewEntity()));
float dist = (float)this.gm.renderDistance / 32.0F;
float shift = light * (1.0F - dist) + dist;
this.fogMult += (shift - this.fogMult) * 0.1F;
++this.rendererUpdateCount;
this.itemRenderer.update();
this.addRainParticles();
@ -1150,11 +1139,6 @@ public class Renderer {
this.moonColorGreen = green * (world.dimension.hasDaylight() ? 1.0f - sun : 0.0f);
this.moonColorBlue = blue * (world.dimension.hasDaylight() ? 1.0f - sun : 0.0f);
}
else if(n == 15) {
this.blockColorRed = red;
this.blockColorGreen = green;
this.blockColorBlue = blue;
}
this.lightmapColors[n] = a << 24 | r << 16 | g << 8 | b;
}
@ -1485,7 +1469,7 @@ public class Renderer {
float dist = ExtMath.sqrtd(dx * dx + dz * dz) / (float)range;
float alpha = ((1.0F - dist * dist) * 0.5F + 0.5F) * rain;
pos.set(x, lpos, z);
int light = world.getCombinedLight(pos, 0);
int light = world.getCombinedLight(pos);
int sky = light >> 16 & 65535;
int blk = light & 65535;
buf.pos((double)x - rx + 0.5D, (double)miny, (double)z - rz + 0.5D).tex(0.0D, (double)miny * 0.25D + offset)
@ -1514,7 +1498,7 @@ public class Renderer {
float dist = ExtMath.sqrtd(dx * dx + dz * dz) / (float)range;
float alpha = ((1.0F - dist * dist) * 0.3F + 0.5F) * rain;
pos.set(x, lpos, z);
int light = (world.getCombinedLight(pos, 0) * 3 + 15728880) / 4;
int light = (world.getCombinedLight(pos) * 3 + 15728880) / 4;
int sky = light >> 16 & 65535;
int blk = light & 65535;
buf.pos((double)x - rx + 0.5D, (double)miny, (double)z - rz + 0.5D).tex(0.0D + tx, (double)miny * 0.25D + offset + ty)
@ -1627,10 +1611,9 @@ public class Renderer {
this.fogColorBlue = 0.0F;
}
float mult = this.lastFogMult + (this.fogMult - this.lastFogMult) * partial;
this.fogColorRed *= mult;
this.fogColorGreen *= mult;
this.fogColorBlue *= mult;
// this.fogColorRed *= this.lastFogMultRed + (this.fogMultRed - this.lastFogMultRed) * partial;
// this.fogColorGreen *= this.lastFogMultGreen + (this.fogMultGreen - this.lastFogMultGreen) * partial;
// this.fogColorBlue *= this.lastFogMultBlue + (this.fogMultBlue - this.lastFogMultBlue) * partial;
double vision = 1.0;
if(world.dimension.hasVoidFog() && this.gm.voidFog) {
@ -2041,7 +2024,6 @@ public class Renderer {
if (worldClientIn != null)
{
this.calculateInitialSkylight();
// worldClientIn.setWorldAccess(this);
this.loadRenderers();
}
@ -3253,21 +3235,21 @@ public class Renderer {
{
if (state.getBlock() != Blocks.air && !state.getBlock().getMaterial().isLiquid())
{
float brightness = brightPos == null ? 1.0f : this.getLightBrightness(brightPos);
int light = brightPos == null ? 0xffffffff : getLightmapValue(this.gm.world, brightPos);
IBakedModel model = this.manager.getModelForState(state);
Block block = state.getBlock();
GL46.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
for (Facing enumfacing : Facing.values())
{
this.renderSimple(brightness, model.getFace(enumfacing));
this.renderSimple(light, model.getFace(enumfacing));
}
this.renderSimple(brightness, model.getQuads());
this.renderSimple(light, model.getQuads());
}
}
private void renderSimple(float brightness, List<BakedQuad> listQuads)
private void renderSimple(int light, List<BakedQuad> listQuads)
{
RenderBuffer worldrenderer = Tessellator.getBuffer();
@ -3275,7 +3257,7 @@ public class Renderer {
{
worldrenderer.begin(GL46.GL_QUADS, DefaultVertexFormats.ITEM);
worldrenderer.addVertexData(bakedquad.getVertexData());
worldrenderer.putColorRGB_F4(brightness, brightness, brightness);
worldrenderer.putBrightness4(light, light, light, light);
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
Tessellator.draw();
@ -3324,26 +3306,29 @@ public class Renderer {
return rendered;
}
private int getLightColor(int light) {
return light << 24 | (int)(this.blockColorBlue * (float)light) << 16 | (int)(this.blockColorGreen * (float)light) << 8 | (int)(this.blockColorRed * (float)light);
public static int getLightColor(int light) {
return Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) << 24 | (light & 0x00ff00) | ((light >> 16) & 0xff) | ((light & 0xff) << 16);
}
public static int componentMax(int lightA, int lightB) {
return Math.max((lightA >> 16) & 0xff, (lightB >> 16) & 0xff) << 16 | Math.max((lightA >> 8) & 0xff, (lightB >> 8) & 0xff) << 8 | Math.max(lightA & 0xff, lightB & 0xff);
}
private int getLightmapValue(IWorldAccess world, BlockPos pos) {
Block block = world.getState(pos).getBlock();
int light = world.getCombinedLight(pos, block.getLight()) & 0xff;
int light = componentMax(world.getCombinedLight(pos), block.getLight());
if(light == 0 && block instanceof BlockSlab) {
pos = pos.down();
block = world.getState(pos).getBlock();
light = world.getCombinedLight(pos, block.getLight()) & 0xff;
light = componentMax(world.getCombinedLight(pos), block.getLight());
}
return this.getLightColor(light);
return getLightColor(light);
}
private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) {
int light = world.getCombinedLight(pos, 0) & 0xff;
int up = world.getCombinedLight(pos.up(), 0) & 0xff;
light = light > up ? light : up;
return this.getLightColor(light);
int light = world.getCombinedLight(pos);
int up = world.getCombinedLight(pos.up());
return getLightColor(componentMax(light, up));
}
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int light, boolean ownLight, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
@ -3924,7 +3909,7 @@ public class Renderer {
return n == 4 ? 1.0f : (s + a == 4 && a > 1 ? 0.0f : 1.0F - f / (float)i);
}
private int getLightFor(BlockPos pos) {
private int getLight(BlockPos pos) {
if(pos.getY() < -World.MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), -World.MAX_SIZE_Y, pos.getZ());
}
@ -3938,7 +3923,7 @@ public class Renderer {
}
}
private int getBlockLightSum(BlockPos pos) {
public int getCombinedLight(BlockPos pos) {
if(pos.getY() < -World.MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), -World.MAX_SIZE_Y, pos.getZ());
}
@ -3947,101 +3932,64 @@ public class Renderer {
return 0;
}
else if(this.gm.world.getState(pos).getBlock().getSumBrightness()) {
int i1 = this.getLightFor(pos.up());
int i = this.getLightFor(pos.east());
int j = this.getLightFor(pos.west());
int k = this.getLightFor(pos.south());
int l = this.getLightFor(pos.north());
int light = this.getLight(pos.up());
int east = this.getLight(pos.east());
int west = this.getLight(pos.west());
int south = this.getLight(pos.south());
int north = this.getLight(pos.north());
if(i > i1) {
i1 = i;
}
light = componentMax(light, east);
light = componentMax(light, west);
light = componentMax(light, south);
light = componentMax(light, north);
if(j > i1) {
i1 = j;
}
if(k > i1) {
i1 = k;
}
if(l > i1) {
i1 = l;
}
return i1;
return light;
}
else {
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
return chunk.getLight(pos);
}
}
//
// private int getLight(BlockPos pos, boolean checkNeighbors) {
// if(pos.getX() >= -World.MAX_SIZE && pos.getZ() >= -World.MAX_SIZE && pos.getX() < World.MAX_SIZE && pos.getZ() < World.MAX_SIZE) {
// if(checkNeighbors && this.gm.world.getState(pos).getBlock().getSumBrightness()) {
// int light = this.getLight(pos.up(), false);
// int east = this.getLight(pos.east(), false);
// int west = this.getLight(pos.west(), false);
// int south = this.getLight(pos.south(), false);
// int north = this.getLight(pos.north(), false);
//
// light = componentMax(light, east);
// light = componentMax(light, west);
// light = componentMax(light, south);
// light = componentMax(light, north);
//
// return light;
// }
// else if(pos.getY() < -World.MAX_SIZE_Y) {
// return 0;
// }
// else {
// if(pos.getY() >= World.MAX_SIZE_Y) {
// pos = new BlockPos(pos.getX(), World.MAX_SIZE_Y - 1, pos.getZ());
// }
//
// ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
// return chunk.getLight(pos);
// }
// }
// else {
// return 0;
// }
// }
public int getCombinedLight(BlockPos pos, int lightValue) {
int i = this.gm.world.dimension.hasSkyLight() ? getSkyLightFor(pos.getY()) : 0;
int j = this.getBlockLightSum(pos);
if(j < lightValue) {
j = lightValue;
}
return i << 20 | j << 4;
}
private int getLight(BlockPos pos, boolean checkNeighbors) {
if(pos.getX() >= -World.MAX_SIZE && pos.getZ() >= -World.MAX_SIZE && pos.getX() < World.MAX_SIZE && pos.getZ() < World.MAX_SIZE) {
if(checkNeighbors && this.gm.world.getState(pos).getBlock().getSumBrightness()) {
int i1 = this.getLight(pos.up(), false);
int i = this.getLight(pos.east(), false);
int j = this.getLight(pos.west(), false);
int k = this.getLight(pos.south(), false);
int l = this.getLight(pos.north(), false);
if(i > i1) {
i1 = i;
}
if(j > i1) {
i1 = j;
}
if(k > i1) {
i1 = k;
}
if(l > i1) {
i1 = l;
}
return i1;
}
else if(pos.getY() < -World.MAX_SIZE_Y) {
return 0;
}
else {
if(pos.getY() >= World.MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), World.MAX_SIZE_Y - 1, pos.getZ());
}
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
return chunk.getLightSub(pos, this.subtract);
}
}
else {
return 15;
}
}
public float getLightBrightness(BlockPos pos) {
return Math.max(BRIGHTNESS[this.getLight(pos, true)], (float)this.gm.world.dimension.getBrightness() / 15.0f);
}
private int getRawBlockLight(BlockPos pos) {
private int getRawBlockLight(BlockPos pos, int component) {
Block block = this.gm.world.getState(pos).getBlock();
int light = block.getLight();
int light = ((block.getLight() >> ((2 - component) * 8)) & 0xff) / 16;
int opacity = block.getLightOpacity();
if(opacity >= 15 && block.getLight() > 0) {
if(opacity >= 15 && light > 0) {
opacity = 1;
}
@ -4058,7 +4006,7 @@ public class Renderer {
else {
for(Facing side : Facing.values()) {
BlockPos bpos = pos.offset(side);
int blight = this.getLightFor(bpos) - opacity;
int blight = this.getLightFor(bpos, component) - opacity;
if(blight > light) {
light = blight;
@ -4073,112 +4021,122 @@ public class Renderer {
}
}
private void setBlockLight(BlockPos pos, int lightValue) {
private int getLightFor(BlockPos pos, int component) {
return ((this.getLight(pos) >> ((2 - component) * 8)) & 0xff) / 16;
}
private void setBlockLight(BlockPos pos, int component, int value) {
if(World.isValid(pos)) {
ChunkClient chunk = this.gm.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
chunk.setLight(pos, lightValue);
this.markUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1, pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
int light = chunk.getLight(pos);
int nlight = (light & ~(0xff << ((2 - component) * 8))) | ((value * 16) << ((2 - component) * 8));
if(nlight != light) {
chunk.setLight(pos, nlight);
this.markUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1, pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
}
}
}
public boolean checkBlockLight(BlockPos pos) {
if(!this.gm.world.isAreaLoaded(pos, 17, false))
return false;
int done = 0;
int cnt = 0;
int light = this.getLightFor(pos);
int raw = this.getRawBlockLight(pos);
int bx = pos.getX();
int by = pos.getY();
int bz = pos.getZ();
if(raw > light) {
this.lightUpdate[cnt++] = 133152;
}
else if(raw < light) {
this.lightUpdate[cnt++] = 133152 | light << 18;
while(done < cnt) {
int p = this.lightUpdate[done++];
int x = (p & 63) - 32 + bx;
int y = (p >> 6 & 63) - 32 + by;
int z = (p >> 12 & 63) - 32 + bz;
int s = p >> 18 & 15;
BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(blk);
if(l == s) {
this.setBlockLight(blk, 0);
if(s > 0) {
int dx = ExtMath.absi(x - bx);
int dy = ExtMath.absi(y - by);
int dz = ExtMath.absi(z - bz);
if(dx + dy + dz < 17) {
BlockPos.MutableBlockPos bpos = new BlockPos.MutableBlockPos();
for(Facing dir : Facing.values()) {
int ox = x + dir.getFrontOffsetX();
int oy = y + dir.getFrontOffsetY();
int oz = z + dir.getFrontOffsetZ();
bpos.set(ox, oy, oz);
int op = Math.max(1, this.theWorld.getState(bpos).getBlock().getLightOpacity());
l = this.getLightFor(bpos);
if(l == s - op && cnt < this.lightUpdate.length) {
this.lightUpdate[cnt++] = ox - bx + 32 | oy - by + 32 << 6 | oz - bz + 32 << 12 | s - op << 18;
for(int component = 0; component < 3; component++) {
int done = 0;
int cnt = 0;
int light = this.getLightFor(pos, component);
int raw = this.getRawBlockLight(pos, component);
int bx = pos.getX();
int by = pos.getY();
int bz = pos.getZ();
if(raw > light) {
this.lightUpdate[cnt++] = 133152;
}
else if(raw < light) {
this.lightUpdate[cnt++] = 133152 | light << 18;
while(done < cnt) {
int p = this.lightUpdate[done++];
int x = (p & 63) - 32 + bx;
int y = (p >> 6 & 63) - 32 + by;
int z = (p >> 12 & 63) - 32 + bz;
int s = p >> 18 & 15;
BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(blk, component);
if(l == s) {
this.setBlockLight(blk, component, 0);
if(s > 0) {
int dx = ExtMath.absi(x - bx);
int dy = ExtMath.absi(y - by);
int dz = ExtMath.absi(z - bz);
if(dx + dy + dz < 17) {
BlockPos.MutableBlockPos bpos = new BlockPos.MutableBlockPos();
for(Facing dir : Facing.values()) {
int ox = x + dir.getFrontOffsetX();
int oy = y + dir.getFrontOffsetY();
int oz = z + dir.getFrontOffsetZ();
bpos.set(ox, oy, oz);
int op = Math.max(1, this.theWorld.getState(bpos).getBlock().getLightOpacity());
l = this.getLightFor(bpos, component);
if(l == s - op && cnt < this.lightUpdate.length) {
this.lightUpdate[cnt++] = ox - bx + 32 | oy - by + 32 << 6 | oz - bz + 32 << 12 | s - op << 18;
}
}
}
}
}
}
done = 0;
}
done = 0;
}
while(done < cnt) {
int p = this.lightUpdate[done++];
int x = (p & 63) - 32 + bx;
int y = (p >> 6 & 63) - 32 + by;
int z = (p >> 12 & 63) - 32 + bz;
BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(blk);
int r = this.getRawBlockLight(blk);
if(r != l) {
this.setBlockLight(blk, r);
if(r > l) {
int k6 = Math.abs(x - bx);
int l6 = Math.abs(y - by);
int i7 = Math.abs(z - bz);
boolean flag = cnt < this.lightUpdate.length - 6;
if(k6 + l6 + i7 < 17 && flag) {
if(this.getLightFor(blk.west()) < r) {
this.lightUpdate[cnt++] = x - 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.east()) < r) {
this.lightUpdate[cnt++] = x + 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.down()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - 1 - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.up()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y + 1 - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.north()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z - 1 - bz + 32 << 12);
}
if(this.getLightFor(blk.south()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z + 1 - bz + 32 << 12);
while(done < cnt) {
int p = this.lightUpdate[done++];
int x = (p & 63) - 32 + bx;
int y = (p >> 6 & 63) - 32 + by;
int z = (p >> 12 & 63) - 32 + bz;
BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(blk, component);
int r = this.getRawBlockLight(blk, component);
if(r != l) {
this.setBlockLight(blk, component, r);
if(r > l) {
int k6 = Math.abs(x - bx);
int l6 = Math.abs(y - by);
int i7 = Math.abs(z - bz);
boolean flag = cnt < this.lightUpdate.length - 6;
if(k6 + l6 + i7 < 17 && flag) {
if(this.getLightFor(blk.west(), component) < r) {
this.lightUpdate[cnt++] = x - 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.east(), component) < r) {
this.lightUpdate[cnt++] = x + 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.down(), component) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - 1 - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.up(), component) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y + 1 - by + 32 << 6) + (z - bz + 32 << 12);
}
if(this.getLightFor(blk.north(), component) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z - 1 - bz + 32 << 12);
}
if(this.getLightFor(blk.south(), component) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z + 1 - bz + 32 << 12);
}
}
}
}
@ -4186,17 +4144,6 @@ public class Renderer {
}
return true;
}
private void calculateInitialSkylight() {
float f = !this.gm.world.dimension.hasDaylight() ? 0.5f : this.calcRotationPhase(this.gm.world.dimension.getRotationalPeriod() / 4L, 1.0f);
float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F);
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
// f1 = 1.0F - f1;
// f1 = (float)((double)f1 * (1.0D - (double)(this.gm.world.getRainStrength() * 5.0F) / 16.0D));
// f1 = (float)((double)f1 * (1.0D - (double)(this.gm.world.getDarkness() * 5.0F) / 16.0D));
// f1 = 1.0F - f1;
this.subtract = (int)(f1 * 11.0F);
}
public static int getSkyLightFor(int y) {
return y < 0 ? 0 : (y < 64 ? y / 4 : 15);

View file

@ -121,7 +121,7 @@ public class RenderManager {
public static int getBrightnessForRender(Entity entity) {
BlockPos pos = new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ);
return entity.worldObj.isBlockLoaded(pos) ? entity.worldObj.getCombinedLight(pos, 0) : 0;
return entity.worldObj.isBlockLoaded(pos) ? entity.worldObj.getCombinedLight(pos) : 0;
}
public boolean renderEntity(Entity entity, float partialTicks) {

View file

@ -55,7 +55,7 @@ public class SpecialRenderer {
public void renderTile(TileEntity tile, float partial) {
if(tile.getDistanceSq(this.posX, this.posY, this.posZ) < tile.getMaxRenderDistanceSquared()) {
int light = this.world.getCombinedLight(tile.getPos(), 0);
int light = this.world.getCombinedLight(tile.getPos());
int block = light % 65536;
int sky = light / 65536;
GL46.glMultiTexCoord2f(GL46.GL_TEXTURE1, (float)block / 1.0F, (float)sky / 1.0F);

View file

@ -189,17 +189,4 @@ public class ChunkClient extends Chunk {
stor.setLight(x, y & 15, z, value);
}
public int getLightSub(BlockPos pos, int amount) {
int x = pos.getX() & 15;
int y = pos.getY();
int z = pos.getZ() & 15;
BlockArray stor = this.getArray(y >> 4);
int l = this.world.dimension.hasSkyLight() ? Renderer.getSkyLightFor(pos.getY()) : 0;
if(stor == null)
return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0;
l = l - amount;
int b = stor.getLight(x, y & 15, z);
return b > l ? b : l;
}
}

View file

@ -79,10 +79,6 @@ public class ChunkEmpty extends ChunkClient {
public void setLight(BlockPos pos, int value) {
}
public int getLightSub(BlockPos pos, int amount) {
return 0;
}
public void addEntity(Entity entity) {
}