mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Finish support for 10 bit blocks
This commit is contained in:
parent
b37da6a576
commit
b04ff7333c
@ -101,7 +101,7 @@ namespace ClassicalSharp {
|
||||
public const int CpeCount = MaxCpeBlock + 1;
|
||||
|
||||
#if USE16_BIT
|
||||
public const BlockID MaxDefinedBlock = 0xFFF;
|
||||
public const BlockID MaxDefinedBlock = 0x3FF;
|
||||
#else
|
||||
public const BlockID MaxDefinedBlock = 0xFF;
|
||||
#endif
|
||||
|
@ -100,7 +100,7 @@ namespace ClassicalSharp {
|
||||
/// should be drawn with the neighbour 'other' present on the other side of the face. </summary>
|
||||
public static bool IsFaceHidden(BlockID block, BlockID other, int tileSide) {
|
||||
#if USE16_BIT
|
||||
return (hidden[(block << 12) | other] & (1 << tileSide)) != 0;
|
||||
return (hidden[(block << 10) | other] & (1 << tileSide)) != 0;
|
||||
#else
|
||||
return (hidden[(block << 8) | other] & (1 << tileSide)) != 0;
|
||||
#endif
|
||||
|
@ -107,7 +107,7 @@ namespace ClassicalSharp {
|
||||
|
||||
BlockID DefaultMapping(int i) {
|
||||
#if USE16_BIT
|
||||
if ((i >= Block.CpeCount && i < 256) || i == Block.Air) return Block.Air;
|
||||
if ((i >= Block.CpeCount) || i == Block.Air) return Block.Air;
|
||||
#else
|
||||
if (i >= Block.CpeCount || i == Block.Air) return Block.Air;
|
||||
#endif
|
||||
|
@ -18,9 +18,13 @@ namespace ClassicalSharp.Physics {
|
||||
|
||||
public State(int x, int y, int z, BlockID block, float tSquared) {
|
||||
X = x << 3; Y = y << 3; Z = z << 3;
|
||||
X |= (block & 0x07);
|
||||
Y |= (block & 0x38) >> 3;
|
||||
Z |= (block & 0xC0) >> 6;
|
||||
X |= (block & 0x007);
|
||||
Y |= (block & 0x038) >> 3;
|
||||
#if !USE16_BIT
|
||||
Z |= (block & 0x0C0) >> 6;
|
||||
#else
|
||||
Z |= (block & 0x1C0) >> 6;
|
||||
#endif
|
||||
this.tSquared = tSquared;
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ namespace ClassicalSharp {
|
||||
X = x; Y = y; Z = z;
|
||||
fullBright = BlockInfo.FullBright[b];
|
||||
#if USE16_BIT
|
||||
int tileIdx = b << 12;
|
||||
int tileIdx = b << 10;
|
||||
#else
|
||||
int tileIdx = b << 8;
|
||||
#endif
|
||||
|
@ -120,6 +120,9 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
if (mapSizeIndex == 4) {
|
||||
if (map == null) {
|
||||
int size = mapSize[0] << 24 | mapSize[1] << 16 | mapSize[2] << 8 | mapSize[3];
|
||||
#if USE16_BIT
|
||||
if (reader.ExtendedBlocks) size *= 2;
|
||||
#endif
|
||||
map = new byte[size];
|
||||
}
|
||||
mapIndex += gzipStream.Read(map, mapIndex, map.Length - mapIndex);
|
||||
@ -131,6 +134,14 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
game.WorldEvents.RaiseMapLoading(progress);
|
||||
}
|
||||
|
||||
#if USE16_BIT
|
||||
static ushort[] UInt8sToUInt16s(byte[] src) {
|
||||
ushort[] dst = new ushort[src.Length / 2];
|
||||
Buffer.BlockCopy(src, 0, dst, 0, src.Length);
|
||||
return dst;
|
||||
}
|
||||
#endif
|
||||
|
||||
void HandleLevelFinalise() {
|
||||
game.Gui.SetNewScreen(null);
|
||||
game.Gui.activeScreen = prevScreen;
|
||||
@ -147,7 +158,11 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
Utils.LogDebug("map loading took: " + loadingMs);
|
||||
|
||||
#if USE16_BIT
|
||||
game.World.SetNewMap(Utils.UInt8sToUInt16s(map), mapWidth, mapHeight, mapLength);
|
||||
if (reader.ExtendedBlocks) {
|
||||
game.World.SetNewMap(UInt8sToUInt16s(map), mapWidth, mapHeight, mapLength);
|
||||
} else{
|
||||
game.World.SetNewMap(Utils.UInt8sToUInt16s(map), mapWidth, mapHeight, mapLength);
|
||||
}
|
||||
#else
|
||||
game.World.SetNewMap(map, mapWidth, mapHeight, mapLength);
|
||||
#endif
|
||||
@ -174,8 +189,8 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
byte id = reader.ReadUInt8();
|
||||
string name = reader.ReadString();
|
||||
string skin = name;
|
||||
net.CheckName(id, ref name, ref skin);
|
||||
net.AddEntity(id, name, skin, true);
|
||||
net.CheckName(id, ref name, ref skin);
|
||||
net.AddEntity(id, name, skin, true);
|
||||
|
||||
if (!net.addEntityHack) return;
|
||||
// Workaround for some servers that declare they support ExtPlayerList,
|
||||
@ -253,7 +268,7 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
}
|
||||
|
||||
internal void ReadAbsoluteLocation(byte id, bool interpolate) {
|
||||
Vector3 P = reader.ReadPosition(id);
|
||||
Vector3 P = reader.ReadPosition(id);
|
||||
float rotY = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
||||
float headX = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
||||
|
||||
@ -267,7 +282,7 @@ namespace ClassicalSharp.Network.Protocols {
|
||||
|
||||
internal void WriteChat(string text, bool partial) {
|
||||
int payload = !net.SupportsPartialMessages ? EntityList.SelfID : (partial ? 1 : 0);
|
||||
writer.WriteUInt8((byte)Opcode.Message);
|
||||
writer.WriteUInt8((byte)Opcode.Message);
|
||||
writer.WriteUInt8((byte)payload);
|
||||
writer.WriteString(text);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user