Skip to content

Commit

Permalink
Add estimated amount display for meteor NEI (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune authored Sep 2, 2022
1 parent 3994b25 commit 82d7520
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) {
stack = new ItemStack(Blocks.fire);
tooltips.add(String.format("no entries found for oredict \"%s\"", component.getOreDictName()));
}
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(component.getChance() / totalMeteorWeight)));
float chance = component.getChance() / totalMeteorWeight;
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(chance)));
tooltips.add(I18n.format("nei.recipe.meteor.amount", getEstimatedAmount(chance, meteor.radius)));
this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips));

col++;
if (col > 8) {
col = 0;
Expand Down Expand Up @@ -197,7 +200,11 @@ private List<MeteorParadigm> getSortedMeteors() {
.collect(Collectors.toList());
}

private String getFormattedChance(double chance) {
private String getFormattedChance(float chance) {
return new DecimalFormat("0.##").format(chance * 100);
}

private int getEstimatedAmount(float chance, int radius) {
return (int) Math.ceil(3f / 4 * Math.PI * Math.pow(radius, 3) * chance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ nei.recipe.meteor.category=Meteor Ritual
nei.recipe.meteor.cost=Cost: %s LP
nei.recipe.meteor.radius=Radius: %s
nei.recipe.meteor.chance=Chance: %s%%
nei.recipe.meteor.amount=Estimated amount: %s

#Rituals
ritual.AW001Water.name=Ritual of the Full Spring
Expand Down

0 comments on commit 82d7520

Please sign in to comment.