1
0
Fork 0

remove more skylight

This commit is contained in:
Sen 2025-08-27 23:53:27 +02:00
parent 0873e0aab0
commit ae0dc2e7cf
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
15 changed files with 128 additions and 300 deletions

View file

@ -1969,8 +1969,8 @@ public class Client implements IThreadListener {
String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos), String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos),
Color.stripCodes(this.world.dimension.getDisplay()), Color.stripCodes(this.world.dimension.getDisplay()),
this.dimensionName) + "\n" + this.dimensionName) + "\n" +
"Licht: " + chunk.getLightSub(pos, 0) + " (" + chunk.getLight(LightType.SKY, pos) + " Himmel, " "Licht: " + chunk.getLightSub(pos, 0) + (this.world.dimension.hasSkyLight() ? " (" + World.getSkyLightFor(pos.getY()) + " Himmel, " : "")
+ chunk.getLight(LightType.BLOCK, pos) + " Blöcke, " + String.format( + chunk.getLight(pos) + " Blöcke, " + String.format(
"%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: " "%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f)) + "\n" + + String.format("%.1f °", this.world.getCelestialAngle(1.0f)) + "\n" +
String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""), String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""),

View file

@ -10,7 +10,6 @@ import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.util.Vec3i; import common.util.Vec3i;
import common.world.IWorldAccess; import common.world.IWorldAccess;
import common.world.LightType;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;
@ -127,8 +126,8 @@ public class RegionRenderCache implements IWorldAccess
public int getLight(BlockPos pos, int lightValue) public int getLight(BlockPos pos, int lightValue)
{ {
int i = this.getLightForExt(LightType.SKY, pos); int i = this.sky ? World.getSkyLightFor(pos.getY()) : 0;
int j = this.getLightForExt(LightType.BLOCK, pos); int j = this.getBlockLightExt(pos);
if (j < lightValue) if (j < lightValue)
{ {
@ -138,13 +137,9 @@ public class RegionRenderCache implements IWorldAccess
return i << 20 | j << 4; return i << 20 | j << 4;
} }
private int getLightForExt(LightType p_175629_1_, BlockPos pos) private int getBlockLightExt(BlockPos pos)
{ {
if (p_175629_1_ == LightType.SKY && !this.sky) if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{
return 0;
}
else if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{ {
if (this.getState(pos).getBlock().getSumBrightness()) if (this.getState(pos).getBlock().getSumBrightness())
{ {
@ -152,7 +147,7 @@ public class RegionRenderCache implements IWorldAccess
for (Facing enumfacing : Facing.values()) for (Facing enumfacing : Facing.values())
{ {
int k = this.getLightFor(p_175629_1_, pos.offset(enumfacing)); int k = this.getBlockLight(pos.offset(enumfacing));
if (k > l) if (k > l)
{ {
@ -171,26 +166,26 @@ public class RegionRenderCache implements IWorldAccess
{ {
int i = (pos.getX() >> 4) - this.xPos; int i = (pos.getX() >> 4) - this.xPos;
int j = (pos.getZ() >> 4) - this.zPos; int j = (pos.getZ() >> 4) - this.zPos;
return this.chunks[i][j].getLight(p_175629_1_, pos); return this.chunks[i][j].getLight(pos);
} }
} }
else else
{ {
return p_175629_1_.defValue; return 0;
} }
} }
public int getLightFor(LightType type, BlockPos pos) private int getBlockLight(BlockPos pos)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{ {
int i = (pos.getX() >> 4) - this.xPos; int i = (pos.getX() >> 4) - this.xPos;
int j = (pos.getZ() >> 4) - this.zPos; int j = (pos.getZ() >> 4) - this.zPos;
return this.chunks[i][j].getLight(type, pos); return this.chunks[i][j].getLight(pos);
} }
else else
{ {
return type.defValue; return 0;
} }
} }
} }

View file

@ -5,10 +5,6 @@ import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import common.log.Log; import common.log.Log;
import common.util.ExtMath; import common.util.ExtMath;

View file

@ -110,7 +110,6 @@ public class ChunkClient extends Chunk {
} }
} }
this.lightInit = true;
this.populated = true; this.populated = true;
this.genHeights(); this.genHeights();

View file

@ -73,11 +73,11 @@ public class ChunkEmpty extends ChunkClient {
return pos.getY() < this.liquidY ? this.dummyBlock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air); return pos.getY() < this.liquidY ? this.dummyBlock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air);
} }
public int getLight(LightType type, BlockPos pos) { public int getLight(BlockPos pos) {
return type.defValue; return 0;
} }
public void setLight(LightType type, BlockPos pos, int value) { public void setLight(BlockPos pos, int value) {
} }
public int getLightSub(BlockPos pos, int amount) { public int getLightSub(BlockPos pos, int amount) {
@ -161,7 +161,7 @@ public class ChunkEmpty extends ChunkClient {
public void enqueueRelight() { public void enqueueRelight() {
} }
public void checkLight() { public void setPopulated() {
} }
public boolean isLoaded() { public boolean isLoaded() {

View file

@ -52,7 +52,7 @@ public class BlockIce extends Block {
} }
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) { public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
if(Vars.iceMelt && (world.getLightFor(LightType.BLOCK, pos) > 11 - this.getLightOpacity() || !world.canFreezeAt(pos))) { if(Vars.iceMelt && (world.getLightFor(pos) > 11 - this.getLightOpacity() || !world.canFreezeAt(pos))) {
if(world.doesWaterVaporize(pos)) { if(world.doesWaterVaporize(pos)) {
world.setBlockToAir(pos); world.setBlockToAir(pos);
} }

View file

@ -131,7 +131,7 @@ public class BlockSnow extends Block
public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand) public void tick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{ {
if (Vars.snowMelt && (worldIn.getLightFor(LightType.BLOCK, pos) > 11 || !worldIn.canFreezeAt(pos))) if (Vars.snowMelt && (worldIn.getLightFor(pos) > 11 || !worldIn.canFreezeAt(pos)))
{ {
this.drop(worldIn, pos, worldIn.getState(pos), 0); this.drop(worldIn, pos, worldIn.getState(pos), 0);
worldIn.setBlockToAir(pos); worldIn.setBlockToAir(pos);

View file

@ -28,7 +28,7 @@ public class BlockSnowBlock extends Block {
} }
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) { public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
if(Vars.snowFullMelt && (world.getLightFor(LightType.BLOCK, pos) > 11 || !world.canFreezeAt(pos))) { if(Vars.snowFullMelt && (world.getLightFor(pos) > 11 || !world.canFreezeAt(pos))) {
this.drop(world, pos, world.getState(pos), 0); this.drop(world, pos, world.getState(pos), 0);
world.setBlockToAir(pos); world.setBlockToAir(pos);
} }

View file

@ -3433,7 +3433,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
} }
tag.setList("items", list); tag.setList("items", list);
if(this.isPlayer()) { if(this.isPlayer()) {
tag.setInt("held", this.getSelectedIndex()); tag.setInt("selected", this.getSelectedIndex());
} }
else { else {
TagObject item = new TagObject(); TagObject item = new TagObject();

View file

@ -20,7 +20,6 @@ import common.util.BlockPos;
import common.util.BoundingBox; import common.util.BoundingBox;
import common.util.InheritanceMultiMap; import common.util.InheritanceMultiMap;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.Facing;
import common.util.IntHashMap; import common.util.IntHashMap;
public abstract class Chunk { public abstract class Chunk {
@ -39,7 +38,6 @@ public abstract class Chunk {
protected boolean loaded; protected boolean loaded;
protected boolean populated; protected boolean populated;
protected boolean lightInit;
protected boolean updated; protected boolean updated;
protected boolean modified; protected boolean modified;
protected boolean hasEntity; protected boolean hasEntity;
@ -258,25 +256,15 @@ public abstract class Chunk {
} }
} }
public int getLight(LightType type, BlockPos pos) { public int getLight(BlockPos pos) {
int x = pos.getX() & 15; int x = pos.getX() & 15;
int y = pos.getY(); int y = pos.getY();
int z = pos.getZ() & 15; int z = pos.getZ() & 15;
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.getArray(y >> 4);
if(type == LightType.SKY) { return stor == null ? 0 : stor.getLight(x, y & 15, z);
int l = stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) : (this.world.dimension.hasSkyLight() ? 15 : 0);
if(y < 64) {
int max = y < 0 ? 0 : y / 4;
l = l > max ? max : l;
}
return l;
}
if(stor == null)
return this.canSeeSky(pos) ? type.defValue : 0;
return type == LightType.BLOCK ? stor.getLight(x, y & 15, z) : type.defValue;
} }
public void setLight(LightType type, BlockPos pos, int value) { public void setLight(BlockPos pos, int value) {
int x = pos.getX() & 15; int x = pos.getX() & 15;
int y = pos.getY(); int y = pos.getY();
int z = pos.getZ() & 15; int z = pos.getZ() & 15;
@ -290,9 +278,7 @@ public abstract class Chunk {
this.modified = true; this.modified = true;
if(type == LightType.BLOCK) { stor.setLight(x, y & 15, z, value);
stor.setLight(x, y & 15, z, value);
}
} }
public int getLightSub(BlockPos pos, int amount) { public int getLightSub(BlockPos pos, int amount) {
@ -300,11 +286,7 @@ public abstract class Chunk {
int y = pos.getY(); int y = pos.getY();
int z = pos.getZ() & 15; int z = pos.getZ() & 15;
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.getArray(y >> 4);
int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasSkyLight() ? 15 : 0); int l = this.world.dimension.hasSkyLight() ? World.getSkyLightFor(pos.getY()) : 0;
if(y < 64) {
int max = y < 0 ? 0 : y / 4;
l = l > max ? max : l;
}
if(stor == null) if(stor == null)
return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0; return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0;
l = l - amount; l = l - amount;
@ -491,10 +473,6 @@ public abstract class Chunk {
public void update(boolean noGaps) { public void update(boolean noGaps) {
this.updated = true; this.updated = true;
if(!this.lightInit && this.populated) {
this.checkLight();
}
while(!this.tileQueue.isEmpty()) { while(!this.tileQueue.isEmpty()) {
BlockPos pos = (BlockPos)this.tileQueue.poll(); BlockPos pos = (BlockPos)this.tileQueue.poll();
@ -507,97 +485,7 @@ public abstract class Chunk {
} }
public boolean isPopulated() { public boolean isPopulated() {
return this.updated && this.populated && this.lightInit; return this.updated && this.populated;
}
public void checkLight() {
this.populated = true;
this.lightInit = true;
BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4);
if(this.world.dimension.hasSkyLight()) {
if(this.world.isAreaLoaded(pos.add(-1, 0, -1), pos.add(16, this.world.getSeaLevel(), 16))) {
label92:
for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) {
if(!this.updateColumn(x, z)) {
this.lightInit = false;
break label92;
}
}
}
if(this.lightInit) {
for(Facing face : Facing.Plane.HORIZONTAL) {
int d = face.getAxisDirection() == Facing.AxisDirection.POSITIVE ? 16 : 1;
this.world.getChunk(pos.offset(face, d)).updateColumns(face.getOpposite());
}
}
}
else {
this.lightInit = false;
}
}
}
private void updateColumns(Facing facing) {
if(this.populated) {
if(facing == Facing.EAST) {
for(int z = 0; z < 16; ++z) {
this.updateColumn(15, z);
}
}
else if(facing == Facing.WEST) {
for(int z = 0; z < 16; ++z) {
this.updateColumn(0, z);
}
}
else if(facing == Facing.SOUTH) {
for(int x = 0; x < 16; ++x) {
this.updateColumn(x, 15);
}
}
else if(facing == Facing.NORTH) {
for(int x = 0; x < 16; ++x) {
this.updateColumn(x, 0);
}
}
}
}
private boolean updateColumn(int x, int z) {
int top = this.top;
int bottom = this.bottom < -64 ? -64 : this.bottom;
boolean opaque = false;
boolean below = false;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z);
for(int y = top + 16 - 1; y > this.world.getSeaLevel() || y > bottom && !below; --y) {
pos.set(pos.getX(), y, pos.getZ());
int o = this.getOpacity(pos);
if(o == 255 && pos.getY() < this.world.getSeaLevel()) {
below = true;
}
if(!opaque && o > 0) {
opaque = true;
}
else if(opaque && o == 0 && !this.world.checkLight(pos)) {
return false;
}
}
for(int y = pos.getY(); y > bottom; --y) {
pos.set(pos.getX(), y, pos.getZ());
if(this.getBlock(pos).getLight() > 0) {
this.world.checkLight(pos);
}
}
return true;
} }
public boolean isLoaded() { public boolean isLoaded() {

View file

@ -182,7 +182,7 @@ public abstract class World implements IWorldAccess {
return false; return false;
Block block1 = iblockstate.getBlock(); Block block1 = iblockstate.getBlock();
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight()) if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())
this.checkLight(pos); this.checkBlockLight(pos);
if((flags & 2) != 0 && (flags & 4) == 0 && chunk.isPopulated()) if((flags & 2) != 0 && (flags & 4) == 0 && chunk.isPopulated())
this.markBlockForUpdate(pos); this.markBlockForUpdate(pos);
return true; return true;
@ -221,12 +221,6 @@ public abstract class World implements IWorldAccess {
x2 = i; x2 = i;
} }
if(this.dimension.hasSkyLight()) {
for(int j = x2; j <= z2; ++j) {
this.checkLightFor(LightType.SKY, new BlockPos(x1, j, z1));
}
}
this.clientRenderUpdate(x1, x2, z1, x1, z2, z1); this.clientRenderUpdate(x1, x2, z1, x1, z2, z1);
} }
@ -317,90 +311,70 @@ public abstract class World implements IWorldAccess {
return new BlockPos(pos.getX(), i, pos.getZ()); return new BlockPos(pos.getX(), i, pos.getZ());
} }
public int getChunksLowestHorizon(int x, int z) { public int getBlockLightSum(BlockPos pos) {
if(x >= -MAX_SIZE && z >= -MAX_SIZE && x < MAX_SIZE && z < MAX_SIZE) {
if(!this.isLoaded(x >> 4, z >> 4, true)) {
return 0;
}
else {
Chunk chunk = this.getChunk(x >> 4, z >> 4);
return chunk.getLowest();
}
}
else {
return this.getSeaLevel() + 1;
}
}
public int getLightFromNeighborsFor(LightType type, BlockPos pos) {
if(!this.dimension.hasSkyLight() && type == LightType.SKY) {
return 0;
}
else {
if(pos.getY() < -MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ());
}
if(!isValid(pos)) {
return type.defValue;
}
else if(!this.isBlockLoaded(pos)) {
return type.defValue;
}
else if(this.getState(pos).getBlock().getSumBrightness()) {
int i1 = this.getLightFor(type, pos.up());
int i = this.getLightFor(type, pos.east());
int j = this.getLightFor(type, pos.west());
int k = this.getLightFor(type, pos.south());
int l = this.getLightFor(type, pos.north());
if(i > i1) {
i1 = i;
}
if(j > i1) {
i1 = j;
}
if(k > i1) {
i1 = k;
}
if(l > i1) {
i1 = l;
}
return i1;
}
else {
Chunk chunk = this.getChunk(pos);
return chunk.getLight(type, pos);
}
}
}
public int getLightFor(LightType type, BlockPos pos) {
if(pos.getY() < -MAX_SIZE_Y) { if(pos.getY() < -MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ()); pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ());
} }
if(!isValid(pos)) { if(!isValid(pos)) {
return type.defValue; return 0;
} }
else if(!this.isBlockLoaded(pos)) { else if(!this.isBlockLoaded(pos)) {
return type.defValue; return 0;
}
else if(this.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());
if(i > i1) {
i1 = i;
}
if(j > i1) {
i1 = j;
}
if(k > i1) {
i1 = k;
}
if(l > i1) {
i1 = l;
}
return i1;
} }
else { else {
Chunk chunk = this.getChunk(pos); Chunk chunk = this.getChunk(pos);
return chunk.getLight(type, pos); return chunk.getLight(pos);
} }
} }
public void setLightFor(LightType type, BlockPos pos, int lightValue) { public int getLightFor(BlockPos pos) {
if(pos.getY() < -MAX_SIZE_Y) {
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ());
}
if(!isValid(pos)) {
return 0;
}
else if(!this.isBlockLoaded(pos)) {
return 0;
}
else {
Chunk chunk = this.getChunk(pos);
return chunk.getLight(pos);
}
}
public void setBlockLight(BlockPos pos, int lightValue) {
if(isValid(pos)) { if(isValid(pos)) {
if(this.isBlockLoaded(pos)) { if(this.isBlockLoaded(pos)) {
Chunk chunk = this.getChunk(pos); Chunk chunk = this.getChunk(pos);
chunk.setLight(type, pos, lightValue); chunk.setLight(pos, lightValue);
this.clientNotifyLight(pos); this.clientNotifyLight(pos);
} }
} }
@ -408,8 +382,8 @@ public abstract class World implements IWorldAccess {
@Clientside @Clientside
public int getCombinedLight(BlockPos pos, int lightValue) { public int getCombinedLight(BlockPos pos, int lightValue) {
int i = this.getLightFromNeighborsFor(LightType.SKY, pos); int i = this.dimension.hasSkyLight() ? getSkyLightFor(pos.getY()) : 0;
int j = this.getLightFromNeighborsFor(LightType.BLOCK, pos); int j = this.getBlockLightSum(pos);
if(j < lightValue) { if(j < lightValue) {
j = lightValue; j = lightValue;
@ -1414,7 +1388,7 @@ public abstract class World implements IWorldAccess {
int l1 = ExtMath.floord(entityplayer1.posX) + this.rand.zrange(11) - 5; int l1 = ExtMath.floord(entityplayer1.posX) + this.rand.zrange(11) - 5;
int i2 = ExtMath.floord(entityplayer1.posY) + this.rand.zrange(11) - 5; int i2 = ExtMath.floord(entityplayer1.posY) + this.rand.zrange(11) - 5;
int j2 = ExtMath.floord(entityplayer1.posZ) + this.rand.zrange(11) - 5; int j2 = ExtMath.floord(entityplayer1.posZ) + this.rand.zrange(11) - 5;
this.checkLight(new BlockPos(l1, i2, j2)); this.checkBlockLight(new BlockPos(l1, i2, j2));
} }
return this.active; return this.active;
@ -1469,7 +1443,7 @@ public abstract class World implements IWorldAccess {
return true; return true;
} }
else { else {
if(pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y && this.getLightFor(LightType.BLOCK, pos) < 10) { if(pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y && this.getLightFor(pos) < 10) {
Block block = this.getState(pos).getBlock(); Block block = this.getState(pos).getBlock();
if((block == Blocks.air || (allowLayers && block == Blocks.snow_layer)) if((block == Blocks.air || (allowLayers && block == Blocks.snow_layer))
@ -1482,66 +1456,50 @@ public abstract class World implements IWorldAccess {
} }
} }
public boolean checkLight(BlockPos pos) { private int getRawBlockLight(BlockPos pos) {
boolean flag = false; Block block = this.getState(pos).getBlock();
int i = block.getLight();
int j = block.getLightOpacity();
if(this.dimension.hasSkyLight()) { if(j >= 15 && block.getLight() > 0) {
flag |= this.checkLightFor(LightType.SKY, pos); j = 1;
} }
flag = flag | this.checkLightFor(LightType.BLOCK, pos); if(j < 1) {
return flag; j = 1;
} }
private int getRawLight(BlockPos pos, LightType lightType) { if(j >= 15) {
if(lightType == LightType.SKY && this.canSeeSky(pos)) { return 0;
return pos.getY() < 64 ? (pos.getY() < 0 ? 0 : pos.getY() / 4) : 15; }
else if(i >= 14) {
return i;
} }
else { else {
Block block = this.getState(pos).getBlock(); for(Facing enumfacing : Facing.values()) {
int i = lightType == LightType.SKY ? 0 : block.getLight(); BlockPos blockpos = pos.offset(enumfacing);
int j = block.getLightOpacity(); int k = this.getLightFor(blockpos) - j;
if(j >= 15 && block.getLight() > 0) { if(k > i) {
j = 1; i = k;
}
if(j < 1) {
j = 1;
}
if(j >= 15) {
return 0;
}
else if(i >= 14) {
return i;
}
else {
for(Facing enumfacing : Facing.values()) {
BlockPos blockpos = pos.offset(enumfacing);
int k = this.getLightFor(lightType, blockpos) - j;
if(k > i) {
i = k;
}
if(i >= 14) {
return i;
}
} }
return i; if(i >= 14) {
return i;
}
} }
return i;
} }
} }
public boolean checkLightFor(LightType type, BlockPos pos) { public boolean checkBlockLight(BlockPos pos) {
if(!this.isAreaLoaded(pos, 17, false)) if(!this.isAreaLoaded(pos, 17, false))
return false; return false;
int done = 0; int done = 0;
int cnt = 0; int cnt = 0;
int light = this.getLightFor(type, pos); int light = this.getLightFor(pos);
int raw = this.getRawLight(pos, type); int raw = this.getRawBlockLight(pos);
int bx = pos.getX(); int bx = pos.getX();
int by = pos.getY(); int by = pos.getY();
int bz = pos.getZ(); int bz = pos.getZ();
@ -1559,10 +1517,10 @@ public abstract class World implements IWorldAccess {
int z = (p >> 12 & 63) - 32 + bz; int z = (p >> 12 & 63) - 32 + bz;
int s = p >> 18 & 15; int s = p >> 18 & 15;
BlockPos blk = new BlockPos(x, y, z); BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(type, blk); int l = this.getLightFor(blk);
if(l == s) { if(l == s) {
this.setLightFor(type, blk, 0); this.setBlockLight(blk, 0);
if(s > 0) { if(s > 0) {
int dx = ExtMath.absi(x - bx); int dx = ExtMath.absi(x - bx);
@ -1578,7 +1536,7 @@ public abstract class World implements IWorldAccess {
int oz = z + dir.getFrontOffsetZ(); int oz = z + dir.getFrontOffsetZ();
bpos.set(ox, oy, oz); bpos.set(ox, oy, oz);
int op = Math.max(1, this.getState(bpos).getBlock().getLightOpacity()); int op = Math.max(1, this.getState(bpos).getBlock().getLightOpacity());
l = this.getLightFor(type, bpos); l = this.getLightFor(bpos);
if(l == s - op && cnt < this.lightUpdate.length) { 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; this.lightUpdate[cnt++] = ox - bx + 32 | oy - by + 32 << 6 | oz - bz + 32 << 12 | s - op << 18;
@ -1598,11 +1556,11 @@ public abstract class World implements IWorldAccess {
int y = (p >> 6 & 63) - 32 + by; int y = (p >> 6 & 63) - 32 + by;
int z = (p >> 12 & 63) - 32 + bz; int z = (p >> 12 & 63) - 32 + bz;
BlockPos blk = new BlockPos(x, y, z); BlockPos blk = new BlockPos(x, y, z);
int l = this.getLightFor(type, blk); int l = this.getLightFor(blk);
int r = this.getRawLight(blk, type); int r = this.getRawBlockLight(blk);
if(r != l) { if(r != l) {
this.setLightFor(type, blk, r); this.setBlockLight(blk, r);
if(r > l) { if(r > l) {
int k6 = Math.abs(x - bx); int k6 = Math.abs(x - bx);
@ -1611,27 +1569,27 @@ public abstract class World implements IWorldAccess {
boolean flag = cnt < this.lightUpdate.length - 6; boolean flag = cnt < this.lightUpdate.length - 6;
if(k6 + l6 + i7 < 17 && flag) { if(k6 + l6 + i7 < 17 && flag) {
if(this.getLightFor(type, blk.west()) < r) { if(this.getLightFor(blk.west()) < r) {
this.lightUpdate[cnt++] = x - 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12); this.lightUpdate[cnt++] = x - 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
} }
if(this.getLightFor(type, blk.east()) < r) { if(this.getLightFor(blk.east()) < r) {
this.lightUpdate[cnt++] = x + 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12); this.lightUpdate[cnt++] = x + 1 - bx + 32 + (y - by + 32 << 6) + (z - bz + 32 << 12);
} }
if(this.getLightFor(type, blk.down()) < r) { if(this.getLightFor(blk.down()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - 1 - by + 32 << 6) + (z - bz + 32 << 12); this.lightUpdate[cnt++] = x - bx + 32 + (y - 1 - by + 32 << 6) + (z - bz + 32 << 12);
} }
if(this.getLightFor(type, blk.up()) < r) { if(this.getLightFor(blk.up()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y + 1 - by + 32 << 6) + (z - bz + 32 << 12); this.lightUpdate[cnt++] = x - bx + 32 + (y + 1 - by + 32 << 6) + (z - bz + 32 << 12);
} }
if(this.getLightFor(type, blk.north()) < r) { if(this.getLightFor(blk.north()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z - 1 - bz + 32 << 12); this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z - 1 - bz + 32 << 12);
} }
if(this.getLightFor(type, blk.south()) < r) { if(this.getLightFor(blk.south()) < r) {
this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z + 1 - bz + 32 << 12); this.lightUpdate[cnt++] = x - bx + 32 + (y - by + 32 << 6) + (z + 1 - bz + 32 << 12);
} }
} }
@ -1865,6 +1823,11 @@ public abstract class World implements IWorldAccess {
return ExtMath.clampd(Math.max(Math.max(xm, zm), ym), 0.0, 1.0); return ExtMath.clampd(Math.max(Math.max(xm, zm), ym), 0.0, 1.0);
} }
@Clientside
public static int getSkyLightFor(int y) {
return y < 0 ? 0 : (y < 64 ? y / 4 : 15);
}
public double getGravity(double x, double y, double z) { public double getGravity(double x, double y, double z) {
double gravity = this.gravity * (1.0 - this.getSpaceFactor(x, y, z)); double gravity = this.gravity * (1.0 - this.getSpaceFactor(x, y, z));
return Math.abs(gravity) < 0.075 ? 0.0 : gravity; return Math.abs(gravity) < 0.075 ? 0.0 : gravity;

View file

@ -20,7 +20,6 @@ public class ChunkServer extends Chunk {
public ChunkServer(WorldServer world, int x, int z) { public ChunkServer(WorldServer world, int x, int z) {
super(world, x, z); super(world, x, z);
this.lightInit = true;
this.updated = true; this.updated = true;
} }
@ -84,7 +83,6 @@ public class ChunkServer extends Chunk {
} }
if(!ceil) if(!ceil)
this.genSky(); this.genSky();
this.lightInit = true;
this.updated = true; this.updated = true;
} }
@ -161,14 +159,6 @@ public class ChunkServer extends Chunk {
this.populated = populated; this.populated = populated;
} }
public boolean isLightPopulated() {
return this.lightInit;
}
public void setLightPopulated(boolean populated) {
this.lightInit = populated;
}
public void setModified(boolean modified) { public void setModified(boolean modified) {
this.modified = modified; this.modified = modified;
} }

View file

@ -486,7 +486,6 @@ public class Region {
ChunkServer chunk = new ChunkServer(world, x, z); ChunkServer chunk = new ChunkServer(world, x, z);
chunk.setHeights(tag.getIntArray("H")); chunk.setHeights(tag.getIntArray("H"));
chunk.setTerrainPopulated(tag.getBool("P")); chunk.setTerrainPopulated(tag.getBool("P"));
chunk.setLightPopulated(tag.getBool("L"));
chunk.setInhabited(tag.getLong("I")); chunk.setInhabited(tag.getLong("I"));
List<TagObject> sects = tag.getList("S"); List<TagObject> sects = tag.getList("S");
BlockArray[] sections = new BlockArray[sects.size()]; BlockArray[] sections = new BlockArray[sects.size()];
@ -587,7 +586,6 @@ public class Region {
tag.setLong("U", world.getTime()); tag.setLong("U", world.getTime());
tag.setIntArray("H", chunk.getHeights()); tag.setIntArray("H", chunk.getHeights());
tag.setBool("P", chunk.isTerrainPopulated()); tag.setBool("P", chunk.isTerrainPopulated());
tag.setBool("L", chunk.isLightPopulated());
tag.setLong("I", chunk.getInhabited()); tag.setLong("I", chunk.getInhabited());
Set<BlockArray> sections = chunk.getStorage(); Set<BlockArray> sections = chunk.getStorage();
List<TagObject> sects = Lists.newArrayList(); List<TagObject> sects = Lists.newArrayList();

View file

@ -1402,7 +1402,7 @@ public final class WorldServer extends AWorldServer {
private void populate(int x, int z) { private void populate(int x, int z) {
ChunkServer chunk = this.getChunk(x, z); ChunkServer chunk = this.getChunk(x, z);
if(!chunk.isTerrainPopulated()) { if(!chunk.isTerrainPopulated()) {
chunk.checkLight(); chunk.setTerrainPopulated(true);
if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) { if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) {
chunk.setModified(true); chunk.setModified(true);
return; return;
@ -2027,7 +2027,7 @@ public final class WorldServer extends AWorldServer {
return false; return false;
Block block1 = iblockstate.getBlock(); Block block1 = iblockstate.getBlock();
if((flags & 8) == 0 && (block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())) if((flags & 8) == 0 && (block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight()))
this.checkLight(pos); this.checkBlockLight(pos);
if((flags & 2) != 0 && chunk.isPopulated()) if((flags & 2) != 0 && chunk.isPopulated())
this.markBlockForUpdate(pos); this.markBlockForUpdate(pos);
if((flags & 1) != 0) if((flags & 1) != 0)
@ -2064,7 +2064,7 @@ public final class WorldServer extends AWorldServer {
// if(update) { // if(update) {
// if(!successful) // if(!successful)
// newState = old; // newState = old;
this.checkLight(pos); this.checkBlockLight(pos);
if(chunk.isPopulated()) if(chunk.isPopulated())
this.markBlockForUpdate(pos); this.markBlockForUpdate(pos);
// this.notifyNeighborsRespectDebug(pos, old.getBlock()); // this.notifyNeighborsRespectDebug(pos, old.getBlock());
@ -2186,7 +2186,7 @@ public final class WorldServer extends AWorldServer {
return false; return false;
} }
else { else {
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y && this.getLightFor(LightType.BLOCK, pos) < 10) { if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y && this.getLightFor(pos) < 10) {
State iblockstate = this.getState(pos); State iblockstate = this.getState(pos);
Block block = iblockstate.getBlock(); Block block = iblockstate.getBlock();

View file

@ -5,7 +5,6 @@ import common.block.Material;
import common.init.Blocks; import common.init.Blocks;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
import common.world.LightType;
import common.world.State; import common.world.State;
import server.world.WorldServer; import server.world.WorldServer;
@ -167,7 +166,7 @@ public class FeatureLakes
{ {
BlockPos blockpos = position.add(i2, j4 - 1, j3); BlockPos blockpos = position.add(i2, j4 - 1, j3);
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0) if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getState(blockpos.up()).getBlock() == Blocks.air)
{ {
worldIn.setState(blockpos, this.top, 2); worldIn.setState(blockpos, this.top, 2);
} }