Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
This works but lags, only for 1.8 server.
Dieser Commit ist enthalten in:
Ursprung
9dad0a0d5e
Commit
b743589d77
@ -14,7 +14,8 @@ public class Chunk1_9_1_2 implements Chunk {
|
||||
private int z;
|
||||
private boolean groundUp;
|
||||
private int bitmask;
|
||||
private byte[] sections;
|
||||
private final ChunkSection1_9_1_2[] sections;
|
||||
private final byte[] biomeData;
|
||||
List<CompoundTag> blockEntities;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
@ -23,15 +24,39 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
int size = Type.VAR_INT.read(input);
|
||||
|
||||
byte[] sections = new byte[size];
|
||||
input.readBytes(sections);
|
||||
// byte[] sections = new byte[size];
|
||||
// input.readBytes(sections);
|
||||
|
||||
BitSet usedSections = new BitSet(16);
|
||||
ChunkSection1_9_1_2[] sections = new ChunkSection1_9_1_2[16];
|
||||
byte[] biomeData = null;
|
||||
|
||||
// Calculate section count from bitmask
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((primaryBitmask & (1 << i)) != 0) {
|
||||
usedSections.set(i);
|
||||
}
|
||||
}
|
||||
int sectionCount = usedSections.cardinality(); // the amount of sections set
|
||||
// Read sections
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (!usedSections.get(i)) continue; // Section not set
|
||||
ChunkSection1_9_1_2 section = new ChunkSection1_9_1_2();
|
||||
sections[i] = section;
|
||||
|
||||
short bitsPerBlock = input.readUnsignedByte();
|
||||
Integer[] palette = Type.VAR_INT_ARRAY.read(input); // 0 if none
|
||||
// Read blocks
|
||||
Long[] data = Type.LONG_ARRAY.read(input);
|
||||
|
||||
}
|
||||
|
||||
int blockEntities = Type.VAR_INT.read(input);
|
||||
List<CompoundTag> nbtData = new ArrayList<>();
|
||||
for (int i = 0; i < blockEntities; i++) {
|
||||
nbtData.add(Type.NBT.read(input));
|
||||
}
|
||||
return new Chunk1_9_1_2(chunkX, chunkZ, groundUp, primaryBitmask, sections, nbtData);
|
||||
return new Chunk1_9_1_2(chunkX, chunkZ, groundUp, primaryBitmask, sections, new byte[0], nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,7 +72,7 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
Type.VAR_INT.write(buffer, chunk.getBitmask());
|
||||
|
||||
Type.VAR_INT.write(buffer, chunk.getSections().length);
|
||||
buffer.writeBytes(chunk.getSections());
|
||||
// buffer.writeBytes(chunk.getSections());
|
||||
|
||||
// no block entities as it's earlier
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class FakeTileEntity {
|
||||
tag.put(new IntTag("x", x));
|
||||
tag.put(new IntTag("y", y));
|
||||
tag.put(new IntTag("z", z));
|
||||
System.out.println("Found tile entity " + block + " at position " + x + " " + y + " " + z);
|
||||
// System.out.println("Found tile entity " + block + " at position " + x + " " + y + " " + z);
|
||||
return tag;
|
||||
}
|
||||
return null;
|
||||
|
@ -47,7 +47,7 @@ public class ChunkSection1_9to1_8 {
|
||||
|
||||
public int getBlockId(int x, int y, int z){
|
||||
int index = blocks[index(x, y, z)];
|
||||
return palette.indexOf(index) >> 4;
|
||||
return palette.get(index) >> 4;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +97,7 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
|
||||
int mask = blockBuf.get();
|
||||
int type = mask >> 4;
|
||||
int data = mask & 0xF;
|
||||
|
||||
section.setBlock(j, type, data);
|
||||
}
|
||||
}
|
||||
@ -161,8 +162,10 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
|
||||
for (int y = 0; y < 16; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getBlockId(x, y, z);
|
||||
if (FakeTileEntity.hasBlock(block))
|
||||
tags.add(FakeTileEntity.getFromBlock(x * chunk.getX(), y, z * chunk.getZ(), block));
|
||||
if (FakeTileEntity.hasBlock(block)) {
|
||||
// NOT SURE WHY Y AND Z WORK THIS WAY, TODO: WORK OUT WHY THIS IS OR FIX W/E BROKE IT
|
||||
tags.add(FakeTileEntity.getFromBlock(x + (chunk.getX() << 4), z + (i << 4), y + (chunk.getZ() << 4), block));
|
||||
}
|
||||
}
|
||||
|
||||
if (!section.hasSkyLight()) continue; // No sky light, we're done here.
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren