Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two new settings to 1.20.1 #285

Open
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BountifulConfigData {
var boardUpdateFrequency: Int = 45
var boardGenFrequency: Int = 2
var flatBonusTimePerBounty: Int = 0
var shouldReputationDecreaseOnFail = false
var shouldBountiesHaveTimersAndExpire = true
var dataPackExclusions = listOf(
"bounty_pools/bountiful/example_pool",
Expand All @@ -22,6 +23,7 @@ class BountifulConfigData {
var objectiveModifier = 0
var maxNumRewards = 2
var showCompletionToast = true
var allowMultipleCopies = true

fun buildScreen(): Screen {
val builder = ConfigBuilder.create()
Expand Down Expand Up @@ -93,6 +95,17 @@ class BountifulConfigData {
}.build()
)

board.addEntry(
creator.startBooleanToggle(
Text.literal("Reputation Decrease on Fail"),
shouldReputationDecreaseOnFail
).setDefaultValue(false).setTooltip(
Text.literal("Whether reputation should decrease when a bounty is taken but not completed")
).setSaveConsumer {
shouldReputationDecreaseOnFail = it
}.build()
)

val bounty = builder.getOrCreateCategory(Text.literal("General - Bounty"))

bounty.addEntry(
Expand Down Expand Up @@ -134,6 +147,17 @@ class BountifulConfigData {
}.build()
)

bounty.addEntry(
creator.startBooleanToggle(
Text.literal("Allow Multiple Copies"),
allowMultipleCopies
).setDefaultValue(true).setTooltip(
Text.literal("Whether multiple copies of the same bounty can be taken by different players")
).setSaveConsumer {
allowMultipleCopies = it
}.build()
)

val client = builder.getOrCreateCategory(Text.literal("Client"))

client.addEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BoardBlockEntity(pos: BlockPos, state: BlockState)
NamedScreenHandlerFactory {

private val decrees = SimpleInventory(3)
private val bounties = BountyInventory()
internal val bounties = BountyInventory()

private var takenMask = mutableMapOf<String, MutableSet<Int>>()
private val takenSerializer = MapSerializer(String.serializer(), SetSerializer(Int.serializer()))
Expand All @@ -51,7 +51,7 @@ class BoardBlockEntity(pos: BlockPos, state: BlockState)
return takenMask.getOrPut(player.uuidAsString) { mutableSetOf() }
}

private var finishMap = mutableMapOf<String, Int>()
internal var finishMap = mutableMapOf<String, Int>()
private val finishSerializer = MapSerializer(String.serializer(), Int.serializer())

// Whether this board has even been initialized/given starting data
Expand All @@ -60,7 +60,7 @@ class BoardBlockEntity(pos: BlockPos, state: BlockState)

// Calculated level, progress to next, point of next level
private val levelData: Triple<Int, Int, Int>
get() = levelProgress(finishMap.values.sum())
get() = levelProgress(finishMap.values.sum().coerceAtLeast(0))

private fun setDecree() {
if (world is ServerWorld && decrees.isEmpty) {
Expand All @@ -74,12 +74,12 @@ class BoardBlockEntity(pos: BlockPos, state: BlockState)
}

val numCompleted: Int
get() = finishMap.values.sum()
get() = finishMap.values.sum().coerceAtLeast(0)

fun updateCompletedBounties(player: PlayerEntity) {
finishMap[player.uuidAsString] = finishMap.getOrPut(player.uuidAsString) {
0
} + 1
} + if (BountifulIO.configData.shouldReputationDecreaseOnFail) 2 else 1
}

private fun getBoardDecrees(): Set<Decree> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.ejekta.bountiful.content.gui

import io.ejekta.bountiful.config.BountifulIO
import io.ejekta.bountiful.content.board.BoardBlockEntity
import io.ejekta.bountiful.content.board.BoardInventory
import io.ejekta.bountiful.util.readOnlyCopy
Expand All @@ -26,9 +27,17 @@ class BoardBountySlot(val inv: BoardInventory, index: Int, x: Int, y: Int) : Slo
}
}.filterNotNull()
for (newIndex in matchingMaskIndices) {
board.maskFor(player).add(newIndex)
if (BountifulIO.configData.shouldReputationDecreaseOnFail) {
board.finishMap[player.uuidAsString] = board.finishMap.getOrDefault(player.uuidAsString, 0) - 1
}
if (BountifulIO.configData.allowMultipleCopies) {
board.maskFor(player).add(newIndex)
} else {
board.bounties.removeStack(newIndex)
}
}
}

super.onTakeItem(player, stack)
return true
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencyResolutionManagement {
}

val Ejekta = object {
val Kambrik = "6.1.0"
val Kambrik = "6.1.1"
val KambrikSnapshot = true
}

Expand Down