fix: correct global state indexing in block shape processing

- Adjusted the indexing logic in BlockShapes.cs to ensure proper mapping of state counts to shape IDs.
- Introduced a global state offset to accurately reference shape IDs in the list, preventing out-of-bounds errors during shape assignment.

These changes enhance the reliability of block shape processing in the physics engine.
This commit is contained in:
BruceChen 2026-03-22 15:49:14 +08:00
parent 38e86eb209
commit 3afbae4f89

View file

@ -173,6 +173,7 @@ namespace MinecraftClient.Physics
if (!prismarineBlocks.TryGetValue(snakeName, out var blockShapeData))
continue;
int globalStateOffset = 0;
foreach (var (start, end) in kvp.Value)
{
int stateCount = end - start + 1;
@ -185,12 +186,13 @@ namespace MinecraftClient.Physics
}
else if (blockShapeData is List<int> shapeIdList)
{
for (int i = 0; i < stateCount && i < shapeIdList.Count; i++)
for (int i = 0; i < stateCount && (globalStateOffset + i) < shapeIdList.Count; i++)
{
int shapeId = shapeIdList[i];
int shapeId = shapeIdList[globalStateOffset + i];
stateToShape[start + i] = prismarineShapes.GetValueOrDefault(shapeId, EmptyArray);
}
}
globalStateOffset += stateCount;
}
}