mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-19 19:49:51 +00:00
Update NEIMeteorRecipeHandler.java
This commit is contained in:
1 parent
801a8548f2
commit
d8b0fa1cc9
1 file changed
+14
-4
@@ -36,6 +36,16 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
|
||||
this.input.add(new PositionedStack(meteor.focusStack, 74, 4));
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
float totalMeteorWeight = 0.0f;
|
||||
for (MeteorParadigmComponent component : meteor.componentList) {
|
||||
ItemStack stack = component.getValidBlockParadigm();
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
totalMeteorWeight += component.getChance();
|
||||
}
|
||||
|
||||
for (MeteorParadigmComponent component : meteor.componentList) {
|
||||
ItemStack stack = component.getValidBlockParadigm();
|
||||
List<String> tooltips = new ArrayList<>();
|
||||
@@ -43,7 +53,7 @@ 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())));
|
||||
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(component.getChance() / totalMeteorWeight)));
|
||||
this.outputs.add(new TooltipStack(stack, 3 + 18 * col, 37 + 18 * row, tooltips));
|
||||
col++;
|
||||
if (col > 8) {
|
||||
@@ -171,9 +181,9 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String getFormattedChance(int chance) {
|
||||
float percentage = (float) chance / 10;
|
||||
boolean isInteger = Float.compare(percentage, (float) (chance / 10)) == 0;
|
||||
private String getFormattedChance(float chance) {
|
||||
float percentage = chance * 100.0f;
|
||||
boolean isInteger = percentage - (int) percentage <= 0.01;
|
||||
if (isInteger) return String.format("%,d", (int) percentage);
|
||||
else return String.format("%,.1f", percentage);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user