Fix biome sending

This commit is contained in:
Jesse Boyd
2019-11-14 19:21:28 +00:00
parent b38ff03ca6
commit 601890fe64
8 changed files with 80 additions and 26 deletions

View File

@ -57,6 +57,9 @@ public interface IBlocks extends Trimable {
BlockRegistry registry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry();
FastByteArrayOutputStream sectionByteArray = new FastByteArrayOutputStream(buffer);
FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray);
System.out.println("Bitmask " + getBitMask());
try {
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
if (!this.hasSection(layer)) continue;
@ -136,9 +139,15 @@ public interface IBlocks extends Trimable {
// }
// }
if (writeBiomes) {
for (int i = 0; i < 256; i++) {
// TODO biomes
sectionWriter.writeInt(0);
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
BiomeType biome = getBiomeType(x, z);
if (biome != null) {
sectionWriter.writeInt(biome.getLegacyId());
} else {
sectionWriter.writeInt(0);
}
}
}
}
} catch (IOException e) {

View File

@ -38,6 +38,10 @@ public interface IChunkSet extends IBlocks, OutputExtent {
BiomeType[] getBiomes();
default boolean hasBiomes() {
return getBiomes() != null;
}
@Override
BiomeType getBiomeType(int x, int z);

View File

@ -170,6 +170,11 @@ public interface IDelegateChunk<U extends IQueueChunk> extends IQueueChunk {
return getParent().getBiomes();
}
@Override
default boolean hasBiomes() {
return getParent().hasBiomes();
}
default <T extends IChunk> T findParent(Class<T> clazz) {
IChunk root = getParent();
if (clazz.isAssignableFrom(root.getClass())) {

View File

@ -46,6 +46,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public BiomeType getBiomeType(int x, int z) {
if (biomes == null) return null;
return biomes[(z << 4) | x];
}

View File

@ -26,7 +26,7 @@ public class ChunkSendProcessor implements IBatchProcessor {
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
boolean replaceAll = set.getBiomeType(0, 0) != null;
boolean replaceAll = set.hasBiomes();
ChunkPacket packet = new ChunkPacket(chunkX, chunkZ, () -> set, replaceAll);
Stream<Player> stream = this.players.get();
if (stream == null) {

View File

@ -219,7 +219,7 @@ public final class BiomeTypes {
ERODED_BADLANDS.setLegacyId(165);
MODIFIED_WOODED_BADLANDS_PLATEAU.setLegacyId(166);
MODIFIED_BADLANDS_PLATEAU.setLegacyId(167);
// BAMBOO_JUNGLE.setLegacyId(168);
// BAMBOO_JUNGLE_HILLS.setLegacyId(169);
BAMBOO_JUNGLE.setLegacyId(168);
BAMBOO_JUNGLE_HILLS.setLegacyId(169);
}
}