make world taller

This commit is contained in:
Sen 2025-05-20 19:06:37 +02:00
parent 3a5a29cf9e
commit caef42dc16
49 changed files with 489 additions and 291 deletions

View file

@ -41,8 +41,6 @@ public class ClipboardPlacer {
}
public void setBlock(BlockPos location, ClipboardBlock block) {
if(location.getY() < 0 || location.getY() > 511)
return;
Block type = block.getState().getBlock();
if (ReorderRegistry.shouldPlaceLast(type)) {
// Place torches, etc. last

View file

@ -74,7 +74,7 @@ public abstract class Command implements Executable {
}
},
new DoubleParser("x", defaulted ? DefType.X : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered),
new DoubleParser("y", defaulted ? DefType.Y : null, 0.0, (double)World.HEIGHT, false),
new DoubleParser("y", defaulted ? DefType.Y : null, (double)(-World.MAX_SIZE_Y), (double)World.MAX_SIZE_Y, false),
new DoubleParser("z", defaulted ? DefType.Z : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered));
}

View file

@ -970,7 +970,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
if (chunk.isPopulated())
{
list.add(chunk);
list1.addAll(((WorldServer)this.entity.worldObj).getTileEntitiesIn(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 512, chunkcoordintpair.z * 16 + 16));
list1.addAll(((WorldServer)this.entity.worldObj).getTileEntitiesIn(chunkcoordintpair.x * 16, -World.MAX_SIZE_Y, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, World.MAX_SIZE_Y, chunkcoordintpair.z * 16 + 16));
iterator1.remove();
}
}
@ -985,7 +985,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
{
if (list.size() == 1)
{
this.sendPacket(new SPacketChunkData((Chunk)list.get(0), true, 0xffffffff));
this.sendPacket(new SPacketChunkData((Chunk)list.get(0), true, 0xffffffff, null));
}
else
{
@ -2098,7 +2098,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
float f1 = this.entity.rotYaw;
float f2 = this.entity.rotPitch;
if (packetIn.isMoving() && packetIn.getPositionY() == -999.0D)
if (packetIn.isMoving() && packetIn.getPositionY() == -99999999.0D)
{
packetIn.setMoving(false);
}
@ -2281,7 +2281,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
{
return;
}
else if (blockpos.getY() >= World.HEIGHT)
else if (blockpos.getY() >= World.MAX_SIZE_Y)
{
return;
}
@ -2345,7 +2345,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
this.tryUseItem(itemstack);
// }
}
else if (blockpos.getY() < World.HEIGHT - 1 || enumfacing != Facing.UP && blockpos.getY() < World.HEIGHT)
else if (blockpos.getY() < World.MAX_SIZE_Y - 1 || enumfacing != Facing.UP && blockpos.getY() < World.MAX_SIZE_Y)
{
double max = this.entity.getReachDistance() + 3.0D;
max *= max;

View file

@ -376,12 +376,22 @@ public class Region {
chunk.setInhabited(tag.getLong("InhabitedTime"));
NBTTagList sects = tag.getTagList("Sections", 10);
int stor = 32;
int min = 0;
int max = stor - 1;
for(int n = 0; n < sects.tagCount(); ++n) {
NBTTagCompound sect = sects.getCompoundTagAt(n);
int y = sect.getInteger("Y");
min = y < min ? y : min;
max = y > max ? y : max;
}
BlockArray[] sections = new BlockArray[stor];
BlockArray[] down = min < 0 ? new BlockArray[-min] : null;
BlockArray[] up = max >= stor ? new BlockArray[1 + max - stor] : null;
boolean light = !world.dimension.hasNoLight();
for(int n = 0; n < sects.tagCount(); ++n) {
NBTTagCompound sect = sects.getCompoundTagAt(n);
int y = sect.getByte("Y");
int y = sect.getInteger("Y");
BlockArray storage = new BlockArray(y << 4, light);
byte[] blocks = sect.getByteArray("Blocks");
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
@ -404,10 +414,15 @@ public class Region {
}
storage.update();
sections[y] = storage;
if(y >= 0 && y < stor)
sections[y] = storage;
else if(y < 0)
down[-down.length - y] = storage;
else
up[y - stor] = storage;
}
chunk.setStorage(sections);
chunk.setStorage(sections, down, up);
if(tag.hasKey("Biomes", 7)) {
chunk.setBiomes(tag.getByteArray("Biomes"));
@ -495,52 +510,58 @@ public class Region {
tag.setBoolean("LightPopulated", chunk.isLightPopulated());
tag.setLong("InhabitedTime", chunk.getInhabited());
BlockArray[] sections = chunk.getStorage();
BlockArray[] down = chunk.getStorage();
BlockArray[] up = chunk.getStorage();
NBTTagList sects = new NBTTagList();
boolean light = !world.dimension.hasNoLight();
for(BlockArray storage : sections) {
if(storage != null) {
NBTTagCompound sect = new NBTTagCompound();
sect.setByte("Y", (byte)(storage.getY() >> 4 & 511));
byte[] blocks = new byte[storage.getData().length];
NibbleArray data = new NibbleArray();
NibbleArray adddata = null;
for(int c = 0; c < storage.getData().length; ++c) {
char cd = storage.getData()[c];
int cx = c & 15;
int cy = c >> 8 & 15;
int cz = c >> 4 & 15;
if(cd >> 12 != 0) {
if(adddata == null) {
adddata = new NibbleArray();
for(BlockArray[] sec : new BlockArray[][] {sections, down, up}) {
if(sec == null)
continue;
for(BlockArray storage : sec) {
if(storage != null) {
NBTTagCompound sect = new NBTTagCompound();
sect.setInteger("Y", storage.getY() >> 4);
byte[] blocks = new byte[storage.getData().length];
NibbleArray data = new NibbleArray();
NibbleArray adddata = null;
for(int c = 0; c < storage.getData().length; ++c) {
char cd = storage.getData()[c];
int cx = c & 15;
int cy = c >> 8 & 15;
int cz = c >> 4 & 15;
if(cd >> 12 != 0) {
if(adddata == null) {
adddata = new NibbleArray();
}
adddata.set(cx, cy, cz, cd >> 12);
}
adddata.set(cx, cy, cz, cd >> 12);
blocks[c] = (byte)(cd >> 4 & 255);
data.set(cx, cy, cz, cd & 15);
}
blocks[c] = (byte)(cd >> 4 & 255);
data.set(cx, cy, cz, cd & 15);
sect.setByteArray("Blocks", blocks);
sect.setByteArray("Data", data.getData());
if(adddata != null) {
sect.setByteArray("Add", adddata.getData());
}
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
if(light) {
sect.setByteArray("SkyLight", storage.getSkylight().getData());
}
else {
sect.setByteArray("SkyLight", new byte[storage.getBlocklight().getData().length]);
}
sects.appendTag(sect);
}
sect.setByteArray("Blocks", blocks);
sect.setByteArray("Data", data.getData());
if(adddata != null) {
sect.setByteArray("Add", adddata.getData());
}
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
if(light) {
sect.setByteArray("SkyLight", storage.getSkylight().getData());
}
else {
sect.setByteArray("SkyLight", new byte[storage.getBlocklight().getData().length]);
}
sects.appendTag(sect);
}
}

View file

@ -90,13 +90,10 @@ public abstract class Spawner {
Chunk chunk = world.getChunk(coord.x, coord.z);
int x = coord.x * 16 + world.rand.zrange(16);
int z = coord.z * 16 + world.rand.zrange(16);
int h = chunk.getHeight(new BlockPos(x, 0, z)) + 1;
if(h > 0) {
int m = h % 16;
h = m == 0 ? h : h + 16 - m;
}
h = h == 0 ? 16 : (h > 0 ? h : chunk.getTopSegment() + 16 - 1);
int y = world.rand.excl(h <= 8 ? 0 : 8, h);
int h = chunk.getTopSegment();
if(h == Integer.MIN_VALUE)
continue;
int y = world.rand.range(chunk.getBottomSegment(), h + 16);
BlockPos pos = new BlockPos(x, y, z);
Block block = world.getState(pos).getBlock();
if(!block.isNormalCube()) {

View file

@ -741,7 +741,7 @@ public final class WorldServer extends AWorldServer {
private BlockPos adjustPosToNearbyEntity(BlockPos pos) {
BlockPos blockpos = this.getPrecipitationHeight(pos);
BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.HEIGHT, blockpos.getZ()))).expand(3.0D,
BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.MAX_SIZE_Y, blockpos.getZ()))).expand(3.0D,
3.0D, 3.0D);
List<EntityLiving> list = this.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate<EntityLiving>() {
public boolean test(EntityLiving p_apply_1_) {
@ -2369,7 +2369,7 @@ public final class WorldServer extends AWorldServer {
if(!this.canBurnAt(pos)) {
return false;
}
if(pos.getY() >= 0 && pos.getY() < 512) {
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) {
Block block = this.getState(pos).getBlock();
if(block.getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this, pos)) {
@ -2385,7 +2385,7 @@ public final class WorldServer extends AWorldServer {
return false;
}
else {
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y && this.getLightFor(LightType.BLOCK, pos) < 10) {
State iblockstate = this.getState(pos);
Block block = iblockstate.getBlock();
@ -2437,8 +2437,9 @@ public final class WorldServer extends AWorldServer {
Chunk chunk = this.getChunk(pos);
BlockPos blockpos;
BlockPos blockpos1;
int bottom;
for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1) {
for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()), bottom = chunk.getBottomSegment(); blockpos.getY() >= bottom; blockpos = blockpos1) {
blockpos1 = blockpos.down();
Material material = chunk.getBlock(blockpos1).getMaterial();
@ -2802,8 +2803,10 @@ public final class WorldServer extends AWorldServer {
private class PlayerInstance {
private final List<EntityNPC> watching = Lists.<EntityNPC>newArrayList();
private final Set<Integer> extend = Sets.newHashSet();
private final long[] changes = new long[64];
private final ChunkPos position;
private int[] changes = new int[64];
private int updates;
private int sections;
private long prevTime;
@ -2834,7 +2837,7 @@ public final class WorldServer extends AWorldServer {
Chunk chunk = WorldServer.this.getChunk(this.position.x, this.position.z);
if(chunk.isPopulated()) {
player.connection.sendPacket(new SPacketChunkData(chunk, true, 0));
player.connection.sendPacket(new SPacketChunkData(chunk, true, 0, new int[0]));
}
this.watching.remove(player);
@ -2877,10 +2880,13 @@ public final class WorldServer extends AWorldServer {
WorldServer.this.toUpdate.add(this);
}
this.sections |= 1 << (y >> 4);
if(y >= 0 && y >> 4 < 32)
this.sections |= 1 << (y >> 4);
else
this.extend.add(y >> 4);
if(this.updates < 64) {
int pos = x << 13 | z << 9 | y;
long pos = ((long)x & 4294967295L) << 36 | ((long)z & 4294967295L) << 32 | (y & 4294967295L);
for(int i = 0; i < this.updates; ++i) {
if(this.changes[i] == pos) {
@ -2905,9 +2911,9 @@ public final class WorldServer extends AWorldServer {
public void onUpdate() {
if(this.updates != 0) {
if(this.updates == 1) {
int x = (this.changes[0] >> 13 & 15) + this.position.x * 16;
int y = this.changes[0] & 511;
int z = (this.changes[0] >> 9 & 15) + this.position.z * 16;
int x = (int)(this.changes[0] >> 36 & 15L) + this.position.x * 16;
int y = (int)(this.changes[0] & 4294967295L);
int z = (int)(this.changes[0] >> 32 & 15L) + this.position.z * 16;
BlockPos pos = new BlockPos(x, y, z);
this.sendToAllPlayersWatchingChunk(new SPacketBlockChange(WorldServer.this, pos));
@ -2918,11 +2924,36 @@ public final class WorldServer extends AWorldServer {
else if(this.updates == 64) {
int x = this.position.x * 16;
int z = this.position.z * 16;
int[] extend = null;
if(!this.biomes) {
extend = new int[this.extend.size()];
int n = 0;
for(Integer i : this.extend) {
extend[n++] = i;
}
}
this.sendToAllPlayersWatchingChunk(new SPacketChunkData(WorldServer.this.getChunk(this.position.x, this.position.z),
this.biomes, this.sections));
this.biomes, this.sections, extend));
if(this.biomes) {
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, Integer.MIN_VALUE, z, x + 16, Integer.MAX_VALUE, z + 16);
for(int cy = 0; cy < 32; ++cy) {
if((this.sections & 1 << cy) != 0) {
for(int n = 0; n < list.size(); ++n) {
this.sendTileToAllPlayersWatchingChunk(list.get(n));
}
}
else {
for(int cy = 0; cy < 32; ++cy) {
if((this.sections & 1 << cy) != 0) {
int y = cy << 4;
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, y, z, x + 16, y + 16, z + 16);
for(int n = 0; n < list.size(); ++n) {
this.sendTileToAllPlayersWatchingChunk(list.get(n));
}
}
}
for(Integer cy : this.extend) {
int y = cy << 4;
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, y, z, x + 16, y + 16, z + 16);
@ -2937,9 +2968,9 @@ public final class WorldServer extends AWorldServer {
WorldServer.this.getChunk(this.position.x, this.position.z)));
for(int n = 0; n < this.updates; ++n) {
int x = (this.changes[n] >> 13 & 15) + this.position.x * 16;
int y = this.changes[n] & 511;
int z = (this.changes[n] >> 9 & 15) + this.position.z * 16;
int x = (int)(this.changes[n] >> 36 & 15L) + this.position.x * 16;
int y = (int)(this.changes[n] & 4294967295L);
int z = (int)(this.changes[n] >> 32 & 15L) + this.position.z * 16;
BlockPos pos = new BlockPos(x, y, z);
if(WorldServer.this.getState(pos).getBlock().hasTileEntity()) {
@ -2950,6 +2981,7 @@ public final class WorldServer extends AWorldServer {
this.updates = 0;
this.sections = 0;
this.extend.clear();
this.biomes = false;
}
}