Skip to content

Commit

Permalink
Improve harvest
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Sep 11, 2024
1 parent 894e522 commit 60fc879
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class HarvestInfoTools {
"iron",
"diamond",
"obsidian",
"cobalt"
"cobalt",
"duranite",
"valyrium",
"vibranium"
};

private static final HashMap<String, ItemStack> testTools = new HashMap<>();
Expand All @@ -46,13 +49,15 @@ static void showHarvestLevel(IProbeInfo probeInfo, IBlockState blockState, Block
if (harvestTool != null) {
int harvestLevel = block.getHarvestLevel(blockState);
String harvestName;
if (harvestLevel >= harvestLevels.length) {
harvestName = Integer.toString(harvestLevel);
} else if (harvestLevel < 0) {

// Handle out-of-bounds or negative harvest levels by converting to string
if (harvestLevel < 0 || harvestLevel >= harvestLevels.length) {
harvestName = Integer.toString(harvestLevel);
} else {
harvestName = harvestLevels[harvestLevel];
}

// Add text information to the probe
probeInfo.text(LABEL + "{*theoneprobe.probe.tool_indicator*} " + INFO + harvestTool + " (level " + harvestName + ")");
}
}
Expand Down Expand Up @@ -105,9 +110,10 @@ static void showHarvestInfo(IProbeInfo probeInfo, World world, BlockPos pos, Blo
// NOTE: When a block doesn't have an explicitly-set harvest tool, getHarvestLevel will return -1 for ANY tool. (Expected behavior)
// ModSetup.getLogger().info("HarvestLevel out of bounds (less than 0). Found " + harvestLevel);
} else if (harvestLevel >= harvestLevels.length) {
harvestName = StringUtils.capitalize(harvestLevels[harvestLevels.length - 1]);
// ModSetup.getLogger().info("HarvestLevel out of bounds (Max value " + harvestLevels.length + "). Found " + harvestLevel);
} else {
harvestName = harvestLevels[harvestLevel];
harvestName = StringUtils.capitalize(harvestLevels[harvestLevel]);
}
harvestTool = StringUtils.capitalize(harvestTool);
}
Expand Down

0 comments on commit 60fc879

Please sign in to comment.