From 0aefc9b967c1cdcc61e46dc822995e2f507838ab Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Thu, 22 Dec 2022 16:24:34 +0100 Subject: PetLeveling: Fix non legendary pets being able to be leveled above 100 (#499) --- .../kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt index e7d29642..0a9e37b9 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt @@ -105,7 +105,7 @@ object PetLeveling { } maxLevel = customLeveling["max_level"]?.asInt ?: maxLevel } - return ExpLadder(levels.drop(offset).take(maxLevel)) + return ExpLadder(levels.drop(offset).take(maxLevel - 1)) } } -- cgit From 9cc5c71a0a8812a14cdc39d7a6b020506fb336cd Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Sun, 25 Dec 2022 11:41:08 +0100 Subject: PetLeveling: return stub exp ladder on misformed repo data (#508) --- .../moulberry/notenoughupdates/util/PetLeveling.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt index 0a9e37b9..56f84d54 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt @@ -91,17 +91,22 @@ object PetLeveling { } } + val stubExpLadder by lazy { + Utils.showOutdatedRepoNotification() + ExpLadder(listOf(1, 1)) + } + internal fun getPetLevelingForPet0(petIdWithoutRarity: String, rarity: Rarity): ExpLadder { - val petConstants = this.petConstants ?: Constants.PETS - var levels = petConstants["pet_levels"].asJsonArray.map { it.asLong }.toMutableList() - val customLeveling = petConstants["custom_pet_leveling"].asJsonObject[petIdWithoutRarity] - val offset = petConstants["pet_rarity_offset"].asJsonObject[rarity.name].asInt + val petConstants = this.petConstants ?: Constants.PETS ?: return stubExpLadder + var levels = petConstants["pet_levels"]?.asJsonArray?.map { it.asLong }?.toMutableList() ?: return stubExpLadder + val customLeveling = petConstants["custom_pet_leveling"]?.asJsonObject?.get(petIdWithoutRarity) + val offset = petConstants["pet_rarity_offset"]?.asJsonObject?.get(rarity.name)?.asInt ?: return stubExpLadder var maxLevel = 100 if (customLeveling is JsonObject) { - val customLevels by lazy { customLeveling["pet_levels"].asJsonArray.map { it.asLong } } + val customLevels by lazy { customLeveling["pet_levels"]?.asJsonArray?.map { it.asLong } } when (customLeveling["type"]?.asInt ?: 0) { - 1 -> levels.addAll(customLevels) - 2 -> levels = customLevels.toMutableList() + 1 -> levels.addAll(customLevels ?: return stubExpLadder) + 2 -> levels = customLevels?.toMutableList() ?: return stubExpLadder } maxLevel = customLeveling["max_level"]?.asInt ?: maxLevel } -- cgit From fa7abebe73f629c17e7a43d8c50307d2f8aa588e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 27 Dec 2022 19:56:24 +0100 Subject: Craft cost price calculation improved (#511) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../kotlin/io/github/moulberry/notenoughupdates/recipes/KatRecipe.kt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/KatRecipe.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/KatRecipe.kt index c4b64969..e6dc0abc 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/KatRecipe.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/KatRecipe.kt @@ -161,4 +161,6 @@ data class KatRecipe( override fun getBackground(): ResourceLocation { return ResourceLocation("notenoughupdates:textures/gui/katting_tall.png") } + + override fun shouldUseForCraftCost() = false } -- cgit From e603cf230af0cef44481633888ec13d2097b6310 Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 13 Jan 2023 13:29:39 +0100 Subject: PetLeveling: Allow for defining custom level offsets for pets (#534) --- .../kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt index 56f84d54..200aa3fa 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/PetLeveling.kt @@ -100,7 +100,7 @@ object PetLeveling { val petConstants = this.petConstants ?: Constants.PETS ?: return stubExpLadder var levels = petConstants["pet_levels"]?.asJsonArray?.map { it.asLong }?.toMutableList() ?: return stubExpLadder val customLeveling = petConstants["custom_pet_leveling"]?.asJsonObject?.get(petIdWithoutRarity) - val offset = petConstants["pet_rarity_offset"]?.asJsonObject?.get(rarity.name)?.asInt ?: return stubExpLadder + var rarityOffsets = petConstants["pet_rarity_offset"]?.asJsonObject var maxLevel = 100 if (customLeveling is JsonObject) { val customLevels by lazy { customLeveling["pet_levels"]?.asJsonArray?.map { it.asLong } } @@ -109,7 +109,10 @@ object PetLeveling { 2 -> levels = customLevels?.toMutableList() ?: return stubExpLadder } maxLevel = customLeveling["max_level"]?.asInt ?: maxLevel + rarityOffsets = customLeveling["rarity_offset"]?.asJsonObject ?: rarityOffsets } + val offset = rarityOffsets?.get(rarity.name)?.asInt ?: return stubExpLadder + return ExpLadder(levels.drop(offset).take(maxLevel - 1)) } -- cgit