Repository navigation
fix(get_entity): do not return an entity from a neighbouring tile - #429
Open
hashbender wants to merge 1 commit into
Open
hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
get_entity searches an area one tile wider than the position on every side and returns the closest entity of the requested type in it. For an empty tile next to an entity of that type (e.g. a gap in a pipe line) it returned the neighbour, so a caller checking "is there a pipe here?" got a pipe from the next tile. Only consider entities whose tile footprint contains the position; when there is none, the existing "not found" path returns None as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_entityon an empty tile returns the entity on the tile next to it instead ofNone:Agents use
get_entity(...) is Noneto find gaps in pipe or belt lines, so a one-tile gap stays hidden.Root cause
get_entity/server.lua:13-24searches{{x - 1, y - 1}, {x + 1, y + 1}}(width and height hard-coded to 1; the collision-box code is commented out).:29-38then takes the closest entity of that name, and any entity on a neighbouring tile is inside that area.Fix
bounding_boxrounded out to whole tiles) contains the position.None, as before.Testing
Run against a Factorio 2.0.73 headless server:
test_get_entity_on_empty_neighbouring_tile_returns_nonefails onmain(returns the chest) and passes with the fix. All 10 tests intests/actions/test_get_entity.pypass with the fix.mainstill returns it and the fix returnsNone.🤖 Generated with Claude Code