-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc87025
commit da0ce28
Showing
17 changed files
with
322 additions
and
118 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
7 changes: 7 additions & 0 deletions
7
api/src/main/java/kr/toxicity/hud/api/player/HudPlayerHead.java
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,4 +1,11 @@ | ||
package kr.toxicity.hud.api.player; | ||
|
||
import net.kyori.adventure.text.format.TextColor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
||
import java.util.List; | ||
|
||
public interface HudPlayerHead { | ||
@NotNull @Unmodifiable List<TextColor> getColors(); | ||
} |
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
45 changes: 45 additions & 0 deletions
45
dist/src/main/kotlin/kr/toxicity/hud/hud/HudHeadElement.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,45 @@ | ||
package kr.toxicity.hud.hud | ||
|
||
import com.google.gson.JsonArray | ||
import com.google.gson.JsonObject | ||
import kr.toxicity.hud.api.player.HudPlayer | ||
import kr.toxicity.hud.api.update.UpdateEvent | ||
import kr.toxicity.hud.image.ImageLocation | ||
import kr.toxicity.hud.layout.HeadLayout | ||
import kr.toxicity.hud.renderer.HeadRenderer | ||
import kr.toxicity.hud.shader.GuiLocation | ||
import kr.toxicity.hud.shader.HudShader | ||
import kr.toxicity.hud.util.NAME_SPACE | ||
import kr.toxicity.hud.util.parseChar | ||
import net.kyori.adventure.text.Component | ||
|
||
class HudHeadElement(parent: HudImpl, private val head: HeadLayout, gui: GuiLocation, pixel: ImageLocation) { | ||
private val renderer = run { | ||
val final = head.location + pixel | ||
val shader = HudShader( | ||
gui, | ||
head.layer, | ||
head.outline | ||
) | ||
HeadRenderer( | ||
(0..7).map { i -> | ||
val char = (++parent.imageChar).parseChar() | ||
parent.jsonArray.add(JsonObject().apply { | ||
addProperty("type", "bitmap") | ||
addProperty("file", "$NAME_SPACE:head/pixel_${head.head.pixel}.png") | ||
addProperty("ascent", HudImpl.createBit(final.y - (7 - i) * head.head.pixel, shader)) | ||
addProperty("height", head.head.pixel) | ||
add("chars", JsonArray().apply { | ||
add(char) | ||
}) | ||
}) | ||
Component.text(char).font(parent.imageKey) | ||
}, | ||
head.head.pixel, | ||
final.x, | ||
head.conditions.and(head.head.conditions) | ||
) | ||
} | ||
|
||
fun getHead(player: HudPlayer) = renderer.getHead(UpdateEvent.EMPTY)(player) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package kr.toxicity.hud.layout | ||
|
||
import kr.toxicity.hud.image.ImageLocation | ||
import kr.toxicity.hud.placeholder.ConditionBuilder | ||
import kr.toxicity.hud.player.HudHead | ||
|
||
class HeadLayout( | ||
val head: HudHead, | ||
val location: ImageLocation, | ||
val outline: Boolean, | ||
val layer: Int, | ||
val conditions: ConditionBuilder | ||
) |
Oops, something went wrong.