diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-10 15:24:07 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-10 15:24:07 +0200 |
commit | 28975d2a1e9f2ca6cac1a012f3b9d3d7d45adaf2 (patch) | |
tree | 8736edeac1987d08b71e18d75be564758ecc21f8 /src/main/java/io | |
parent | 251b365e4846aa89513d78208a7c0f77a5540701 (diff) | |
download | NotEnoughUpdates-28975d2a1e9f2ca6cac1a012f3b9d3d7d45adaf2.tar.gz NotEnoughUpdates-28975d2a1e9f2ca6cac1a012f3b9d3d7d45adaf2.tar.bz2 NotEnoughUpdates-28975d2a1e9f2ca6cac1a012f3b9d3d7d45adaf2.zip |
fix adding slayer tier 1 minion prices to higher tiers for full crafting cost
Diffstat (limited to 'src/main/java/io')
4 files changed, 34 insertions, 8 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java index 27e7ac22..ba38b01d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/Minion.java @@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderables.OverviewLine; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CustomSource; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; import java.util.ArrayList; @@ -32,6 +33,7 @@ public class Minion extends OverviewLine { private final int tier; private String displayName; private MinionSource minionSource; + private CustomSource customSource; private Minion parent; private final List<MinionRequirement> requirements = new ArrayList<>(); @@ -99,4 +101,12 @@ public class Minion extends OverviewLine { public void onClick() { NotEnoughUpdates.INSTANCE.manager.displayGuiItemRecipe(internalName); } + + public void setCustomSource(CustomSource customSource) { + this.customSource = customSource; + } + + public CustomSource getCustomSource() { + return customSource; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java index 952bd07a..6d7c9daa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java @@ -26,6 +26,8 @@ import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionH import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.repo.MinionHelperRepoLoader; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.MinionHelperOverlay; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.MinionHelperTooltips; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CustomSource; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.util.MinionHelperPriceCalculation; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.util.MinionHelperRequirementsManager; import io.github.moulberry.notenoughupdates.util.Utils; @@ -248,4 +250,12 @@ public class MinionHelperManager { public int getNeedForNextSlot() { return needForNextSlot; } + + public void setCustomSource(Minion minion, CustomSource customSource) { + MinionSource minionSource = minion.getMinionSource(); + if (minionSource == null) { + minion.setMinionSource(customSource); + } + minion.setCustomSource(customSource); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java index e73e8e7a..2eed2958 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java @@ -112,7 +112,7 @@ public class MinionHelperRepoLoader { String sourceName = entry.getValue(); Minion minion = manager.getMinionById(internalName); if (minion == null) continue; - minion.setMinionSource(new CustomSource(sourceName)); + manager.setCustomSource(minion, new CustomSource(sourceName)); } manager.getMinionById("FLOWER_GENERATOR_1").getRequirements().add(new CustomRequirement( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java index 79a1848a..3ffe4846 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java @@ -32,9 +32,7 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; public class MinionHelperPriceCalculation { @@ -70,16 +68,18 @@ public class MinionHelperPriceCalculation { String internalName = minion.getInternalName(); if (upgradeOnly) { if (upgradeCostFormatCache.containsKey(internalName)) { - upgradeCostFormatCache.get(internalName); + return upgradeCostFormatCache.get(internalName); } } else { if (fullCostFormatCache.containsKey(internalName)) { - fullCostFormatCache.get(internalName); + return fullCostFormatCache.get(internalName); } } - if (source instanceof CustomSource) { - return "§f" + ((CustomSource) source).getSourceName(); + if (upgradeOnly) { + if (minion.getCustomSource() != null) { + return "§f" + (minion.getCustomSource()).getSourceName(); + } } long costs = calculateUpgradeCosts(minion, upgradeOnly); @@ -104,6 +104,13 @@ public class MinionHelperPriceCalculation { public long calculateUpgradeCosts(Minion minion, boolean upgradeOnly) { MinionSource source = minion.getMinionSource(); + + if (upgradeOnly) { + if (minion.getCustomSource() != null) { + return 0; + } + } + if (source instanceof CraftingSource) { CraftingSource craftingSource = (CraftingSource) source; return getCosts(minion, upgradeOnly, craftingSource.getItems()); @@ -161,7 +168,6 @@ public class MinionHelperPriceCalculation { long avgBinPrice = (long) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalName); if (avgBinPrice >= 1) return avgBinPrice; - //is ah without bin JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalName); if (auctionInfo == null) { |