Skip to content

NPE fix (gravity over non-solid) - #862

Merged
Raycoms merged 1 commit into
ldtteam:version/mainfrom
armele:blueprint_npe
Nov 8, 2026
Merged

Raycoms merged 1 commit into
ldtteam:version/mainfrom
armele:blueprint_npe

Conversation

@armele

@armele armele commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Closes None

Changes proposed in this pull request

  • NPE caused by attempting to use the scan tool to remove a gravity block (like sand) that is placed over a non-solid (like string).

Can be reproduced by a simple placeholder under string under sand, highlighting that structure, then pressing the "Show Resources" button & removing the sand.

Testing

  • Yes I tested this before submitting it.
  • I also did a multiplayer test.

Review please

BlockState supportBlockState = placementContext.getSolidBlockForPos(pos, placementContext.getBluePrint().getRawBlockStateFunction());
final Blueprint blueprint = placementContext.getBluePrint();

BlockState supportBlockState = placementContext.getSolidBlockForPos(pos, blueprint == null ? ignored -> null : blueprint.getRawBlockStateFunction());

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.

What crashes here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

NPE when getBlueprint() returns null. I can get a stack trace next time I am at the computer...

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.

I wonder why the blueprint is null when the block below is non solid like string. I think the actual error might be upstream then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's the top of the stack trace: java.lang.NullPointerException: Cannot invoke "com.ldtteam.structurize.blueprints.v1.Blueprint.getRawBlockStateFunction()" because the return value of "com.ldtteam.structurize.placement.IPlacementContext.getBluePrint()" is null
at com.ldtteam.structurize.placement.handlers.placement.PlacementHandlers$FallingBlockPlacementHandler.getRequiredItems(PlacementHandlers.java:353) ~[main/:?] {re:classloading}
at com.ldtteam.structurize.client.gui.WindowScan.updateResources(WindowScan.java:511) ~[main/:?] {re:classloading}
at com.ldtteam.structurize.client.gui.WindowScan.showResClicked(WindowScan.java:234) ~[main/:?] {re:classloading}
at com.ldtteam.structurize.client.gui.AbstractWindowSkeleton.lambda$registerButton$0(AbstractWindowSkeleton.java:49) ~[main/:?] {re:classloading}
at com.ldtteam.structurize.client.gui.AbstractWindowSkeleton.onButtonClicked(AbstractWindowSkeleton.java:76) ~[main/:?] {re:classloading}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is an upstream problem, as WindowScan passes a SimplePlacementContext to be used (in my test, at least) and that always returns a null blueprint.

@Raycoms
Raycoms merged commit f66c19c into ldtteam:version/main Nov 8, 2026
1 check passed
Raycoms pushed a commit that referenced this pull request Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants