2018-10-25 13:56:40 +02:00
|
|
|
package us.myles.ViaVersion.api.type.types.version;
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
|
|
|
import us.myles.ViaVersion.api.type.Type;
|
|
|
|
|
|
|
|
import java.nio.ByteOrder;
|
|
|
|
|
|
|
|
public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
|
|
|
|
2018-11-12 14:36:01 +01:00
|
|
|
public ChunkSectionType1_8() {
|
|
|
|
super("Chunk Section Type", ChunkSection.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChunkSection read(ByteBuf buffer) throws Exception {
|
|
|
|
ChunkSection chunkSection = new ChunkSection();
|
2019-03-02 21:07:23 +01:00
|
|
|
// Don't clear palette because 0 index needs to be air in 1.9 version
|
2018-11-12 14:36:01 +01:00
|
|
|
|
2019-02-10 18:22:34 +01:00
|
|
|
ByteBuf littleEndianView = buffer.order(ByteOrder.LITTLE_ENDIAN);
|
2018-11-12 14:36:01 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < ChunkSection.SIZE; i++) {
|
2019-02-10 18:22:34 +01:00
|
|
|
int mask = littleEndianView.readShort();
|
2018-11-12 14:36:01 +01:00
|
|
|
int type = mask >> 4;
|
|
|
|
int data = mask & 0xF;
|
|
|
|
chunkSection.setBlock(i, type, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return chunkSection;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
2018-10-25 13:56:40 +02:00
|
|
|
}
|