Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

// Fixes "java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1" in onEntityRemove
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment claims the change fixes Index 1 out of bounds for length 1, but the guard below only handles null or empty arrays. Please update the comment to match the actual condition handled (or adjust the guard so the comment is accurate).

Suggested change
// Fixes "java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1" in onEntityRemove
// Adds safety around onEntityRemove to handle array index issues and null/empty NPC references

Copilot uses AI. Check for mistakes.

@Mixin(SpawnReferenceSystems.MarkerAddRemoveSystem.class)
public abstract class MixinMarkerAddRemoveSystem {

Expand Down Expand Up @@ -92,9 +94,9 @@ public abstract void onEntityRemove(
InvalidatablePersistentRef[] refs = refixes$NPC_REFERENCES.get();
refixes$NPC_REFERENCES.remove();

if (refs == null) {
if (refs == null || refs.length == 0) {
refixes$LOGGER.atWarning().log(
"MarkerAddRemoveSystem#onEntityRemove(): Discarding due to null NPC references (%s)",
"MarkerAddRemoveSystem#onEntityRemove(): Discarding due to null or empty NPC references (%s)",
spawnMarkerComponent.getSpawnMarkerId());
ci.cancel();
Comment on lines +97 to 101
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added guard checks refs.length == 0, but the reported crash is Index 1 out of bounds for length 1, which would still pass this check. If the underlying code can index into position 1, consider discarding/handling the case where refs.length <= 1 (or otherwise ensuring the array is long enough) before continuing.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Copilot is right here. This wouldn't fix the crash

}
Expand Down
Loading