Skip to content

Commit

Permalink
Code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Oct 21, 2024
1 parent a22fc36 commit 54f1f28
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class ImageLayoutImpl(
}
val newHeight = (it.image.image.height.toDouble() * scale()).roundToInt()
val div = newHeight.toDouble() / it.image.image.height.toDouble()
for (i in (0..<count)) {
val y = (y() + groupY() * i)
for (i in 0..<count) {
val y = y() + groupY() * i
list.add(componentMap.computeIfAbsent(BitmapData(dir, y, newHeight)) { _ ->
val component = (parent.index++).parseChar()
val component = parent.index++.parseChar()
jsonArray.add(JsonObject().apply {
addProperty("type", "bitmap")
addProperty("file", "$NAMESPACE:$dir")
Expand Down Expand Up @@ -100,7 +100,7 @@ class ImageLayoutImpl(
val list = if (listen >= 0) {
components[(listen * components.lastIndex).roundToInt().coerceAtMost(components.lastIndex)]
} else {
components[(next++) % components.size]
components[next++ % components.size]
}
return list[count.coerceAtMost(list.lastIndex)]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TextLayoutImpl(
}

val map = HashMap<BitmapData, WidthKey>()
for (i in (0..<count)) {
for (i in 0..<count) {
val y = y() + groupY() * i
val keyName = "${parent.name}/$name/${i + 1}"
keys.add(map.computeIfAbsent(BitmapData(keyName, y, height)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ListenerManagerImpl : ListenerManager, BetterHealthBerManager {
}
put("absorption") {
HealthBarListener {
(it.entity.entity().absorptionAmount) / it.entity.entity().getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.value
it.entity.entity().absorptionAmount / it.entity.entity().getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.value
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PackResource {
add(JsonObject().apply {
addProperty("type", "space")
add("advances", JsonObject().apply {
(-8192..8192).forEach { i ->
for (i in -8192..8192) {
addProperty((ADVENTURE_START_INT + i).parseChar(), i)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun HealthBarCreateEvent.createEntity(component: WidthComponent, layer: Int = 0)
return PLUGIN.nms().createTextDisplay(player.player(), toEntityLocation(), component.component.build()).apply {
val scale = healthBar.scale()
transformation(
Vector(0.0, if (ConfigManagerImpl.useCoreShaders()) -(1 - scale.y) * 8192 / 40 else 0.0, (layer.toDouble()) / 4000),
Vector(0.0, if (ConfigManagerImpl.useCoreShaders()) -(1 - scale.y) * 8192 / 40 else 0.0, layer.toDouble() / 4000),
scale
)
}
Expand Down
2 changes: 1 addition & 1 deletion dist/src/main/kotlin/kr/toxicity/healthbar/util/Images.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fun BufferedImage.withOpacity(opacity: Int): BufferedImage {
for (i2 in 0..<height) {
val rgba = getRGB(i1, i2)
val alpha = opacity shl 24
it.setRGB(i1, i2, alpha or (if ((rgba shr 24) and 0xFF > 0) (rgba and 0xFFFFFF) else ENCODE_COLOR))
it.setRGB(i1, i2, alpha or if ((rgba shr 24) and 0xFF > 0) rgba and 0xFFFFFF else ENCODE_COLOR)
}
}
}
Expand Down

0 comments on commit 54f1f28

Please sign in to comment.