3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Not sure if i'm working forward or backwards on this, but pushing for progress

Dieser Commit ist enthalten in:
Myles 2016-07-01 20:17:25 +01:00
Ursprung 20bbe7cec6
Commit 598d0f96d8
4 geänderte Dateien mit 73 neuen und 52 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -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 {
@ -47,7 +46,7 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
setBlock(index(x, y, z), type, data); setBlock(index(x, y, z), type, data);
} }
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.indexOf(index) >> 4;
} }
@ -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];
for(int i = 0; i < blocks.length; i++) { System.out.println("Block Length: " + blockData.length);
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;
if(startIndex == endIndex) { int val;
blocks[i] = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue); if (startIndex == endIndex) {
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.
@ -161,7 +188,7 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
public void readSkyLight(ByteBuf input) { public void readSkyLight(ByteBuf input) {
byte[] handle = new byte[LIGHT_LENGTH]; byte[] handle = new byte[LIGHT_LENGTH];
input.readBytes(handle); input.readBytes(handle);
if(skyLight != null) { if (skyLight != null) {
skyLight.setHandle(handle); skyLight.setHandle(handle);
return; return;
} }

Datei anzeigen

@ -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]));
} }
} // }
}); });
} }
}); });

Datei anzeigen

@ -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;