Commit 7272e15
committed
Fixed
The warning occured because `delivery.getBlockPos()` might return null, leading to a `NullPointerException` when calling `pos.getX()`. Although `isBlockTarget()` checks for non-null `blockPos`, the static analyzer doesn't recognize this invariant.
Solved it by adding a null check for `delivery.getBlockPos()` in the `applyTargeted` method. Only proceed with sound playback if `pos` is not null. The null check if `(pos != null)` ensures `pos.getX()` won't be called on a null reference. This satisfies the static analyzer while maintaining the existing logic since `isBlockTarget()` already implies `blockPos` shouldn't be null. The check acts as a safeguard against potential future changes to `TargetedSpellDelivery`.Method invocation 'getX' may produce 'NullPointerException'
1 parent ebb2f7a commit 7272e15
File tree
1 file changed
+3
-1
lines changed- src/main/java/dev/overgrown/thaumaturge/spell/impl/victus
1 file changed
+3
-1
lines changedLines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
0 commit comments