pre genlayer rework

This commit is contained in:
Sen 2025-07-22 21:20:06 +02:00
parent 0525ba5d56
commit 0f128c1b1b
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
112 changed files with 2464 additions and 3353 deletions

View file

@ -99,7 +99,6 @@ import client.window.WindowEvent;
import client.world.ChunkClient;
import client.world.WorldClient;
import common.Version;
import common.biome.Biome;
import common.block.Block;
import common.collect.Lists;
import common.collect.Maps;
@ -523,7 +522,6 @@ public class Client implements IThreadListener {
Window.init();
ModelBlock.setAsProvider();
Registry.register();
UniverseRegistry.register();
Log.setSync(CLIENT);
CLIENT.run(time);
Window.end();
@ -1721,15 +1719,13 @@ public class Client implements IThreadListener {
break;
}
Biome biome = null;
String bline;
String lline;
if(this.world.isBlockLoaded(blockpos)) {
ChunkClient chunk = this.world.getChunk(blockpos);
biome = chunk.getBiome(blockpos);
bline = "Biom: " + biome.display + " (" + biome.name + "), D: " +
TextColor.stripCodes(this.world.dimension.getDisplay()) +
" (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")";
bline = String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", 0.0f, 0.0f,
TextColor.stripCodes(this.world.dimension.getDisplay()),
this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName);
lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, "
+ chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format(
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
@ -1744,7 +1740,6 @@ public class Client implements IThreadListener {
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f));
}
float temp = Math.max(this.world.getTempOffset() + (biome != null ? biome.getTemperature(blockpos) : 0.0f), 0.0f);
long ticked = System.currentTimeMillis() - this.lastTicked;
return
@ -1780,7 +1775,7 @@ public class Client implements IThreadListener {
String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)",
!this.world.dimension.hasSeasons() ? "*" : "",
this.world.getLeavesGen(blockpos).getDisplayName(),
temp, World.ABSOLUTE_ZERO + temp,
this.world.getTemperatureK(blockpos), this.world.getTemperatureC(blockpos),
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
this.world.getDarkness()
) + "\n" +

View file

@ -90,7 +90,7 @@ public class GuiCreateDimension extends Gui {
private static Dimension addFlatPreset(String display, String base, Biome biome, boolean populate, State main, Object ... layers) {
Dimension dim = addPreset("Flach - " + display, base, "ClearGenerator:1b" + (populate ? "" : ",NoPopulation:1b"));
dim.setBiome(biome);
// dim.setBiome(biome); // TODO: populator
if(main != null)
dim.setFlatGen(main, layers);
return dim;
@ -121,18 +121,18 @@ public class GuiCreateDimension extends Gui {
52, Blocks.dirt.getState(), 5, Blocks.sand.getState(), 90, Blocks.water.getState());
addFlatPreset("Oberfläche", Biome.PLAIN, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
3, Blocks.dirt.getState(), Blocks.grass.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages().enableStrongholds().enableMineshafts().setDungeons(8)
3, Blocks.dirt.getState(), Blocks.grass.getState()).setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages().enableStrongholds().enableMineshafts().setDungeons(8)
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false).addLake(Blocks.lava.getState(), Blocks.stone.getState(), null, 8, 8, 255, true);
addFlatPreset("Verschneites Königreich", Biome.ICE, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).enableVillages();
addFlatPreset("Verschneites Königreich +", Biome.ICE, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages()
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages()
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false);
addFlatPreset("Unendliche Grube", Biome.PLAIN, false, Blocks.dirt.getState(), 2, Blocks.cobblestone.getState(), 3, Blocks.dirt.getState(), Blocks.grass.getState())
.setBiomeReplacer(Blocks.gravel.getState()).enableVillages();
.setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).enableVillages();
addFlatPreset("Wüste", Biome.DESERT, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), 52, Blocks.sandstone.getState())
.enableVillages().enableScattered();

View file

@ -90,7 +90,6 @@ import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketTabComplete;
import common.packet.SPacketUpdateEntityTags;
import common.packet.SPacketAnimation;
import common.packet.SPacketBiome;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
@ -768,14 +767,6 @@ public class ClientPlayer implements IClientPlayer
}
}
public void handleBiomes(SPacketBiome packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
ChunkClient chunk = this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
chunk.setBiome(packetIn.getPos(), packetIn.getBiome());
this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15);
}
/**
* Updates the block and metadata and generates a blockupdate (and notify the clients)
*/

View file

