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 <noreply@anthropic.com>
This commit is contained in:
Lazzexus 2026-10-12 16:36:12 +02:00
parent 8040abfd82
commit 05389d5954

View file

@ -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",
}
)
}