diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 4827311c..d3d1dafa 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -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), Color.stripCodes(this.world.dimension.getDisplay()), this.dimensionName) + "\n" + - "Licht: " + chunk.getLightSub(pos, 0) + " (" + chunk.getLight(LightType.SKY, pos) + " Himmel, " - + chunk.getLight(LightType.BLOCK, pos) + " Blöcke, " + String.format( + "Licht: " + chunk.getLightSub(pos, 0) + (this.world.dimension.hasSkyLight() ? " (" + World.getSkyLightFor(pos.getY()) + " Himmel, " : "") + + chunk.getLight(pos) + " Blöcke, " + String.format( "%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: " + 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" : ""), diff --git a/client/src/main/java/client/renderer/RegionRenderCache.java b/client/src/main/java/client/renderer/RegionRenderCache.java index ef9397e5..5e59ef1d 100755 --- a/client/src/main/java/client/renderer/RegionRenderCache.java +++ b/client/src/main/java/client/renderer/RegionRenderCache.java @@ -10,7 +10,6 @@ import common.util.BlockPos; import common.util.Facing; import common.util.Vec3i; import common.world.IWorldAccess; -import common.world.LightType; import common.world.State; import common.world.World; @@ -127,8 +126,8 @@ public class RegionRenderCache implements IWorldAccess public int getLight(BlockPos pos, int lightValue) { - int i = this.getLightForExt(LightType.SKY, pos); - int j = this.getLightForExt(LightType.BLOCK, pos); + int i = this.sky ? World.getSkyLightFor(pos.getY()) : 0; + int j = this.getBlockLightExt(pos); if (j < lightValue) { @@ -138,13 +137,9 @@ public class RegionRenderCache implements IWorldAccess 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) - { - return 0; - } - else 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) { if (this.getState(pos).getBlock().getSumBrightness()) { @@ -152,7 +147,7 @@ public class RegionRenderCache implements IWorldAccess 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) { @@ -171,26 +166,26 @@ public class RegionRenderCache implements IWorldAccess { int i = (pos.getX() >> 4) - this.xPos; 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 { - 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) { int i = (pos.getX() >> 4) - this.xPos; int j = (pos.getZ() >> 4) - this.zPos; - return this.chunks[i][j].getLight(type, pos); + return this.chunks[i][j].getLight(pos); } else { - return type.defValue; + return 0; } } } diff --git a/client/src/main/java/client/renderer/RenderBuffer.java b/client/src/main/java/client/renderer/RenderBuffer.java index a111d3ff..026d5d75 100755 --- a/client/src/main/java/client/renderer/RenderBuffer.java +++ b/client/src/main/java/client/renderer/RenderBuffer.java @@ -5,10 +5,6 @@ import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; -import java.util.Arrays; -import java.util.BitSet; -import java.util.Comparator; - import common.log.Log; import common.util.ExtMath; diff --git a/client/src/main/java/client/world/ChunkClient.java b/client/src/main/java/client/world/ChunkClient.java index 2bfb5af9..0c87001c 100644 --- a/client/src/main/java/client/world/ChunkClient.java +++ b/client/src/main/java/client/world/ChunkClient.java @@ -110,7 +110,6 @@ public class ChunkClient extends Chunk { } } - this.lightInit = true; this.populated = true; this.genHeights(); diff --git a/client/src/main/java/client/world/ChunkEmpty.java b/client/src/main/java/client/world/ChunkEmpty.java index 76cffbd8..3cb0fa5b 100755 --- a/client/src/main/java/client/world/ChunkEmpty.java +++ b/client/src/main/java/client/world/ChunkEmpty.java @@ -73,11 +73,11 @@ public class ChunkEmpty extends ChunkClient { return pos.getY() < this.liquidY ? this.dummyBlock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air); } - public int getLight(LightType type, BlockPos pos) { - return type.defValue; + public int getLight(BlockPos pos) { + 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) { @@ -161,7 +161,7 @@ public class ChunkEmpty extends ChunkClient { public void enqueueRelight() { } - public void checkLight() { + public void setPopulated() { } public boolean isLoaded() { diff --git a/common/src/main/java/common/block/natural/BlockIce.java b/common/src/main/java/common/block/natural/BlockIce.java index 2cca363a..c8ab8f26 100755 --- a/common/src/main/java/common/block/natural/BlockIce.java +++ b/common/src/main/java/common/block/natural/BlockIce.java @@ -52,7 +52,7 @@ public class BlockIce extends Block { } 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)) { world.setBlockToAir(pos); } diff --git a/common/src/main/java/common/block/natural/BlockSnow.java b/common/src/main/java/common/block/natural/BlockSnow.java index b284e6a9..6f276e0e 100755 --- a/common/src/main/java/common/block/natural/BlockSnow.java +++ b/common/src/main/java/common/block/natural/BlockSnow.java @@ -131,7 +131,7 @@ public class BlockSnow extends Block 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); worldIn.setBlockToAir(pos); diff --git a/common/src/main/java/common/block/natural/BlockSnowBlock.java b/common/src/main/java/common/block/natural/BlockSnowBlock.java index 16a8cf2a..0318f5f0 100755 --- a/common/src/main/java/common/block/natural/BlockSnowBlock.java +++ b/common/src/main/java/common/block/natural/BlockSnowBlock.java @@ -28,7 +28,7 @@ public class BlockSnowBlock extends Block { } 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); world.setBlockToAir(pos); } diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index 78187884..69e1045a 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -3433,7 +3433,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory } tag.setList("items", list); if(this.isPlayer()) { - tag.setInt("held", this.getSelectedIndex()); + tag.setInt("selected", this.getSelectedIndex()); } else { TagObject item = new TagObject(); diff --git a/common/src/main/java/common/world/Chunk.java b/common/src/main/java/common/world/Chunk.java index 7696bd69..f80bcf79 100755 --- a/common/src/main/java/common/world/Chunk.java +++ b/common/src/main/java/common/world/Chunk.java @@ -20,7 +20,6 @@ import common.util.BlockPos; import common.util.BoundingBox; import common.util.InheritanceMultiMap; import common.util.ExtMath; -import common.util.Facing; import common.util.IntHashMap; public abstract class Chunk { @@ -39,7 +38,6 @@ public abstract class Chunk { protected boolean loaded; protected boolean populated; - protected boolean lightInit; protected boolean updated; protected boolean modified; 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 y = pos.getY(); int z = pos.getZ() & 15; BlockArray stor = this.getArray(y >> 4); - if(type == LightType.SKY) { - 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; + return stor == null ? 0 : stor.getLight(x, y & 15, z); } - public void setLight(LightType type, BlockPos pos, int value) { + public void setLight(BlockPos pos, int value) { int x = pos.getX() & 15; int y = pos.getY(); int z = pos.getZ() & 15; @@ -290,9 +278,7 @@ public abstract class Chunk { 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) { @@ -300,11 +286,7 @@ public abstract class Chunk { int y = pos.getY(); int z = pos.getZ() & 15; BlockArray stor = this.getArray(y >> 4); - int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasSkyLight() ? 15 : 0); - if(y < 64) { - int max = y < 0 ? 0 : y / 4; - l = l > max ? max : l; - } + int l = this.world.dimension.hasSkyLight() ? World.getSkyLightFor(pos.getY()) : 0; if(stor == null) return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0; l = l - amount; @@ -491,10 +473,6 @@ public abstract class Chunk { public void update(boolean noGaps) { this.updated = true; - if(!this.lightInit && this.populated) { - this.checkLight(); - } - while(!this.tileQueue.isEmpty()) { BlockPos pos = (BlockPos)this.tileQueue.poll(); @@ -507,97 +485,7 @@ public abstract class Chunk { } public boolean isPopulated() { - return this.updated && this.populated && this.lightInit; - } - - 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; + return this.updated && this.populated; } public boolean isLoaded() { diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index fa2f6a51..f8ea5d43 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -182,7 +182,7 @@ public abstract class World implements IWorldAccess { return false; Block block1 = iblockstate.getBlock(); if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight()) - this.checkLight(pos); + this.checkBlockLight(pos); if((flags & 2) != 0 && (flags & 4) == 0 && chunk.isPopulated()) this.markBlockForUpdate(pos); return true; @@ -221,12 +221,6 @@ public abstract class World implements IWorldAccess { 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); } @@ -317,90 +311,70 @@ public abstract class World implements IWorldAccess { return new BlockPos(pos.getX(), i, pos.getZ()); } - public int getChunksLowestHorizon(int x, int z) { - 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) { + public int getBlockLightSum(BlockPos pos) { if(pos.getY() < -MAX_SIZE_Y) { pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ()); } if(!isValid(pos)) { - return type.defValue; + return 0; } 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 { 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(this.isBlockLoaded(pos)) { Chunk chunk = this.getChunk(pos); - chunk.setLight(type, pos, lightValue); + chunk.setLight(pos, lightValue); this.clientNotifyLight(pos); } } @@ -408,8 +382,8 @@ public abstract class World implements IWorldAccess { @Clientside public int getCombinedLight(BlockPos pos, int lightValue) { - int i = this.getLightFromNeighborsFor(LightType.SKY, pos); - int j = this.getLightFromNeighborsFor(LightType.BLOCK, pos); + int i = this.dimension.hasSkyLight() ? getSkyLightFor(pos.getY()) : 0; + int j = this.getBlockLightSum(pos); if(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 i2 = ExtMath.floord(entityplayer1.posY) + 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; @@ -1469,7 +1443,7 @@ public abstract class World implements IWorldAccess { return true; } 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(); if((block == Blocks.air || (allowLayers && block == Blocks.snow_layer)) @@ -1482,66 +1456,50 @@ public abstract class World implements IWorldAccess { } } - public boolean checkLight(BlockPos pos) { - boolean flag = false; + private int getRawBlockLight(BlockPos pos) { + Block block = this.getState(pos).getBlock(); + int i = block.getLight(); + int j = block.getLightOpacity(); - if(this.dimension.hasSkyLight()) { - flag |= this.checkLightFor(LightType.SKY, pos); + if(j >= 15 && block.getLight() > 0) { + j = 1; } - flag = flag | this.checkLightFor(LightType.BLOCK, pos); - return flag; - } + if(j < 1) { + j = 1; + } - private int getRawLight(BlockPos pos, LightType lightType) { - if(lightType == LightType.SKY && this.canSeeSky(pos)) { - return pos.getY() < 64 ? (pos.getY() < 0 ? 0 : pos.getY() / 4) : 15; + if(j >= 15) { + return 0; + } + else if(i >= 14) { + return i; } else { - Block block = this.getState(pos).getBlock(); - int i = lightType == LightType.SKY ? 0 : block.getLight(); - int j = block.getLightOpacity(); + for(Facing enumfacing : Facing.values()) { + BlockPos blockpos = pos.offset(enumfacing); + int k = this.getLightFor(blockpos) - j; - if(j >= 15 && block.getLight() > 0) { - j = 1; - } - - 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; - } + if(k > i) { + i = k; } - 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)) return false; int done = 0; int cnt = 0; - int light = this.getLightFor(type, pos); - int raw = this.getRawLight(pos, type); + int light = this.getLightFor(pos); + int raw = this.getRawBlockLight(pos); int bx = pos.getX(); int by = pos.getY(); int bz = pos.getZ(); @@ -1559,10 +1517,10 @@ public abstract class World implements IWorldAccess { int z = (p >> 12 & 63) - 32 + bz; int s = p >> 18 & 15; BlockPos blk = new BlockPos(x, y, z); - int l = this.getLightFor(type, blk); + int l = this.getLightFor(blk); if(l == s) { - this.setLightFor(type, blk, 0); + this.setBlockLight(blk, 0); if(s > 0) { int dx = ExtMath.absi(x - bx); @@ -1578,7 +1536,7 @@ public abstract class World implements IWorldAccess { int oz = z + dir.getFrontOffsetZ(); bpos.set(ox, oy, oz); 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) { 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 z = (p >> 12 & 63) - 32 + bz; BlockPos blk = new BlockPos(x, y, z); - int l = this.getLightFor(type, blk); - int r = this.getRawLight(blk, type); + int l = this.getLightFor(blk); + int r = this.getRawBlockLight(blk); if(r != l) { - this.setLightFor(type, blk, r); + this.setBlockLight(blk, r); if(r > l) { int k6 = Math.abs(x - bx); @@ -1611,27 +1569,27 @@ public abstract class World implements IWorldAccess { boolean flag = cnt < this.lightUpdate.length - 6; 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); } - 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); } - 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); } - 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); } - 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); } - 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); } } @@ -1864,6 +1822,11 @@ public abstract class World implements IWorldAccess { double zm = (Math.abs(z) - r) / 16384.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) { double gravity = this.gravity * (1.0 - this.getSpaceFactor(x, y, z)); diff --git a/server/src/main/java/server/world/ChunkServer.java b/server/src/main/java/server/world/ChunkServer.java index 5180fe9b..1c874c0e 100644 --- a/server/src/main/java/server/world/ChunkServer.java +++ b/server/src/main/java/server/world/ChunkServer.java @@ -20,7 +20,6 @@ public class ChunkServer extends Chunk { public ChunkServer(WorldServer world, int x, int z) { super(world, x, z); - this.lightInit = true; this.updated = true; } @@ -84,7 +83,6 @@ public class ChunkServer extends Chunk { } if(!ceil) this.genSky(); - this.lightInit = true; this.updated = true; } @@ -161,14 +159,6 @@ public class ChunkServer extends Chunk { this.populated = populated; } - public boolean isLightPopulated() { - return this.lightInit; - } - - public void setLightPopulated(boolean populated) { - this.lightInit = populated; - } - public void setModified(boolean modified) { this.modified = modified; } diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 4f3208e0..700991c1 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -486,7 +486,6 @@ public class Region { ChunkServer chunk = new ChunkServer(world, x, z); chunk.setHeights(tag.getIntArray("H")); chunk.setTerrainPopulated(tag.getBool("P")); - chunk.setLightPopulated(tag.getBool("L")); chunk.setInhabited(tag.getLong("I")); List sects = tag.getList("S"); BlockArray[] sections = new BlockArray[sects.size()]; @@ -587,7 +586,6 @@ public class Region { tag.setLong("U", world.getTime()); tag.setIntArray("H", chunk.getHeights()); tag.setBool("P", chunk.isTerrainPopulated()); - tag.setBool("L", chunk.isLightPopulated()); tag.setLong("I", chunk.getInhabited()); Set sections = chunk.getStorage(); List sects = Lists.newArrayList(); diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index 4149c667..a6dff5a0 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -1402,7 +1402,7 @@ public final class WorldServer extends AWorldServer { private void populate(int x, int z) { ChunkServer chunk = this.getChunk(x, z); if(!chunk.isTerrainPopulated()) { - chunk.checkLight(); + chunk.setTerrainPopulated(true); if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) { chunk.setModified(true); return; @@ -2027,7 +2027,7 @@ public final class WorldServer extends AWorldServer { return false; Block block1 = iblockstate.getBlock(); if((flags & 8) == 0 && (block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())) - this.checkLight(pos); + this.checkBlockLight(pos); if((flags & 2) != 0 && chunk.isPopulated()) this.markBlockForUpdate(pos); if((flags & 1) != 0) @@ -2064,7 +2064,7 @@ public final class WorldServer extends AWorldServer { // if(update) { // if(!successful) // newState = old; - this.checkLight(pos); + this.checkBlockLight(pos); if(chunk.isPopulated()) this.markBlockForUpdate(pos); // this.notifyNeighborsRespectDebug(pos, old.getBlock()); @@ -2186,7 +2186,7 @@ public final class WorldServer extends AWorldServer { return false; } 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); Block block = iblockstate.getBlock(); diff --git a/server/src/main/java/server/worldgen/component/FeatureLakes.java b/server/src/main/java/server/worldgen/component/FeatureLakes.java index 265747c1..83532d64 100755 --- a/server/src/main/java/server/worldgen/component/FeatureLakes.java +++ b/server/src/main/java/server/worldgen/component/FeatureLakes.java @@ -5,7 +5,6 @@ import common.block.Material; import common.init.Blocks; import common.rng.Random; import common.util.BlockPos; -import common.world.LightType; import common.world.State; import server.world.WorldServer; @@ -167,7 +166,7 @@ public class FeatureLakes { 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); }