Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Not sure if i'm working forward or backwards on this, but pushing for progress
Dieser Commit ist enthalten in:
Ursprung
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.type.Type;
|
||||
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_9to1_8.storage.ClientChunks;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.type.Type;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||
@ -111,35 +110,63 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||
palette.clear();
|
||||
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = input.readByte();
|
||||
int bitsPerBlock = input.readUnsignedByte();
|
||||
long maxEntryValue = (1L << bitsPerBlock) - 1;
|
||||
|
||||
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
|
||||
int paletteLength = Type.VAR_INT.read(input);
|
||||
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
if (bitsPerBlock != 13) {
|
||||
palette.add(Type.VAR_INT.read(input));
|
||||
} else {
|
||||
Type.VAR_INT.read(input);
|
||||
}
|
||||
}
|
||||
System.out.println("length of palette: " + paletteLength);
|
||||
}
|
||||
|
||||
// Read blocks
|
||||
int blockLength = Type.VAR_INT.read(input);
|
||||
if (blockLength > 0) {
|
||||
long[] blockData = new long[blockLength];
|
||||
System.out.println("Block Length: " + blockData.length);
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
int bitIndex = i * bitsPerBlock;
|
||||
int startIndex = bitIndex / 64;
|
||||
int endIndex = ((i + 1) * bitsPerBlock - 1) / 64;
|
||||
int startBitSubIndex = bitIndex % 64;
|
||||
int val;
|
||||
if (startIndex == endIndex) {
|
||||
blocks[i] = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||
val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||
} else {
|
||||
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.
|
||||
|
@ -13,15 +13,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
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_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 us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
||||
@Override
|
||||
@ -81,7 +76,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
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);
|
||||
// if(rawChunk instanceof Chunk1_9to1_8) {
|
||||
// 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.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 org.bukkit.World;
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren