add world size, space around worlds

This commit is contained in:
Sen 2025-07-13 20:34:50 +02:00
parent 629e8aadc5
commit c2dc0e7247
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
22 changed files with 214 additions and 123 deletions

View file

@ -35,7 +35,7 @@ public class CommandLoad extends Command {
star = star == null ? UniverseRegistry.getName(new Random().pick(Lists.newArrayList(UniverseRegistry.getStars()))) : star;
if(!UniverseRegistry.isType(star, DimType.STAR) || UniverseRegistry.isRegistered(name))
return null;
Planet dim = new Planet(sky, fog, clouds, orbit, rotation, offset, gravity, temperature, brightness);
Planet dim = new Planet(sky, fog, clouds, 17000000, orbit, rotation, offset, gravity, temperature, brightness);
dim.setTimeQualifier(3);
return UniverseRegistry.registerCustomPlanet(name, custom, dim, star);
}
@ -59,7 +59,7 @@ public class CommandLoad extends Command {
do {
sname = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
} while(UniverseRegistry.isRegistered(sname.toLowerCase()));
Star star = new Star(0xff0000 | (rand.range(0x60, 0xa0) << 8),
Star star = new Star(0xff0000 | (rand.range(0x60, 0xa0) << 8), rand.range(300000000, 1200000000),
rand.frange(200.0f, 400.0f), rand.frange(5000.0f, 7000.0f),
rand.pick(Blocks.lava.getState(), Blocks.magma.getState()), rand.range(64, 212));
UniverseRegistry.registerCustomGalaxy(galaxy.toLowerCase(), galaxy);

View file

@ -93,6 +93,12 @@ public class ChunkServer extends Chunk {
else
this.genSkyLight();
}
public ChunkServer(World world, Biome biome, int x, int z) {
this(world, x, z);
Arrays.fill(this.biomes, (char)biome.id);
this.genSkyLight();
}
public int getTopSegment() {
return this.top;

View file

@ -165,12 +165,13 @@ public final class WorldServer extends AWorldServer {
private FeatureLiquids[] liquids;
private long seed;
private int height;
private int size;
private int seaLevel;
private boolean mobs;
private boolean snow;
private boolean populate;
private boolean updateForced;
private int updatesForced;
private boolean loadersModified;
private int emptyTicks;
private int blockEvtIdx;
@ -179,10 +180,6 @@ public final class WorldServer extends AWorldServer {
private int updateLCG = this.rand.intv();
private long prevUpdate;
private long time;
public static float clampGravity() {
return ExtMath.clampf(Vars.gravity, -10.0f, 10.0f);
}
public void sendPacket(Packet packet) {
for(Player conn : this.server.getPlayers()) {
@ -348,10 +345,6 @@ public final class WorldServer extends AWorldServer {
this.loadersModified = false;
}
}
public Server getServer() {
return this.server;
}
public void tick() {
this.updatePhysics();
@ -608,7 +601,8 @@ public final class WorldServer extends AWorldServer {
NextTickListEntry nextticklistentry = new NextTickListEntry(pos, blockIn);
int i = 0;
if(this.updateForced && blockIn != Blocks.air) {
if(this.updatesForced > 0 && blockIn != Blocks.air) {
--this.updatesForced;
if(blockIn.requiresUpdates()) {
i = 8;
@ -1358,6 +1352,10 @@ public final class WorldServer extends AWorldServer {
ChunkServer chunk = this.getChunk(x, z);
if(!chunk.isTerrainPopulated()) {
chunk.checkLight();
if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) {
chunk.setModified(true);
return;
}
BlockFalling.fallInstantly = true;
int bx = x * 16;
int bz = z * 16;
@ -1429,6 +1427,8 @@ public final class WorldServer extends AWorldServer {
}
private ChunkServer generate(int x, int z) {
if(x < -this.size || z < -this.size || x >= this.size || z >= this.size)
return new ChunkServer(this, Biome.SPACE, x, z);
this.grng.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer primer = new ChunkPrimer(this.height);
this.generator.generateChunk(this, x, z, primer);
@ -1614,6 +1614,7 @@ public final class WorldServer extends AWorldServer {
this.liquids = exterminated ? null : this.createLiquids();
this.dungeons = exterminated ? null : this.createDungeonGenerator();
this.height = this.generator.getMaximumHeight();
this.size = this.dimension.getSize() / 16;
if(this.villageGen != null) {
TagObject tag = null;
try {
@ -1654,9 +1655,9 @@ public final class WorldServer extends AWorldServer {
}
public void forceBlockUpdateTick(Block blockType, BlockPos pos, Random random) {
this.updateForced = true;
this.updatesForced = 128;
blockType.updateTick(this, pos, this.getState(pos), random);
this.updateForced = false;
this.updatesForced = 0;
}
public Village getNearestVillage(BlockPos doorBlock, int radius) {