3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-04 23:30:24 +01:00

This works but lags, only for 1.8 server.

Dieser Commit ist enthalten in:
Myles 2016-06-22 19:22:38 +01:00
Ursprung 9dad0a0d5e
Commit b743589d77
5 geänderte Dateien mit 38 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -14,7 +14,8 @@ public class Chunk1_9_1_2 implements Chunk {
private int z; private int z;
private boolean groundUp; private boolean groundUp;
private int bitmask; private int bitmask;
private byte[] sections; private final ChunkSection1_9_1_2[] sections;
private final byte[] biomeData;
List<CompoundTag> blockEntities; List<CompoundTag> blockEntities;
} }

Datei anzeigen

@ -7,6 +7,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType; import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.BitSet;
import java.util.List; import java.util.List;
public class Chunk1_9_1_2Type extends BaseChunkType { 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 primaryBitmask = Type.VAR_INT.read(input);
int size = Type.VAR_INT.read(input); int size = Type.VAR_INT.read(input);
byte[] sections = new byte[size]; // byte[] sections = new byte[size];
input.readBytes(sections); // 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); int blockEntities = Type.VAR_INT.read(input);
List<CompoundTag> nbtData = new ArrayList<>(); List<CompoundTag> nbtData = new ArrayList<>();
for (int i = 0; i < blockEntities; i++) { for (int i = 0; i < blockEntities; i++) {
nbtData.add(Type.NBT.read(input)); 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 @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.getBitmask());
Type.VAR_INT.write(buffer, chunk.getSections().length); Type.VAR_INT.write(buffer, chunk.getSections().length);
buffer.writeBytes(chunk.getSections()); // buffer.writeBytes(chunk.getSections());
// no block entities as it's earlier // no block entities as it's earlier
} }

Datei anzeigen

@ -104,7 +104,7 @@ public class FakeTileEntity {
tag.put(new IntTag("x", x)); tag.put(new IntTag("x", x));
tag.put(new IntTag("y", y)); tag.put(new IntTag("y", y));
tag.put(new IntTag("z", z)); 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 tag;
} }
return null; return null;

Datei anzeigen

@ -47,7 +47,7 @@ public class ChunkSection1_9to1_8 {
public int getBlockId(int x, int y, int z){ public int getBlockId(int x, int y, int z){
int index = blocks[index(x, y, z)]; int index = blocks[index(x, y, z)];
return palette.indexOf(index) >> 4; return palette.get(index) >> 4;
} }
/** /**

Datei anzeigen

@ -97,6 +97,7 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
int mask = blockBuf.get(); int mask = blockBuf.get();
int type = mask >> 4; int type = mask >> 4;
int data = mask & 0xF; int data = mask & 0xF;
section.setBlock(j, type, data); 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 y = 0; y < 16; y++)
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
int block = section.getBlockId(x, y, z); int block = section.getBlockId(x, y, z);
if (FakeTileEntity.hasBlock(block)) if (FakeTileEntity.hasBlock(block)) {
tags.add(FakeTileEntity.getFromBlock(x * chunk.getX(), y, z * chunk.getZ(), 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. if (!section.hasSkyLight()) continue; // No sky light, we're done here.