From 05389d595439fa87c77d516016916fdbab9d60c3 Mon Sep 17 00:00:00 2001 From: Lazzexus Date: Mon, 12 Oct 2026 16:36:12 +0200 Subject: [PATCH] Filter resource entities by prototype type, not collision layer Caught by another in-game crash: "Entity is not resource." when reading entity.amount. The previous fix (collision_mask: "resource") was still wrong - collision layers and entity type are decoupled in Factorio 2.0, so find_entities_filtered({collision_mask: "resource"}) can return non-resource entities that merely opted into the same collision layer (likely something from Space Exploration or Krastorio 2). entity.amount/initial_amount only exist on entities whose prototype type is actually "resource". Filtering by type: "resource" directly targets the right entities and is simpler than inferring it via collision mask in the first place. Co-Authored-By: Claude Sonnet 5 --- .../typescript/main/events/handlers/EntityUpdateHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts b/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts index 6bee921..e80ddf2 100644 --- a/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts +++ b/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts @@ -210,7 +210,7 @@ export class EntityUpdatesHandler { ): LuaEntity[] { return surface.find_entities_filtered({ position: mapPosition, - collision_mask: "resource", + type: "resource", } ) } @@ -223,7 +223,7 @@ export class EntityUpdatesHandler { ): LuaEntity[] { return surface.find_entities_filtered({ area: area, - collision_mask: "resource", + type: "resource", } ) }