Skip to content

Commit f3707b9

Browse files
committed
Restore background function.
1 parent 19f33c8 commit f3707b9

39 files changed

+275
-239
lines changed

bootstrap/bukkit/src/main/kotlin/kr/toxicity/hud/bootstrap/bukkit/compatibility/oraxen/OraxenCompatibility.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class OraxenCompatibility : Compatibility {
4545
}
4646
else -> warn("Unknown Oraxen Version.")
4747
}
48-
info("Successfully handle Oraxen $version.")
48+
info(
49+
"BetterHud hooks Oraxen $version.",
50+
"Be sure to set 'pack-type' to 'none' in your config."
51+
)
4952
}
5053
}

bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/compatibility/PolymerResourcePackCompatibility.kt

+4
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,9 @@ class PolymerResourcePackCompatibility : Compatibility {
4949
is OnReload -> warn("This mod is still on reload!")
5050
}
5151
}
52+
info(
53+
"BetterHud hooks Polymer resource pack.",
54+
"Be sure to set 'pack-type' to 'none' in your config."
55+
)
5256
}
5357
}

bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/module/fabric/FabricStandardModule.kt

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kr.toxicity.hud.bootstrap.fabric.module.Module
1313
import net.minecraft.resources.ResourceLocation
1414
import net.minecraft.world.entity.LivingEntity
1515
import net.minecraft.world.entity.ai.attributes.Attributes
16+
import net.minecraft.world.item.ItemStack
1617
import java.util.function.Function
1718

1819
class FabricStandardModule : Module {
@@ -206,8 +207,17 @@ class FabricStandardModule : Module {
206207
it.fabricPlayer.hasPermission(args[0])
207208
}
208209
}
209-
210210
override fun getRequiredArgsLength(): Int = 1
211-
}
211+
},
212+
"has_main_hand" to HudPlaceholder.of { _, _ ->
213+
Function { p ->
214+
!p.fabricPlayer.mainHandItem.`is`(ItemStack.EMPTY.item)
215+
}
216+
},
217+
"has_off_hand" to HudPlaceholder.of { _, _ ->
218+
Function { p ->
219+
!p.fabricPlayer.offhandItem.`is`(ItemStack.EMPTY.item)
220+
}
221+
},
212222
)
213223
}

build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val platform = "4.3.4"
3131
val targetJavaVersion = 21
3232
val velocity = "3.4.0"
3333
val bStats = "3.1.0"
34-
val betterCommand = "1.1"
34+
val betterCommand = "1.2"
3535

3636
val supportedMinecraftVersions = listOf(
3737
//1.17
@@ -95,7 +95,7 @@ allprojects {
9595
apply(plugin = "org.jetbrains.dokka")
9696

9797
group = "kr.toxicity.hud"
98-
version = "1.8" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")
98+
version = "1.9" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")
9999

100100
repositories {
101101
mavenCentral()

changelog/1.9.md

+48-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,55 @@
1414
- If your server uses Oraxen, you have to use '/oraxen reload all' instead of '/hud reload'.
1515

1616
## Text layout
17+
![1](https://github.com/user-attachments/assets/2201c5ee-093f-4790-ab55-e0c40bf6a32f)
18+
```yaml
19+
test_text:
20+
texts:
21+
1:
22+
name: unifont
23+
pattern: Minecraft is a 3D sandbox adventure game developed by Mojang Studios where players can interact with a fully customizable three-dimensional world made of blocks and entities. Its diverse gameplay options allow players to choose the way they play, creating countless possibilities.
24+
align: center
25+
line-align: left
26+
scale: 0.5
27+
line: 5
28+
split-width: 300
29+
y: 32
30+
```
31+
![2](https://github.com/user-attachments/assets/ff220742-ecf0-4239-bc2b-be172ac2cc24)
32+
```yaml
33+
test_text:
34+
texts:
35+
1:
36+
name: unifont
37+
pattern: |
38+
<image:star> Background test <image:star>
39+
<image:star> Background test2 3 34 23423 <image:star>
40+
background: test
41+
align: center
42+
line-align: center
43+
scale: 0.5
44+
line: 5
45+
split-width: 300
46+
y: 32
47+
```
1748
- Add 'line' to use multiple line text.
1849
- Add 'line-width' to define the y location of each line.
1950
- Add 'split-width' to define max length of each line.
2051
- Add 'line-align' to sort each line.
52+
- BetterHud uses '\n' to split text line.
2153
22-
## Placeholder
54+
## Placeholder (Bukkit)
2355
These placeholders are added:
2456
- has_main_hand
2557
- has_off_hand
2658
- entity_health_percentage
2759
- entity_vehicle_health_percentage
2860
61+
## Placeholder (Fabric)
62+
These placeholders are added:
63+
- has_main_hand
64+
- has_off_hand
65+
2966
## Placeholder (MythicMobs)
3067
These placeholders are added:
3168
- mythicmobs_aura_duration_reversed:arg
@@ -37,15 +74,23 @@ These placeholders are added:
3774
- mythicmobs_entity_has_aura:arg
3875
3976
## Fix
40-
- Fix inappropriate space.
77+
- Fix inappropriate text space.
4178
- Fix self-host to stop when switch to other pack type.
4279
- Fix command load problem.
43-
- Fix inappropriate compass location fix.
80+
- Fix inappropriate compass location.
81+
- Fix no mysql connector library found in Fabric and Velocity.
82+
83+
## Improve
84+
- Improve compass movement.
4485
4586
## Config
4687
- Add 'remove-default-hotbar' to disable vanilla hotbar.
4788
- Add 'pack-type: none' to use other resource pack extension.
4889
90+
## Library
91+
- Now BetterHud uses BetterCommand 1.2.
92+
- Clean jar file to use runtime library injector.
93+
4994
## Contribute
5095
These languages are included:
5196
- ja_JP

dist/src/main/kotlin/kr/toxicity/hud/BetterHudImpl.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BetterHudImpl(val bootstrap: BetterHudBootstrap): BetterHud {
4949
PlaceholderManagerImpl,
5050
TriggerManagerImpl,
5151

52-
//BackgroundManager, //TODO Fix this
52+
BackgroundManager,
5353
ImageManager,
5454
TextManagerImpl,
5555
PlayerHeadManager,

dist/src/main/kotlin/kr/toxicity/hud/background/BackgroundImage.kt

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,17 @@
11
package kr.toxicity.hud.background
22

3-
import kr.toxicity.hud.api.component.WidthComponent
4-
import kr.toxicity.hud.api.yaml.YamlObject
53
import kr.toxicity.hud.configuration.HudConfiguration
6-
import kr.toxicity.hud.hud.HudImpl
7-
import kr.toxicity.hud.image.NamedLoadedImage
84
import kr.toxicity.hud.location.PixelLocation
9-
import kr.toxicity.hud.pack.PackGenerator
10-
import kr.toxicity.hud.renderer.BackgroundRenderer
11-
import kr.toxicity.hud.resource.GlobalResource
12-
import kr.toxicity.hud.shader.HudShader
13-
import kr.toxicity.hud.util.*
14-
import net.kyori.adventure.text.Component
15-
import java.io.File
16-
import kotlin.math.roundToInt
5+
import kr.toxicity.hud.image.LoadedImage
176

18-
//TODO Fix this
7+
//TODO replace it to proper background in the future.
198
class HudBackground(
209
override val path: String,
21-
private val id: String,
22-
private val yamlObject: YamlObject
23-
) : HudConfiguration {
10+
val name: String,
2411

25-
private val lineMap = HashMap<Int, List<ImageTriple>>()
12+
val left: LoadedImage,
13+
val right: LoadedImage,
14+
val body: LoadedImage,
2615

27-
private val location = PixelLocation(yamlObject)
28-
private val imageBuilder = BackgroundType.valueOf(yamlObject.getAsString("type", "auto").uppercase())
29-
30-
fun generateImage(resource: GlobalResource, line: Int, index: Int): ImageTriple {
31-
val triple = lineMap.computeIfAbsent(line) {
32-
val image = imageBuilder.parse(id, line, yamlObject)
33-
val leftX = image.maxOf {
34-
it.first.xOffset
35-
}
36-
val nameMap = run {
37-
val list = ArrayList<ImageTriple>()
38-
var i = 0
39-
image.forEach {
40-
list.add(ImageTriple(
41-
leftX,
42-
it.first.toNamed("background_${id}_${line}_${++i}"),
43-
it.second.toNamed("background_${id}_${line}_${++i}"),
44-
it.third.toNamed("background_${id}_${line}_${++i}")
45-
))
46-
}
47-
list
48-
}
49-
nameMap.forEach {
50-
it.forEach { image ->
51-
PackGenerator.addTask(resource.textures + image.name) {
52-
image.image.image.toByteArray()
53-
}
54-
}
55-
}
56-
nameMap
57-
}
58-
return if (index == 0) triple.first() else if (index == triple.lastIndex) triple.last() else triple[1.coerceAtMost(triple.lastIndex)]
59-
}
60-
61-
inner class ImageTriple(
62-
private val max: Int,
63-
private val first: NamedLoadedImage,
64-
private val second: NamedLoadedImage,
65-
private val third: NamedLoadedImage
66-
) : Iterable<NamedLoadedImage> {
67-
override fun iterator(): Iterator<NamedLoadedImage> = listOf(first, second, third).iterator()
68-
// fun toBackground(shaders: HudShader, y: Int, scale: Double): BackgroundRenderer {
69-
// var char = start
70-
// fun NamedLoadedImage.toWidth(): WidthComponent {
71-
// val c = (++char).parseChar()
72-
// val height = (image.image.height.toDouble() * scale).roundToInt()
73-
// val div = height.toDouble() / image.image.height.toDouble()
74-
// HudImpl.createBit(shaders, y + location.y) {
75-
// json.add(jsonObjectOf(
76-
// "type" to "bitmap",
77-
// "file" to "$NAME_SPACE_ENCODED:$name",
78-
// "ascent" to it,
79-
// "height" to height,
80-
// "chars" to jsonArrayOf(c)
81-
// ))
82-
// }
83-
// return WidthComponent(Component.text().content(c), (image.image.width * div).roundToInt())
84-
// }
85-
// return BackgroundRenderer(
86-
// location.x,
87-
// BackgroundRenderer.BackgroundComponent(
88-
// max,
89-
// first.toWidth(),
90-
// second.toWidth(),
91-
// third.toWidth()
92-
// )
93-
// )
94-
// }
95-
}
96-
97-
enum class BackgroundType {
98-
AUTO {
99-
override fun parse(id: String, line: Int, yamlObject: YamlObject): List<BackgroundImage> {
100-
val image = File(DATA_FOLDER.subFolder("assets"), yamlObject.get("file")
101-
.ifNull("value 'file' not set in $id")
102-
.asString()
103-
.replace('/', File.separatorChar))
104-
.ifNotExist {
105-
"This file doesn't exist: $id in $name"
106-
}
107-
.toImage()
108-
return BackgroundImage.splitOf(line, image)
109-
}
110-
}
111-
;
112-
abstract fun parse(id: String, line: Int, yamlObject: YamlObject): List<BackgroundImage>
113-
}
114-
}
16+
val location: PixelLocation,
17+
) : HudConfiguration

dist/src/main/kotlin/kr/toxicity/hud/compass/CompassType.kt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package kr.toxicity.hud.compass
22

33
import kr.toxicity.hud.api.yaml.YamlObject
4+
import kr.toxicity.hud.compass.type.CircleCompass
45
import kr.toxicity.hud.resource.GlobalResource
56
import java.io.File
67

dist/src/main/kotlin/kr/toxicity/hud/compass/CircleCompass.kt dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package kr.toxicity.hud.compass
1+
package kr.toxicity.hud.compass.type
22

33
import com.google.gson.JsonArray
44
import kr.toxicity.hud.api.component.WidthComponent
55
import kr.toxicity.hud.api.configuration.HudObjectType
66
import kr.toxicity.hud.api.player.HudPlayer
77
import kr.toxicity.hud.api.update.UpdateEvent
88
import kr.toxicity.hud.api.yaml.YamlObject
9+
import kr.toxicity.hud.compass.CompassImpl
910
import kr.toxicity.hud.equation.TEquation
1011
import kr.toxicity.hud.hud.HudImpl
1112
import kr.toxicity.hud.location.PixelLocation

dist/src/main/kotlin/kr/toxicity/hud/component/LayoutComponentContainer.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package kr.toxicity.hud.component
22

33
import kr.toxicity.hud.api.component.PixelComponent
44
import kr.toxicity.hud.api.component.WidthComponent
5-
import kr.toxicity.hud.layout.LayoutAlign
6-
import kr.toxicity.hud.layout.LayoutOffset
5+
import kr.toxicity.hud.layout.enums.LayoutAlign
6+
import kr.toxicity.hud.layout.enums.LayoutOffset
77
import kr.toxicity.hud.util.EMPTY_WIDTH_COMPONENT
88
import kr.toxicity.hud.util.toSpaceComponent
99

dist/src/main/kotlin/kr/toxicity/hud/equation/EquationPairLocation.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package kr.toxicity.hud.equation
22

33
import kr.toxicity.hud.api.yaml.YamlObject
44
import kr.toxicity.hud.location.PixelLocation
5-
import kr.toxicity.hud.image.LocationGroup
5+
import kr.toxicity.hud.location.LocationGroup
66
import kr.toxicity.hud.location.GuiLocation
77

88
class EquationPairLocation(

dist/src/main/kotlin/kr/toxicity/hud/hud/HudImpl.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kr.toxicity.hud.api.update.UpdateEvent
99
import kr.toxicity.hud.api.yaml.YamlObject
1010
import kr.toxicity.hud.configuration.HudConfiguration
1111
import kr.toxicity.hud.location.PixelLocation
12-
import kr.toxicity.hud.location.AnimationType
12+
import kr.toxicity.hud.location.animation.AnimationType
1313
import kr.toxicity.hud.manager.ConfigManagerImpl
1414
import kr.toxicity.hud.manager.LayoutManager
1515
import kr.toxicity.hud.manager.ShaderManagerImpl

0 commit comments

Comments
 (0)