1
0
Fork 0

make light clientside

This commit is contained in:
Sen 2025-08-30 12:03:46 +02:00
parent e3e5fbd7fd
commit 16d20fb31d
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
54 changed files with 556 additions and 1316 deletions

View file

@ -348,7 +348,6 @@ public class Client implements IThreadListener {
super(dim, true);
this.orbit = dim.getOrbit();
this.rotation = dim.getRotation();
this.calculateInitialSkylight();
this.calculateInitialWeather();
this.updatePhysics();
}
@ -424,6 +423,14 @@ public class Client implements IThreadListener {
public void setLastLightning(int last, int color) {
Client.this.renderer.setLastLightning(last, color);
}
public void checkBlockLight(BlockPos pos) {
Client.this.renderer.checkBlockLight(pos);
}
public int getCombinedLight(BlockPos pos, int lightValue) {
return Client.this.renderer.getCombinedLight(pos, lightValue);
}
}
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
@ -590,6 +597,10 @@ public class Client implements IThreadListener {
public int renderDistance = 8;
@Variable(name = "chunk_build_time", category = CVarCategory.RENDER, min = 1, max = 100, display = "Zeit für Chunk-Bau", unit = "ms")
public int maxBuildTime = 8;
@Variable(name = "chunk_light_updates", category = CVarCategory.RENDER, min = 100, max = 10000, display = "Licht-Updates / Tick")
private int lightUpdates = 2048;
@Variable(name = "chunk_light_range", category = CVarCategory.RENDER, min = 5, max = 1024, display = "Radius Licht-Updates")
private int lightRange = 32;
@Variable(name = "gl_fov", category = CVarCategory.RENDER, min = 1.0f, max = 179.0f, display = "Sichtfeld (FOV)", unit = "°", precision = 1)
public float fov = 70.0f;
@Variable(name = "gl_wireframe", category = CVarCategory.RENDER, display = "Gitter-Render-Modus")
@ -2042,11 +2053,11 @@ 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() ? + World.getSkyLightFor(pos.getY()) + " Himmel, " : "")
"Licht: " + chunk.getLightSub(pos, 0) + " (" + (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.world.getCelestialAngle(1.0f), !this.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos((-90.0f + this.world.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI),
!this.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin((-90.0f + this.world.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI)) + "\n" +
+ 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),
!this.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin((-90.0f + this.renderer.getCelestialAngle(1.0f)) / 180.0f * (float)Math.PI)) + "\n" +
String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""),
this.world.formatEpochSimple(),
this.world.getRotation(),
@ -3666,16 +3677,25 @@ public class Client implements IThreadListener {
long time = System.currentTimeMillis();
for (ChunkClient chunk : this.chunkListing)
{
chunk.update(System.currentTimeMillis() - time > 5L);
chunk.spawnTiles();
}
if (System.currentTimeMillis() - time > 100L)
{
Log.TICK.warn("Render-Chunk-Tick dauerte " + (System.currentTimeMillis() - time) + " ms");
}
Set<ChunkPos> active = this.world.setActivePlayerChunksAndCheckLight(this.renderDistance);
this.previousActive.retainAll(active);
if(this.player != null) {
int radius = Math.min(this.renderDistance * 16, this.lightRange);
for(int n = 0; n < this.lightUpdates; n++) {
int x = ExtMath.floord(this.player.posX) + this.world.rand.range(-radius, radius);
int y = ExtMath.floord(this.player.posY) + this.world.rand.range(-radius, radius);
int z = ExtMath.floord(this.player.posZ) + this.world.rand.range(-radius, radius);
this.world.checkBlockLight(new BlockPos(x, y, z));
}
}
Set<ChunkPos> active = this.world.setActiveChunks(this.renderDistance);
this.previousActive.retainAll(active);
if (this.previousActive.size() == active.size())
{
this.previousActive.clear();