diff options
author | kr45732 <52721908+kr45732@users.noreply.github.com> | 2022-10-21 02:34:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 23:34:05 -0700 |
commit | 280a89cdbf086e53bcd6985e1ddd48b6aa718087 (patch) | |
tree | 0c37d97f8067621d717ed53ed4e6c159cee4f0a0 /src/main/java/io | |
parent | d1f618d8e952ee2ac2cba4b97df7677773c66472 (diff) | |
download | NotEnoughUpdates-280a89cdbf086e53bcd6985e1ddd48b6aa718087.tar.gz NotEnoughUpdates-280a89cdbf086e53bcd6985e1ddd48b6aa718087.tar.bz2 NotEnoughUpdates-280a89cdbf086e53bcd6985e1ddd48b6aa718087.zip |
Me when I read NEU code (#350)
350/merge
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index 6460e1ed..a49b9e6d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -1239,6 +1239,7 @@ public class RenderListener { if (stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) { int stars = Utils.getNumberOfStars(stack); if (stars == 0) continue; + String starsStr = "" + stars; NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8); int costIndex = 10000; @@ -1251,38 +1252,39 @@ public class RenderListener { if (entry.equals("§7Cost")) { costIndex = j; } + if (j > costIndex) { entry = entry.trim(); - int index = entry.lastIndexOf('x'); - String item, amountString; - if (index < 0) { - item = entry.trim() + " x1"; - amountString = "x1"; - } else { - amountString = entry.substring(index); - item = entry.substring(0, index).trim(); + + int countIndex = entry.lastIndexOf(" §8x"); + + String upgradeName = entry; + String amount = "1"; + if (countIndex != -1) { + upgradeName = entry.substring(0, countIndex); + // +4 to account for " §8x" + amount = entry.substring(countIndex + 4); } - item = item.substring(0, item.length() - 3); - int amount = Integer.parseInt(amountString.trim().replace("x", "").replace(",", "")); - if (item.endsWith("Essence")) { - int index2 = entry.indexOf("Essence"); - String type = item.substring(0, index2).trim().substring(2); - newEntry.add("type", new JsonPrimitive(type)); - newEntry.add(String.valueOf(stars), new JsonPrimitive(amount)); + + if (upgradeName.endsWith(" Essence")) { + // First 2 chars are control code + // [EssenceCount, EssenceType, "Essence"] + String[] upgradeNameSplit = upgradeName.substring(2).split(" "); + newEntry.addProperty("type", upgradeNameSplit[1]); + newEntry.addProperty(starsStr, Integer.parseInt(upgradeNameSplit[0].replace(",", ""))); } else { - String itemString = item + " §8x" + amount; if (!newEntry.has("items")) { newEntry.add("items", new JsonObject()); } - if (!newEntry.get("items").getAsJsonObject().has(String.valueOf(stars))) { - newEntry.get("items").getAsJsonObject().add(String.valueOf(stars), new JsonArray()); + if (!newEntry.get("items").getAsJsonObject().has(starsStr)) { + newEntry.get("items").getAsJsonObject().add(starsStr, new JsonArray()); } newEntry .get("items") .getAsJsonObject() - .get(String.valueOf(stars)) + .get(starsStr) .getAsJsonArray() - .add(new JsonPrimitive(itemString)); + .add(new JsonPrimitive(upgradeName + (upgradeName.contains("Coins") ? "" : (" §8x" + amount)))); } } } |