From 82d75209442c701ecddc6216b2d297979a661b52 Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 2 Sep 2022 20:52:12 +0900 Subject: [PATCH] Add estimated amount display for meteor NEI (#31) --- .../client/nei/NEIMeteorRecipeHandler.java | 11 +++++++++-- .../assets/alchemicalwizardry/lang/en_US.lang | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index 7379cf08..e0570e40 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -51,8 +51,11 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { 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; @@ -197,7 +200,11 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { .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); + } } diff --git a/src/main/resources/assets/alchemicalwizardry/lang/en_US.lang b/src/main/resources/assets/alchemicalwizardry/lang/en_US.lang index 47bbf0dd..03d59f93 100644 --- a/src/main/resources/assets/alchemicalwizardry/lang/en_US.lang +++ b/src/main/resources/assets/alchemicalwizardry/lang/en_US.lang @@ -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