@ -13,7 +13,6 @@ import client.Client;
import client.renderer.texture.DynamicTexture;
import client.renderer.texture.TextureMap;
import client.world.WorldClient;
import common.biome.Biome;
import common.block.Block;
import common.block.Material;
import common.effect.Effect;
@ -1140,10 +1139,9 @@ public class EntityRenderer {
for (int l = 0; l < k; ++l)
{
BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i)));
Biome biomegenbase = world.getBiomeGenForCoords(blockpos1);
BlockPos blockpos2 = blockpos1.down();
Block block = world.getState(blockpos2).getBlock();
float temp = World.ABSOLUTE_ZERO + world.getTempOffset() + biomegenbase.getTemperature(blockpos1);
float temp = world.getTemperatureC(blockpos1);
if (blockpos1.getY() <= blockpos.getY() + i && blockpos1.getY() >= blockpos.getY() - i && /* biomegenbase.canRain() && */ temp > 0.0F)
{
@ -1235,7 +1233,6 @@ public class EntityRenderer {
double rx = (double)this.rainXCoords[idx] * 0.5D;
double rz = (double)this.rainZCoords[idx] * 0.5D;
pos.set(x, 0, z);
Biome biome = world.getBiomeGenForCoords(pos);
int prec = world.getPrecipitationHeight(pos).getY();
int miny = ey - hrange;
@ -1258,7 +1255,7 @@ public class EntityRenderer {
if(miny != maxy) {
this.random.setSeed((long)(x * x * 3121 + x * 45238971 ^ z * z * 418711 + z * 13761));
pos.set(x, miny, z);
float temp = World.ABSOLUTE_ZERO + world.getTempOffset() + biome.getTemperature(pos);
float temp = world.getTemperatureC(pos);
if(temp > 0.0F) {
if(mode != (temp >= 194.0f ? 2 : (temp <= 5.0f ? 3 : 0))) {

View file

@ -4,7 +4,6 @@ import java.util.Arrays;
import client.world.ChunkClient;
import client.world.WorldClient;
import common.biome.Biome;
import common.init.Blocks;
import common.tileentity.TileEntity;
import common.util.BlockPos;
@ -139,11 +138,6 @@ public class RegionRenderCache implements IWorldAccess
return i << 20 | j << 4;
}
public Biome getBiomeGenForCoords(BlockPos pos)
{
return this.world.getBiomeGenForCoords(pos);
}
private int getLightForExt(LightType p_175629_1_, BlockPos pos)
{
if (p_175629_1_ == LightType.SKY && !this.world.dimension.hasSkyLight())

View file

@ -1,6 +1,5 @@
package client.world;
import common.biome.Biome;
import common.block.Block;
import common.init.Blocks;
import common.tileentity.TileEntity;
@ -11,6 +10,9 @@ import common.world.Chunk;
import common.world.World;
public class ChunkClient extends Chunk {
private final float[] temperatures = new float[256];
private final float[] offsets = new float[256];
public ChunkClient(World world, int x, int z) {
super(world, x, z);
}
@ -105,9 +107,11 @@ public class ChunkClient extends Chunk {
}
if(biomes) {
for(int k = 0; k < this.biomes.length; ++k) {
this.biomes[k] = (char)((data[pos + 1] & 255) << 8 | data[pos] & 255);
pos += 2;
for(int k = 0; k < this.temperatures.length; ++k) {
this.temperatures[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255));
pos += 4;
this.offsets[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255));
pos += 4;
}
}
@ -130,12 +134,20 @@ public class ChunkClient extends Chunk {
public void setLoaded() {
this.loaded = true;
}
public void setBiome(BlockPos pos, Biome biome) {
this.biomes[((pos.getZ() & 15) << 4 | pos.getX() & 15)] = (char)biome.id;
}
public boolean isDummy() {
return false;
}
public float getTemperature(BlockPos pos) {
int x = pos.getX() & 15;
int z = pos.getZ() & 15;
return this.temperatures[z << 4 | x];
}
public float getOffset(BlockPos pos) {
int x = pos.getX() & 15;
int z = pos.getZ() & 15;
return this.offsets[z << 4 | x];
}
}

View file

@ -3,7 +3,6 @@ package client.world;
import java.util.List;
import java.util.function.Predicate;
import common.biome.Biome;
import common.block.Block;
import common.block.natural.BlockFire;
import common.collect.Lists;
@ -146,12 +145,13 @@ public class ChunkEmpty extends ChunkClient {
public void setData(byte[] data, int[] extend, boolean biomes) {
}
public Biome getBiome(BlockPos pos) {
return Biome.DEF_BIOME;
public float getTemperature(BlockPos pos) {
return 0.0f;
}
public void setBiome(BlockPos pos, Biome biome) {
public float getOffset(BlockPos pos) {
return 0.0f;
}
public void resetRelight() {

View file

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Set;
import client.Client;
import common.biome.Biome;
import common.collect.Lists;
import common.collect.Sets;
import common.dimension.Dimension;
@ -411,11 +410,11 @@ public class WorldClient extends AWorldClient
return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
}
public Biome getBiomeGenForCoords(BlockPos pos) {
if(this.isBlockLoaded(pos))
return this.getChunk(pos).getBiome(pos);
else
return Biome.DEF_BIOME;
protected float getTemperature(BlockPos pos) {
if(!this.isBlockLoaded(pos))
return 0.0f;
ChunkClient chunk = this.getChunk(pos);
return pos.getY() > 64 ? chunk.getTemperature(pos) - (chunk.getOffset(pos) + (float)pos.getY() - 64.0F) / 15.0f : chunk.getTemperature(pos);
}
protected boolean isLoaded(int x, int z, boolean allowEmpty) {
@ -769,24 +768,14 @@ public class WorldClient extends AWorldClient
public Vec3 getSkyColor(Entity entity, float partial) {
BlockPos pos = new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
ExtMath.floord(entity.posZ));
Biome biome = this.getBiomeGenForCoords(pos);
Vec3 vec;
if(this.dimension.isExterminated())
vec = new Vec3(0x101010);
else
vec = new Vec3(this.dimension.getSkyColor());
if(this.dimension.hasDaylight()) {
float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F,
0.0F, 1.0F);
if(this.dimension.getSkyColor() == 0xffffffff) {
float temp = ExtMath.clampf(((biome.getTemperature(pos) + 14.0f) / 40.0f + 0.15f) / 3.0F,
-1.0F, 1.0F);
Vec3 sky = new Vec3(hsvToRGB(0.62222224F - temp * 0.05F, 0.5F + temp * 0.1F, 1.0F));
vec = new Vec3(vec.xCoord * sky.xCoord * mult, vec.yCoord * sky.yCoord * mult, vec.zCoord * sky.zCoord * mult);
}
else {
vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult);
}
float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult);
}
float r = (float)vec.xCoord;
float g = (float)vec.yCoord;