add dummy display chunks
This commit is contained in:
parent
e145675525
commit
31dd9d6303
9 changed files with 147 additions and 68 deletions
|
@ -1799,7 +1799,8 @@ public class Client implements IThreadListener {
|
|||
) + "\n" +
|
||||
String.format("Letzte Zeitsynch.: + %d.%d s",
|
||||
ticked / 1000L, (ticked / 100L) % 10L
|
||||
) +
|
||||
) + "\n" +
|
||||
"Startwert: " + this.world.dimension.getSeed() +
|
||||
(this.serverInfo != null ? "\n" + this.serverInfo : "")
|
||||
// IWorldServer world = this.server.getWorld(this.theWorld.dimension.getDimensionId());
|
||||
// if(world != null)
|
||||
|
|
|
@ -722,6 +722,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
this.gameController.player.prevY = this.gameController.player.posY;
|
||||
this.gameController.player.prevZ = this.gameController.player.posZ;
|
||||
this.doneLoadingTerrain = true;
|
||||
this.clientWorldController.markReload();
|
||||
// this.gameController.displayGuiScreen(null);
|
||||
// if(this.travelSound) {
|
||||
// this.gameController.getSoundManager().playSound(new PositionedSound(SoundEvent.TELEPORT));
|
||||
|
|
|
@ -3,40 +3,40 @@ package client.world;
|
|||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import common.biome.Biome;
|
||||
import common.block.Block;
|
||||
import common.entity.Entity;
|
||||
import common.init.Blocks;
|
||||
import common.log.Log;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.world.Chunk;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.worldgen.BiomeGenerator;
|
||||
|
||||
public class EmptyChunk extends Chunk {
|
||||
private final int liquidY;
|
||||
private final State liquid;
|
||||
private final Block liquidBlock;
|
||||
private final int liquidMeta;
|
||||
|
||||
public EmptyChunk(WorldClient world) {
|
||||
super(world, 0, 0);
|
||||
this.liquidY = world.dimension.getSeaLevel() - 1;
|
||||
this.liquid = world.dimension.getLiquid();
|
||||
this.liquidBlock = this.liquid.getBlock();
|
||||
this.liquidMeta = this.liquidBlock.getMetaFromState(this.liquid);
|
||||
Log.SYSTEM.info("See: %d", this.liquidY);
|
||||
}
|
||||
|
||||
public int getHeight(int x, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void genHeights() {
|
||||
}
|
||||
|
||||
public void genSkyLight() {
|
||||
return this.liquidY;
|
||||
}
|
||||
|
||||
public Block getBlock(BlockPos pos) {
|
||||
return Blocks.air;
|
||||
}
|
||||
|
||||
public int getOpacity(BlockPos pos) {
|
||||
return 255;
|
||||
}
|
||||
|
||||
public int getMeta(BlockPos pos) {
|
||||
return 0;
|
||||
return pos.getY() < this.liquidY ? Blocks.bedrock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air);
|
||||
}
|
||||
|
||||
public int getLight(LightType type, BlockPos pos) {
|
||||
|
@ -57,28 +57,19 @@ public class EmptyChunk extends Chunk {
|
|||
}
|
||||
|
||||
public boolean canSeeSky(BlockPos pos) {
|
||||
return false;
|
||||
return pos.getY() > this.liquidY;
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addTileEntity(TileEntity tile) {
|
||||
}
|
||||
|
||||
public void addTileEntity(BlockPos pos, TileEntity tile) {
|
||||
}
|
||||
|
||||
public void removeTileEntity(BlockPos pos) {
|
||||
}
|
||||
|
||||
public void onChunkLoad() {
|
||||
}
|
||||
|
||||
public void onChunkUnload() {
|
||||
}
|
||||
|
||||
public void setModified() {
|
||||
}
|
||||
|
||||
|
@ -88,15 +79,63 @@ public class EmptyChunk extends Chunk {
|
|||
public <T extends Entity> void getEntities(Class<? extends T> clazz, BoundingBox bb, List<T> list, Predicate<? super T> pred) {
|
||||
}
|
||||
|
||||
public boolean isDirty(long time) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
public boolean isDummy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty(int bottom, int top) {
|
||||
return top < 0 || bottom > this.liquidY;
|
||||
}
|
||||
|
||||
public State getState(BlockPos pos) {
|
||||
return pos.getY() < this.liquidY ? Blocks.bedrock.getState() : (pos.getY() == this.liquidY ? this.liquid : Blocks.air.getState());
|
||||
}
|
||||
|
||||
public State setState(BlockPos pos, State state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlockPos getPrecipitation(BlockPos pos) {
|
||||
return new BlockPos(pos.getX(), this.liquidY + 1, pos.getZ());
|
||||
}
|
||||
|
||||
public void update(boolean noGaps) {
|
||||
}
|
||||
|
||||
public void onChunkUnload() {
|
||||
}
|
||||
|
||||
public boolean isPopulated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setData(byte[] data, int update, boolean biomes) {
|
||||
}
|
||||
|
||||
public Biome getBiome(BlockPos pos, BiomeGenerator gen) {
|
||||
return Biome.DEF_BIOME;
|
||||
}
|
||||
|
||||
public void setBiomes(byte[] biomes) {
|
||||
}
|
||||
|
||||
public void resetRelight() {
|
||||
}
|
||||
|
||||
public void enqueueRelight() {
|
||||
}
|
||||
|
||||
public void checkLight() {
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLoaded(boolean loaded) {
|
||||
}
|
||||
|
||||
public int getLowest() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,9 @@ public class WorldClient extends AWorldClient
|
|||
private final Set<ChunkPos> previousActive = Sets.<ChunkPos>newHashSet();
|
||||
private final LongHashMap<Chunk> chunkMapping = new LongHashMap();
|
||||
private final List<Chunk> chunkListing = Lists.<Chunk>newArrayList();
|
||||
private final Chunk blankChunk = new EmptyChunk(this);
|
||||
private final Set<ChunkPos> emptyChunkListing = Sets.<ChunkPos>newHashSet();
|
||||
private final Set<ChunkPos> nextEmptyChunkListing = Sets.<ChunkPos>newHashSet();
|
||||
private final Chunk emptyChunk = new EmptyChunk(this);
|
||||
// public final Profiler profiler;
|
||||
protected int lastLightning;
|
||||
protected Vec3 lightColor = new Vec3(0xffffff);
|
||||
|
@ -63,8 +65,41 @@ public class WorldClient extends AWorldClient
|
|||
// this.setDifficulty(this.gm.difficulty);
|
||||
}
|
||||
|
||||
private void markReload(int cx, int cz, int range) {
|
||||
this.nextEmptyChunkListing.clear();
|
||||
for(int x = cx - range; x <= cx + range; x++) {
|
||||
for(int z = cz - range; z <= cz + range; z++) {
|
||||
long id = LongHashMap.packInt(x, z);
|
||||
ChunkPos pos = new ChunkPos(x, z);
|
||||
if(this.chunkMapping.getValueByKey(id) != null) {
|
||||
if(this.emptyChunkListing.contains(pos)) {
|
||||
this.emptyChunkListing.remove(pos);
|
||||
this.nextEmptyChunkListing.add(pos);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
this.chunkMapping.add(id, this.emptyChunk);
|
||||
this.emptyChunkListing.remove(pos);
|
||||
this.nextEmptyChunkListing.add(pos);
|
||||
this.markBlockRangeForRenderUpdate(x << 4, 0, z << 4, (x << 4) + 15, 512, (z << 4) + 15);
|
||||
}
|
||||
}
|
||||
for(ChunkPos pos : this.emptyChunkListing) {
|
||||
this.chunkMapping.remove(LongHashMap.packInt(pos.x, pos.z));
|
||||
this.markBlockRangeForRenderUpdate(pos.x << 4, 0, pos.z << 4, (pos.x << 4) + 15, 512, (pos.z << 4) + 15);
|
||||
}
|
||||
this.emptyChunkListing.clear();
|
||||
this.emptyChunkListing.addAll(this.nextEmptyChunkListing);
|
||||
}
|
||||
|
||||
public void markReload() {
|
||||
if(this.gm.player != null && !this.gm.charEditor)
|
||||
this.markReload((int)this.gm.player.posX >> 4, (int)this.gm.player.posZ >> 4, this.gm.renderDistance + 4);
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
this.markReload();
|
||||
// this.info.tick();
|
||||
|
||||
if (this.gm.dayCycle)
|
||||
|
@ -127,24 +162,23 @@ public class WorldClient extends AWorldClient
|
|||
|
||||
public void doPreChunk(int x, int z, boolean load)
|
||||
{
|
||||
long id = LongHashMap.packInt(x, z);
|
||||
if (load)
|
||||
{
|
||||
if(this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z)) != null)
|
||||
if(this.chunkMapping.getValueByKey(id) != null)
|
||||
this.doPreChunk(x, z, false);
|
||||
Chunk chunk = new Chunk(this, x, z);
|
||||
this.chunkMapping.add(LongHashMap.packInt(x, z), chunk);
|
||||
this.chunkMapping.add(id, chunk);
|
||||
this.chunkListing.add(chunk);
|
||||
chunk.setLoaded(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Chunk chunk = this.getChunk(x, z);
|
||||
if (!chunk.isEmpty())
|
||||
{
|
||||
chunk.onChunkUnload();
|
||||
}
|
||||
this.chunkMapping.remove(LongHashMap.packInt(x, z));
|
||||
chunk.onChunkUnload();
|
||||
this.chunkMapping.remove(id);
|
||||
this.chunkListing.remove(chunk);
|
||||
this.emptyChunkListing.remove(new ChunkPos(x, z));
|
||||
}
|
||||
|
||||
if (!load)
|
||||
|
@ -354,7 +388,7 @@ public class WorldClient extends AWorldClient
|
|||
public Chunk getChunk(int x, int z)
|
||||
{
|
||||
Chunk chunk = this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z));
|
||||
return chunk == null ? this.blankChunk : chunk;
|
||||
return chunk == null ? this.emptyChunk : chunk;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue