aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-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(