change biome packet
This commit is contained in:
parent
88c43d0824
commit
ffca1f62e5
7 changed files with 50 additions and 80 deletions
|
@ -159,6 +159,17 @@ public class ChunkServer extends Chunk {
|
|||
return this.biomes;
|
||||
}
|
||||
|
||||
public void setBiomes(byte[] biomes) {
|
||||
if(this.biomes.length != biomes.length) {
|
||||
Log.JNI.warn("Konnte Biome des Chunks nicht setzen, Länge des Arrays ist " + biomes.length + " statt " + this.biomes.length);
|
||||
}
|
||||
else {
|
||||
for(int n = 0; n < this.biomes.length; ++n) {
|
||||
this.biomes[n] = biomes[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getHeights() {
|
||||
return this.height;
|
||||
}
|
||||
|
|
|
@ -1874,15 +1874,18 @@ public final class WorldServer extends AWorldServer {
|
|||
return this.instances.getValueByKey(v) != null;
|
||||
}
|
||||
|
||||
public boolean updateBiomes(int chunkX, int chunkZ) {
|
||||
public void setBiome(BlockPos pos, Biome biome) {
|
||||
ChunkServer chunk = this.getChunk(pos);
|
||||
if(chunk == null || !chunk.isLoaded())
|
||||
return;
|
||||
chunk.getBiomes()[((pos.getZ() & 0xF) << 4 | pos.getX() & 0xF)] = (byte)biome.id;
|
||||
chunk.setModified(true);
|
||||
int chunkX = pos.getX() >> 4;
|
||||
int chunkZ = pos.getZ() >> 4;
|
||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
||||
PlayerInstance ins = this.instances.getValueByKey(v);
|
||||
if(ins == null)
|
||||
return false;
|
||||
ChunkServer chunk = this.getChunk(chunkX, chunkZ);
|
||||
chunk.setModified(true);
|
||||
ins.sendToAllPlayersWatchingChunk(new SPacketBiomes(chunkX, chunkZ, chunk.getBiomes()));
|
||||
return true;
|
||||
if(ins != null)
|
||||
ins.sendToAllPlayersWatchingChunk(new SPacketBiomes(pos, biome));
|
||||
}
|
||||
|
||||
private PlayerInstance getPlayerInstance(int chunkX, int chunkZ, boolean create) {
|
||||
|
@ -2244,50 +2247,7 @@ public final class WorldServer extends AWorldServer {
|
|||
return new ClipboardBlock(state);
|
||||
}
|
||||
}
|
||||
|
||||
// public final EditBlock getLazyBlock(Vector position) {
|
||||
// State state = this.getState(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
|
||||
// return new LazyBlock(state, this, position);
|
||||
// }
|
||||
|
||||
private final boolean setChunkBiome(BlockPos position, Biome biome) {
|
||||
ChunkServer chunk = this.getChunk(position);
|
||||
if((chunk != null) && (chunk.isLoaded())) {
|
||||
chunk.getBiomes()[((position.getZ() & 0xF) << 4 | position.getX() & 0xF)] = (byte)biome.id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void setBiomes(BlockPos start, BlockPos end, Biome biome) {
|
||||
Set<ChunkPos> chunks = Sets.newHashSet();
|
||||
for(int x = start.getX(); x <= end.getX(); x++) {
|
||||
for(int z = start.getZ(); z <= end.getZ(); z++) {
|
||||
if(this.setChunkBiome(new BlockPos(x, 0, z), biome))
|
||||
chunks.add(new ChunkPos(x >> 4, z >> 4));
|
||||
}
|
||||
}
|
||||
for(ChunkPos pos : chunks) {
|
||||
this.updateBiomes(pos.x, pos.z);
|
||||
}
|
||||
chunks.clear();
|
||||
}
|
||||
|
||||
public final void setBiome(BlockPos pos, Biome biome) {
|
||||
if(this.setChunkBiome(pos, biome))
|
||||
this.updateBiomes(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
}
|
||||
|
||||
// public final List<? extends Entity> getEntities(EditRegion region) {
|
||||
// List<Entity> entities = Lists.newArrayList();
|
||||
// for(Entity entity : this.entities) {
|
||||
// if(region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) {
|
||||
// entities.add(entity);
|
||||
// }
|
||||
// }
|
||||
// return entities;
|
||||
// }
|
||||
|
||||
public final List<? extends Entity> getEntities() {
|
||||
List<Entity> entities = Lists.newArrayList();
|
||||
for(Entity entity : this.entities) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue