Skip to content

Commit

Permalink
Fix NPE in break time calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSharp committed Apr 10, 2024
1 parent 62b2f81 commit 4572b75
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/baritone/utils/ToolSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ private double avoidanceMultiplier(Block b) {
* @return how long it would take in ticks
*/
public static double calculateSpeedVsBlock(ItemStack item, BlockState state) {
float hardness = state.getDestroySpeed(null, null);
float hardness;
try {
hardness = state.getDestroySpeed(null, null);
} catch (NullPointerException npe) {
// can't easily determine the hardness so treat it as unbreakable
return -1;
}
if (hardness < 0) {
return -1;
}
Expand Down

0 comments on commit 4572b75

Please sign in to comment.