mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 20:16:02 +01:00
Not sure if i'm working forward or backwards on this, but pushing for progress
This commit is contained in:
parent
20bbe7cec6
commit
598d0f96d8
@ -8,8 +8,7 @@ import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
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 us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.sotrage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChunkSection1_9_1_2 implements ChunkSection {
|
public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||||
@ -111,35 +110,63 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
|||||||
palette.clear();
|
palette.clear();
|
||||||
|
|
||||||
// Reaad bits per block
|
// Reaad bits per block
|
||||||
int bitsPerBlock = input.readByte();
|
int bitsPerBlock = input.readUnsignedByte();
|
||||||
long maxEntryValue = (1L << bitsPerBlock) - 1;
|
long maxEntryValue = (1L << bitsPerBlock) - 1;
|
||||||
|
|
||||||
if (bitsPerBlock == 0) {
|
if (bitsPerBlock == 0) {
|
||||||
throw new RuntimeException("Aye me m8 its the global palette!");
|
bitsPerBlock = 13;
|
||||||
}
|
}
|
||||||
|
if (bitsPerBlock < 4) {
|
||||||
|
bitsPerBlock = 4;
|
||||||
|
}
|
||||||
|
if (bitsPerBlock > 8) {
|
||||||
|
bitsPerBlock = 13;
|
||||||
|
}
|
||||||
|
System.out.println("bps: " + bitsPerBlock);
|
||||||
|
if(bitsPerBlock != 13) {
|
||||||
// Read palette
|
// Read palette
|
||||||
int paletteLength = Type.VAR_INT.read(input);
|
int paletteLength = Type.VAR_INT.read(input);
|
||||||
|
|
||||||
for (int i = 0; i < paletteLength; i++) {
|
for (int i = 0; i < paletteLength; i++) {
|
||||||
|
if (bitsPerBlock != 13) {
|
||||||
palette.add(Type.VAR_INT.read(input));
|
palette.add(Type.VAR_INT.read(input));
|
||||||
|
} else {
|
||||||
|
Type.VAR_INT.read(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("length of palette: " + paletteLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read blocks
|
// Read blocks
|
||||||
int blockLength = Type.VAR_INT.read(input);
|
int blockLength = Type.VAR_INT.read(input);
|
||||||
|
if (blockLength > 0) {
|
||||||
long[] blockData = new long[blockLength];
|
long[] blockData = new long[blockLength];
|
||||||
|
System.out.println("Block Length: " + blockData.length);
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
int bitIndex = i * bitsPerBlock;
|
int bitIndex = i * bitsPerBlock;
|
||||||
int startIndex = bitIndex / 64;
|
int startIndex = bitIndex / 64;
|
||||||
int endIndex = ((i + 1) * bitsPerBlock - 1) / 64;
|
int endIndex = ((i + 1) * bitsPerBlock - 1) / 64;
|
||||||
int startBitSubIndex = bitIndex % 64;
|
int startBitSubIndex = bitIndex % 64;
|
||||||
|
int val;
|
||||||
if (startIndex == endIndex) {
|
if (startIndex == endIndex) {
|
||||||
blocks[i] = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
|
val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||||
} else {
|
} else {
|
||||||
int endBitSubIndex = 64 - startBitSubIndex;
|
int endBitSubIndex = 64 - startBitSubIndex;
|
||||||
blocks[i] = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue);
|
val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitsPerBlock == 13) {
|
||||||
|
int type = val >> 4;
|
||||||
|
int data = val & 0xF;
|
||||||
|
|
||||||
|
setBlock(i, type, data);
|
||||||
|
} else {
|
||||||
|
blocks[i] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("done");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read block light from buffer.
|
* Read block light from buffer.
|
||||||
|
@ -13,15 +13,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.sotrage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.Chunk1_9to1_8;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.ChunkSection1_9to1_8;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.ChunkType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
||||||
@Override
|
@Override
|
||||||
@ -81,7 +76,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
|||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
|
||||||
Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld);
|
Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld);
|
||||||
if (wrapper.isReadable(type, 0)) {
|
// if (wrapper.isReadable(type, 0)) {
|
||||||
Chunk chunk = wrapper.read(type);
|
Chunk chunk = wrapper.read(type);
|
||||||
// if(rawChunk instanceof Chunk1_9to1_8) {
|
// if(rawChunk instanceof Chunk1_9to1_8) {
|
||||||
// throw new RuntimeException("Sweet berry candies");
|
// throw new RuntimeException("Sweet berry candies");
|
||||||
@ -108,7 +103,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
|||||||
wrapper.write(type, chunk);
|
wrapper.write(type, chunk);
|
||||||
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0]));
|
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0]));
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.sotrage;
|
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
Loading…
Reference in New Issue
Block a user