Skip to content

Commit 4faf59b

Browse files
committed
wrath visuals, ability screen tweak
1 parent 5ac0dc6 commit 4faf59b

File tree

8 files changed

+107
-0
lines changed

8 files changed

+107
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package dev.sterner.client.event
2+
3+
import com.mojang.blaze3d.systems.RenderSystem
4+
import com.sammy.malum.common.components.MalumComponents
5+
import com.sammy.malum.common.components.MalumPlayerDataComponent
6+
import dev.sterner.VoidBound
7+
import dev.sterner.api.item.ItemAbility
8+
import dev.sterner.api.util.VoidBoundItemUtils
9+
import dev.sterner.registry.VoidBoundComponentRegistry
10+
import net.minecraft.client.Minecraft
11+
import net.minecraft.client.gui.GuiGraphics
12+
import net.minecraft.client.renderer.GameRenderer
13+
import net.minecraft.util.Mth
14+
import net.minecraft.world.entity.ai.attributes.Attributes
15+
import team.lodestar.lodestone.systems.rendering.VFXBuilders
16+
import kotlin.math.max
17+
import kotlin.math.min
18+
19+
object WrathHudRenderEvent {
20+
21+
fun renderWrathBar(guiGraphics: GuiGraphics, partialTick: Float) {
22+
val minecraft = Minecraft.getInstance()
23+
if (minecraft.player == null) {
24+
return
25+
}
26+
27+
val comp = VoidBoundComponentRegistry.VOID_BOUND_PLAYER_ITEM_ABILITY_COMPONENT.get(minecraft.player!!)
28+
29+
val wrath = comp.getWrath()
30+
31+
val ability = VoidBoundItemUtils.getActiveAbility(minecraft.player!!.mainHandItem)
32+
if (ability != ItemAbility.FINALE && ability != ItemAbility.OPENER) {
33+
return
34+
}
35+
36+
if (wrath <= 0) {
37+
return
38+
}
39+
40+
val window = minecraft.window
41+
val player = minecraft.player!!
42+
43+
if (player.isCreative() || player.isSpectator()) {
44+
return
45+
}
46+
47+
val absorb = Mth.ceil(player.absorptionAmount).toFloat()
48+
val maxHealth: Float = player.getAttribute(Attributes.MAX_HEALTH)!!.getValue().toFloat()
49+
val armor: Float = player.getAttribute(Attributes.ARMOR)!!.getValue().toFloat()
50+
val left = window.guiScaledWidth / 2 - 89
51+
var top = window.guiScaledHeight - 45
52+
if (armor == 0.0f) {
53+
top += 4
54+
}
55+
val soulWardHandler = MalumComponents.MALUM_PLAYER_COMPONENT[player].soulWardHandler
56+
val soulWard = if(soulWardHandler.soulWard > 0) -9 else 0
57+
58+
val poseStack = guiGraphics.pose()
59+
val healthRows = Mth.ceil((maxHealth + absorb) / 2.0f / 10.0f)
60+
val rowHeight = max((10 - (healthRows - 2)).toDouble(), 3.0).toInt() + soulWard
61+
62+
poseStack.pushPose()
63+
RenderSystem.setShaderTexture(0, VoidBound.id("textures/gui/wrath_empty.png"))
64+
RenderSystem.depthMask(true)
65+
RenderSystem.enableBlend()
66+
RenderSystem.defaultBlendFunc()
67+
val builder = VFXBuilders.createScreen().setPosColorTexDefaultFormat()
68+
.setShader { GameRenderer.getPositionColorTexShader() }
69+
70+
for (i in 0 until 10) {
71+
val row = (i.toFloat() / 10.0f).toInt()
72+
val x = left + i % 10 * 8
73+
val y = top - row * 4 + rowHeight * 2 - 15
74+
builder.setPositionWithWidth((x - 2).toFloat(), (y - 2).toFloat(), 9f, 9f)
75+
.setUVWithWidth(0f,0f,9f,9f,9f,9f)
76+
.draw(poseStack)
77+
}
78+
79+
RenderSystem.setShaderTexture(0, VoidBound.id("textures/gui/wrath_full.png"))
80+
for (i in 0 until wrath) {
81+
val row = (i.toFloat() / 10.0f).toInt()
82+
val x = left + i % 10 * 8
83+
val y = top - row * 4 + rowHeight * 2 - 15
84+
builder.setPositionWithWidth((x - 2).toFloat(), (y - 2).toFloat(), 9f, 9f)
85+
.setUVWithWidth(0f,0f,9f,9f,9f,9f)
86+
.draw(poseStack)
87+
}
88+
89+
RenderSystem.depthMask(true)
90+
RenderSystem.disableBlend()
91+
poseStack.popPose()
92+
}
93+
}

src/main/kotlin/dev/sterner/client/screen/ItemAbilityScreen.kt

+9
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import dev.sterner.networking.AbilityUpdatePacket
88
import dev.sterner.registry.VoidBoundComponentRegistry
99
import dev.sterner.registry.VoidBoundItemRegistry
1010
import dev.sterner.registry.VoidBoundPacketRegistry
11+
import dev.sterner.registry.VoidBoundTags
1112
import net.minecraft.client.Minecraft
1213
import net.minecraft.client.gui.GuiGraphics
1314
import net.minecraft.client.gui.screens.Screen
1415
import net.minecraft.network.chat.Component
16+
import net.minecraft.world.entity.EquipmentSlot
1517
import net.minecraft.world.item.ItemStack
1618

1719
class ItemAbilityScreen(var stack: ItemStack) : Screen(Component.literal("Ability Selection")) {
@@ -66,6 +68,13 @@ class ItemAbilityScreen(var stack: ItemStack) : Screen(Component.literal("Abilit
6668
if (abilities?.isEmpty() == true) {
6769
return
6870
}
71+
val player = Minecraft.getInstance().player ?: return
72+
73+
val hasHand = player.mainHandItem.`is`(VoidBoundTags.ITEM_WITH_ABILITY)
74+
val hasCrown = player.getItemBySlot(EquipmentSlot.HEAD).`is`(VoidBoundTags.ITEM_WITH_ABILITY)
75+
if (!hasHand && !hasCrown) {
76+
return
77+
}
6978

7079
val matrixStack = guiGraphics.pose()
7180
val mainWindow = minecraft!!.window

src/main/kotlin/dev/sterner/common/components/VoidBoundPlayerItemAbilityComponent.kt

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class VoidBoundPlayerItemAbilityComponent(private val player: Player) : AutoSync
8484
sync()
8585
}
8686

87+
fun getWrath(): Int{
88+
return wrathCounter
89+
}
90+
8791
/**
8892
* if wrath is not maxed out and target has more than 95% health, increase wrath and increase the damage
8993
*/

src/main/kotlin/dev/sterner/registry/VoidBoundEvents.kt

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ object VoidBoundEvents {
8686
HudRenderCallback.EVENT.register(RiftHudRenderEvent::spiritRiftHud)
8787
HudRenderCallback.EVENT.register(SpiritJarHudRenderEvent::spiritJarHud)
8888
HudRenderCallback.EVENT.register(ThoughtsTextHudRenderEvent::renderThoughts)
89+
HudRenderCallback.EVENT.register(WrathHudRenderEvent::renderWrathBar)
8990
ClientTickEvents.END_CLIENT_TICK.register(ClientTickHandler::clientTickEnd)
9091
ClientTickEvents.END_CLIENT_TICK.register {
9192
VoidBoundClient.ITEM_ABILITY_HANDLER.tick()
Loading
Loading

0 commit comments

Comments
 (0)