Decode PerformVoxelActions#1
Open
MichalSy wants to merge 5 commits into
Open
Conversation
Owner
|
Thanks for the PR! Here is the structure;
Here is how I've read the data; public static bool Handle(Connection connection, BitStream bitStream)
{
var inOutByteArray = new byte[4];
if (!bitStream.ReadBits(inOutByteArray, 8 - Util.NumBitsRequiredByte(8), true))
return false;
var location = inOutByteArray[0];
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var chunkCoordX = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var chunkCoordY = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var chunkCoordZ = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var voxelCoordX = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var voxelCoordY = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var voxelCoordZ = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 8 - Util.NumBitsRequiredByte(6), true))
return false;
var side = inOutByteArray[0];
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(32), true))
return false;
var power = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(0x10000), true))
return false;
var positionX = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(0x10000), true))
return false;
var positionY = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(0x10000), true))
return false;
var positionZ = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(128), true))
return false;
var directionX = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(128), true))
return false;
var directionY = BitConverter.ToInt32(inOutByteArray, 0);
if (!bitStream.ReadBits(inOutByteArray, 32 - Util.NumBitsRequiredUInt32(128), true))
return false;
var directionZ = BitConverter.ToInt32(inOutByteArray, 0);
Debug.WriteLine($"location: {location}, chunkCoord: {chunkCoordX} {chunkCoordY} {chunkCoordZ}, voxelCoord: {voxelCoordX} {voxelCoordY} {voxelCoordZ}, side: {side}, power: {power}, position: {positionX} {positionY} {positionZ}, direction: {directionX} {directionY} {directionZ}", nameof(PerformVoxelActions));
return true;
} |
EDITzDev
requested changes
Nov 28, 2025
Comment on lines
+55
to
+57
| var bitsToSkip = 8 - Util.NumBitsRequiredByte(maxValue); | ||
|
|
||
| if (!bitStream.ReadBits(buffer, bitsToSkip, alignBitsToRight: true)) |
Owner
There was a problem hiding this comment.
bitsToSkip should be named something like bitsToRead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.