forked from CleverNucleus/data-attributes
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge 1.20.1/fabric dev formatting (#29)
* Implement Interface Injection, bump version (#22) * [init] initial commit of formatting * [fix] Add endec suppor tto attribute format * [format] change formatting of percentages * [semver] bump version to beta-12 * [feat] Add getFormattedValue to API * [chore] update changelog --------- Co-authored-by: Bibi Reden <[email protected]>
- Loading branch information
1 parent
f9b9cf4
commit 26f33b7
Showing
11 changed files
with
125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
## Changes 🌽 | ||
- Resolved an issue with entity-types/functions not applying properly if a mod/data-pack got to the entity-type id first. | ||
## Additions 🍎 | ||
- Added a condensed way to format attribute values into the API through `getFormattedValue`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/bibireden/data_attributes/api/attribute/AttributeFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.bibireden.data_attributes.api.attribute | ||
|
||
import io.wispforest.endec.Endec | ||
|
||
enum class AttributeFormat(val function: (min: Double, max: Double, value: Double) -> String) { | ||
Percentage ({min, max, value -> "%.2f".format((value-min)/((max-min)/100))+"%" }), | ||
Whole({_, _, value -> "$value"} ); | ||
|
||
companion object { | ||
val ENDEC: Endec<AttributeFormat> = Endec.STRING.xmap(AttributeFormat::of) { it.name } | ||
|
||
fun of(id: String) = if (id.equals("percentage", ignoreCase = true)) Percentage else Whole | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/kotlin/com/bibireden/data_attributes/config/functions/AttributeFunction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters