From 3afbae4f899111b62b14fede9a92f2ebd3383bbc Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 22 Mar 2026 15:49:14 +0800 Subject: [PATCH] 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. --- MinecraftClient/Physics/BlockShapes.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Physics/BlockShapes.cs b/MinecraftClient/Physics/BlockShapes.cs index 5575644b..2fbe5b27 100644 --- a/MinecraftClient/Physics/BlockShapes.cs +++ b/MinecraftClient/Physics/BlockShapes.cs @@ -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 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; } }