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) {
}

View file

@ -386,13 +386,8 @@ public class Block {
return this;
}
public final Block setLight(float level) {
this.light = (int)(15.0F * level);
return this;
}
public final Block setLight(int level) {
this.light = level;
public final Block setLight(int color) {
this.light = color;
return this;
}

View file

@ -25,7 +25,7 @@ public class BlockFloorPortal extends Block
public BlockFloorPortal(Material materialIn)
{
super(materialIn);
this.setLight(1.0F);
this.setLight(0x7f00ff);
}
// /**

View file

@ -20,7 +20,7 @@ public class BlockMetalBlock extends Block {
super(Material.SOLID);
this.metal = metal;
this.setSound(SoundType.STONE);
this.setLight(metal.radioactivity > 0.0F ? 0.25F : 0.0F);
this.setLight(metal.radioactivity > 0.0F ? 0x003f00 : 0x000000);
this.setRadiation(metal.radioactivity * 2.0f);
this.setTab(CheatTab.GEMS);
}

View file

@ -67,7 +67,7 @@ public class BlockBlueShroom extends BlockBush
protected boolean canPlaceBlockOn(Block ground)
{
return ground.isFullBlock();
return ground.isFullBlock() || ground.isNonBlock();
}
public boolean canBlockStay(World worldIn, BlockPos pos, State state)

View file

@ -70,7 +70,7 @@ public class BlockMushroom extends BlockBush implements IGrowable
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground.isFullBlock();
return ground.isFullBlock() || ground.isNonBlock();
}
public boolean canBlockStay(World worldIn, BlockPos pos, State state)

View file

