aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-08-20 03:20:08 +0200
committerGitHub <noreply@github.com>2022-08-20 11:20:08 +1000
commit46e99cbaac7e999048c18ee8f310b1b1b5d333af (patch)
tree338338f5719e1f9c7ea5f50ba19d1ced36aa9fe5 /src
parent5908643f22674f68ad5f48edae01133b61e593a7 (diff)
downloadNotEnoughUpdates-46e99cbaac7e999048c18ee8f310b1b1b5d333af.tar.gz
NotEnoughUpdates-46e99cbaac7e999048c18ee8f310b1b1b5d333af.tar.bz2
NotEnoughUpdates-46e99cbaac7e999048c18ee8f310b1b1b5d333af.zip
more friendly drop chance format (#231)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
index 0d891071..7702f365 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
@@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.miscfeatures.entityviewer.EntityViewer;
import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.Panorama;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
import io.github.moulberry.notenoughupdates.util.JsonUtils;
@@ -64,11 +65,28 @@ public class MobLootRecipe implements NeuRecipe {
if (itemStack == null) {
itemStack = drop.getItemStack().copy();
List<String> arrayList = new ArrayList<>(extra);
- arrayList.add("§r§e§lDrop Chance: §6" + chance);
+ arrayList.add("§r§e§lDrop Chance: §6" + formatDropChance());
ItemUtils.appendLore(itemStack, arrayList);
}
return itemStack;
}
+
+ private String formatDropChance() {
+ if (!chance.endsWith("%")) {
+ return chance + " §cInvalid repo data!";
+ }
+
+ String chanceText = chance.substring(0, chance.length() - 1);
+ int chanceIn;
+ try {
+ chanceIn = (int) (100.0 / Double.parseDouble(chanceText));
+ } catch (NumberFormatException e) {
+ return chance + " §cInvalid repo data!";
+ }
+
+ String format = GuiProfileViewer.numberFormat.format(chanceIn);
+ return "1/" + format + " (" + chance + ")";
+ }
}
public static ResourceLocation BACKGROUND = new ResourceLocation(