@ -15,7 +15,7 @@ public class BlockMetalOre extends BlockOre {
public BlockMetalOre(MetalType metal) {
this.metal = metal;
this.setSound(SoundType.STONE);
this.setLight(metal.radioactivity > 0.0F ? 0.25F : 0.0F);
this.setLight(metal.radioactivity > 0.0F ? 0x003f00 : 0x000000);
this.setRadiation(metal.radioactivity * 0.5f);
}

View file

@ -18,7 +18,7 @@ public class BlockActiveDisplay extends BlockDisplay implements ITileEntityProvi
public BlockActiveDisplay(BlockInactiveDisplay inactive) {
super(inactive.getDensity());
this.setLight(1.0f);
this.setLight(0xafafff);
this.inactive = inactive;
inactive.setActive(this);
}

View file

@ -37,7 +37,7 @@ public class BlockFurnace extends BlockMachine {
this.fuelEfficiency = fuelEfficiency;
this.setHardness(3.5F).setSound(SoundType.STONE);
if(this.isBurning)
this.setLight(0.875F);
this.setLight(0xffffaf);
}
public BlockFurnace(int burnTime, int fuelEfficiency) {

View file

@ -18,7 +18,7 @@ public class BlockToggleableLight extends Block {
super(Material.LOOSE);
this.isOn = isOn;
if(isOn)
this.setLight(1.0F);
this.setLight(0xffffcf);
}
public void toggle(World worldIn, BlockPos pos) {

View file

@ -118,10 +118,10 @@ public abstract class BlockRegistry {
private static void registerFluid(String name, String display, LiquidType type, int light, int rate,
float radiation, Object still, Object flowing) {
BlockDynamicLiquid dy = (BlockDynamicLiquid)(new BlockDynamicLiquid(type.material, rate, flowing)).setHardness(100.0F)
.setOpacity(3).setLight((float)light / 15.0f).setDisplay(display)
.setOpacity(3).setLight(light).setDisplay(display)
.setRadiation(radiation);
BlockStaticLiquid st = (BlockStaticLiquid)(new BlockStaticLiquid(type.material, rate, still, dy)).setHardness(100.0F)
.setOpacity(3).setLight((float)light / 15.0f).setDisplay(display)
.setOpacity(3).setLight(light).setDisplay(display)
.setRadiation(radiation);
register("flowing_" + name, dy);
register(name, st);
@ -170,7 +170,7 @@ public abstract class BlockRegistry {
register("ice", (new BlockIce()).setHardness(0.5F).setOpacity(3).setSound(SoundType.GLASS).setDisplay("Eis").setMiningTool(Equipment.PICKAXE, 0));
register("packed_ice", (new BlockPackedIce()).setHardness(0.5F).setSound(SoundType.GLASS).setDisplay("Packeis").setMiningTool(Equipment.PICKAXE, 0));
register("soul_sand", (new BlockSoulSand()).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Seelensand").setMiningTool(Equipment.SHOVEL));
register("glowstone", (new BlockGlowstone(Material.TRANSLUCENT)).setHardness(0.3F).setSound(SoundType.GLASS).setLight(1.0F)
register("glowstone", (new BlockGlowstone(Material.TRANSLUCENT)).setHardness(0.3F).setSound(SoundType.GLASS).setLight(0xffff3f)
.setDisplay("Glowstone"));
Block blackened_stone = register("blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setSound(SoundType.STONE).setDisplay("Schwarzstein"));
Block blackened_cobble = register("blackened_cobble", (new BlockNonBlock(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setSound(SoundType.STONE)
@ -178,9 +178,9 @@ public abstract class BlockRegistry {
registerFluid("water", "Wasser", LiquidType.WATER, 0, 5, 0.0f, TextureAnimation.WATER_STILL, TextureAnimation.WATER_FLOW);
registerFluid("lava", "Lava", LiquidType.LAVA, 15, -30, 0.0f, 2, 3);
registerFluid("magma", "Magma", LiquidType.HOT, 15, 40, 0.0f, TextureAnimation.MAGMA_STILL, TextureAnimation.MAGMA_FLOW);
registerFluid("plasma", "Plasma", LiquidType.HOT, 15, 15, 0.0f, 2, 2);
registerFluid("lava", "Lava", LiquidType.LAVA, 0xffcfaf, -30, 0.0f, 2, 3);
registerFluid("magma", "Magma", LiquidType.HOT, 0xffaf8f, 40, 0.0f, TextureAnimation.MAGMA_STILL, TextureAnimation.MAGMA_FLOW);
registerFluid("plasma", "Plasma", LiquidType.HOT, 0xff7f00, 15, 0.0f, 2, 2);
registerFluid("mercury", "Quecksilber", LiquidType.COLD, 0, 40, 0.0f, 8, 4);
registerFluid("hydrogen", "Wasserstoff", LiquidType.COLD, 0, 50, 0.0f, 8, 4);
registerFluid("acid", "Säure", LiquidType.HOT, 0, 5, 0.0f, 1, 1);
@ -271,7 +271,7 @@ public abstract class BlockRegistry {
Block brown_mushroom = (new BlockMushroom()).setHardness(0.0F).setSound(SoundType.GRASS).setLight(0.125F)
Block brown_mushroom = (new BlockMushroom()).setHardness(0.0F).setSound(SoundType.GRASS).setLight(0x1f1f1f)
.setDisplay("Pilz");
register("brown_mushroom", brown_mushroom);
register("brown_mushroom_block", (new BlockHugeMushroom(brown_mushroom)).setHardness(0.2F)
@ -280,7 +280,7 @@ public abstract class BlockRegistry {
register("red_mushroom", red_mushrooom);
register("red_mushroom_block", (new BlockHugeMushroom(red_mushrooom)).setHardness(0.2F)
.setSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS));
register("blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setSound(SoundType.GRASS).setLight(0.5F)
register("blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setSound(SoundType.GRASS).setLight(0x00007f)
.setDisplay("Tianpilz"));
Block pumpkin = (new BlockPumpkin()).setHardness(1.0F).setSound(SoundType.WOOD).setDisplay("Kürbis");
@ -317,9 +317,9 @@ public abstract class BlockRegistry {
register("web", (new BlockWeb()).setOpacity(1).setHardness(4.0F).setDisplay("Spinnennetz"));
register("fire", (new BlockFire()).setHardness(0.0F).setLight(1.0F).setSound(SoundType.CLOTH).setDisplay("Feuer"));
register("black_fire", (new BlockBlackFire()).setHardness(0.0F).setLight(1.0F).setSound(SoundType.CLOTH).setDisplay("Dunkles Feuer"));
register("soul_fire", (new BlockSoulFire()).setHardness(0.0F).setLight(1.0F).setSound(SoundType.CLOTH).setDisplay("Feuer der Seelen"));
register("fire", (new BlockFire()).setHardness(0.0F).setLight(0xffffbf).setSound(SoundType.CLOTH).setDisplay("Feuer"));
register("black_fire", (new BlockBlackFire()).setHardness(0.0F).setLight(0x7f7f7f).setSound(SoundType.CLOTH).setDisplay("Dunkles Feuer"));
register("soul_fire", (new BlockSoulFire()).setHardness(0.0F).setLight(0x0000ff).setSound(SoundType.CLOTH).setDisplay("Feuer der Seelen"));
register("glass", (new BlockGlass()).setHardness(0.3F).setSound(SoundType.GLASS).setDisplay("Glas"));
@ -348,7 +348,7 @@ public abstract class BlockRegistry {
register("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setSound(SoundType.WOOD).setDisplay("Bücherregal"));
register("cake", (new BlockCake()).setHardness(0.5F).setSound(SoundType.CLOTH).setDisplay("Kuchen").setTab(CheatTab.DECORATION));
register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setSound(SoundType.STONE)
.setLight(0.125F).setDisplay("Drachenei").setTab(CheatTab.DECORATION));
.setLight(0x1f001f).setDisplay("Drachenei").setTab(CheatTab.DECORATION));
register("flowerpot", (new BlockFlowerPot(null)).setHardness(0.0F).setSound(SoundType.STONE).setDisplay("Blumentopf").setTab(CheatTab.DECORATION));
register("flowerpot_cactus", (new BlockFlowerPot(cactus)).setHardness(0.0F).setSound(SoundType.STONE).setDisplay("Blumentopf mit " + cactus.getDisplay()));
for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
@ -371,10 +371,10 @@ public abstract class BlockRegistry {
for(PortalType portal : PortalType.values()) {
if(portal != PortalType.FLOOR && portal != PortalType.VOID)
register(portal.getName() + "_portal", (new BlockPortal(portal)).setHardness(0.0F).setSound(SoundType.GLASS).setLight(0.75F).setDisplay(portal.getDisplay()));
register(portal.getName() + "_portal", (new BlockPortal(portal)).setHardness(0.0F).setSound(SoundType.GLASS).setLight(0x1f1f1f).setDisplay(portal.getDisplay()));
}
register(PortalType.FLOOR.getName() + "_portal", (new BlockFloorPortal(Material.PORTAL)).setHardness(0.0F).setDisplay(PortalType.FLOOR.getDisplay()));
register("portal_frame", (new BlockPortalFrame()).setSound(SoundType.GLASS).setLight(0.125F).setHardness(5.0F)
register("portal_frame", (new BlockPortalFrame()).setSound(SoundType.GLASS).setLight(0x1f002f).setHardness(5.0F)
.setDisplay("Portalrahmen").setResistance(2000.0F).setTab(CheatTab.TECHNOLOGY));
register("farmland", (new BlockFarmland()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Ackerboden").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.PLANTS));
@ -589,9 +589,9 @@ public abstract class BlockRegistry {
register("anvil" + (z == 0 ? "" : "_damaged_" + z), (new BlockAnvil(z)).setHardness(5.0F).setSound(SoundType.ANVIL).setResistance(2000.0F).setDisplay((z == 0 ? "" : (z == 1 ? "Leicht beschädigter " : "Stark beschädigter ")) + "Amboss"));
}
register("enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch"));
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLight(0.125F).setDisplay("Braustand").setTab(CheatTab.TECHNOLOGY));
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLight(0x1f1f18).setDisplay("Braustand").setTab(CheatTab.TECHNOLOGY));
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel").setTab(CheatTab.TECHNOLOGY));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLight(1.0F));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLight(0xffffff));
register("wood_chest", new BlockChest(9, 3).setDisplay("Holztruhe"));
register("stone_chest", new BlockChest(9, 6).setDisplay("Steintruhe"));
@ -602,7 +602,7 @@ public abstract class BlockRegistry {
register("black_metal_chest", new BlockChest(28, 18).setDisplay("Schwarzmetalltruhe"));
register("nichun_chest", new BlockChest(32, 18).setDisplay("Nichuntruhe"));
register("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setSound(SoundType.STONE)
.setDisplay("Warptruhe").setLight(0.5F));
.setDisplay("Warptruhe").setLight(0x7f00af));
for(int z = 0; z < BlockTNT.TNTS.length; z++) {
register("tnt" + (z == 0 ? "" : "_" + z), (new BlockTNT(z)).setHardness(0.0F).setSound(SoundType.GRASS).setDisplay("TNT" + Util.getTierSuffix(z)));
@ -639,14 +639,14 @@ public abstract class BlockRegistry {
register("wire", (new BlockWire()).setHardness(0.0F).setSound(SoundType.STONE).setDisplay("Kabel").setTab(CheatTab.TECHNOLOGY));
BlockUnlitTorch torch;
register("torch", (torch = new BlockUnlitTorch(0xffffffff)).setHardness(0.0F).setSound(SoundType.WOOD).setDisplay("Fackel"));
register("lit_torch", (new BlockLitTorch(torch)).setHardness(0.0F).setLight(0.9375F).setSound(SoundType.WOOD).setDisplay("Fackel"));
register("lit_torch", (new BlockLitTorch(torch)).setHardness(0.0F).setLight(0xefef9f).setSound(SoundType.WOOD).setDisplay("Fackel"));
BlockUnlitTorch tian_torch;
register("tian_torch", (tian_torch = new BlockUnlitTorch(0x7f00ff)).setHardness(0.0F).setSound(SoundType.WOOD).setDisplay("Tian-Fackel"));
register("lit_tian_torch", (new BlockLitTorch(tian_torch)).setHardness(0.0F).setLight(0.5F).setSound(SoundType.WOOD)
register("lit_tian_torch", (new BlockLitTorch(tian_torch)).setHardness(0.0F).setLight(0xaf00ff).setSound(SoundType.WOOD)
.setDisplay("Tian-Fackel"));
BlockUnlitTorch soul_torch;
register("soul_torch", (soul_torch = new BlockUnlitTorch(0x1f1fff)).setHardness(0.0F).setSound(SoundType.WOOD).setDisplay("Seelenfackel"));
register("lit_soul_torch", (new BlockLitTorch(soul_torch)).setHardness(0.0F).setLight(0.75F).setSound(SoundType.WOOD)
register("lit_soul_torch", (new BlockLitTorch(soul_torch)).setHardness(0.0F).setLight(0x0000af).setSound(SoundType.WOOD)
.setDisplay("Seelenfackel"));
register("lamp", (new BlockToggleableLight(false)).setHardness(0.3F).setSound(SoundType.GLASS)
.setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY));

View file

@ -15,7 +15,7 @@ public class BlockArray {
private int ticked;
private int filled;
private char[] data;
private NibbleArray blocklight;
private int[] blocklight;
public BlockArray(int y, State filler) {
this.yBase = y;
@ -113,12 +113,12 @@ public class BlockArray {
public void setLight(int x, int y, int z, int value) {
if(this.blocklight == null)
this.blocklight = new NibbleArray();
this.blocklight.set(x, y, z, value);
this.blocklight = new int[4096];
this.blocklight[y << 8 | z << 4 | x] = value;
}
public int getLight(int x, int y, int z) {
return this.blocklight == null ? 0 : this.blocklight.get(x, y, z);
return this.blocklight == null ? 0 : this.blocklight[y << 8 | z << 4 | x];
}
public void clearLight() {

View file

@ -8,5 +8,5 @@ public interface IWorldAccess extends IBlockAccess
{
TileEntity getTileEntity(BlockPos pos);
@Clientside
int getCombinedLight(BlockPos pos, int lightValue);
int getCombinedLight(BlockPos pos);
}

View file

@ -187,7 +187,7 @@ public abstract class World implements IWorldAccess {
public void checkBlockLight(BlockPos pos) {
}
public int getCombinedLight(BlockPos pos, int lightValue) {
public int getCombinedLight(BlockPos pos) {
return 0;
}