Skip to content

Commit

Permalink
fix: Pickaxe ability cooldown not rendering properly
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Nov 10, 2024
1 parent d1241fb commit 72fed8b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/features/mining/PickaxeAbility.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ object PickaxeAbility : FirmamentFeature {

@Subscribe
fun onProfileSwitch(event: ProfileSwitchEvent) {
lastUsage.clear()
lastUsage.entries.removeIf {
it.value < lobbyJoinTime
}
}

val abilityUsePattern = Pattern.compile("You used your (?<name>.*) Pickaxe Ability!")
val fuelPattern = Pattern.compile("Fuel: .*/(?<maxFuel>$SHORT_NUMBER_FORMAT)")
val pickaxeAbilityCooldownPattern = Pattern.compile("Your pickaxe ability is on cooldown for (?<remainingCooldown>$TIME_PATTERN)\\.")
val pickaxeAbilityCooldownPattern =
Pattern.compile("Your pickaxe ability is on cooldown for (?<remainingCooldown>$TIME_PATTERN)\\.")

data class PickaxeAbilityData(
val name: String,
Expand Down
20 changes: 17 additions & 3 deletions src/main/kotlin/util/render/DrawContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.RenderLayer.MultiPhaseParameters
import net.minecraft.client.render.RenderPhase
import net.minecraft.client.render.VertexFormat
import net.minecraft.client.render.VertexFormat.DrawMode
import net.minecraft.client.render.VertexFormats
import net.minecraft.util.Identifier
import net.minecraft.util.TriState
Expand All @@ -22,13 +23,26 @@ object GuiRenderLayers {
val GUI_TEXTURED_NO_DEPTH = Util.memoize<Identifier, RenderLayer> { texture: Identifier ->
RenderLayer.of("firmament_gui_textured_no_depth",
VertexFormats.POSITION_TEXTURE_COLOR,
VertexFormat.DrawMode.QUADS,
RenderLayer.CUTOUT_BUFFER_SIZE,
DrawMode.QUADS,
DEFAULT_BUFFER_SIZE,
MultiPhaseParameters.builder()
.texture(RenderPhase.Texture(texture, TriState.FALSE, false))
.program(RenderPhase.POSITION_TEXTURE_COLOR_PROGRAM)
.transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY)
.depthTest(RenderPhase.ALWAYS_DEPTH_TEST)
.depthTest(RenderPhase.ALWAYS_DEPTH_TEST)
.build(false))
}
val GUI_TEXTURED_TRIS = Util.memoize { texture: Identifier ->
RenderLayer.of("firmament_gui_textured_overlay_tris",
VertexFormats.POSITION_TEXTURE_COLOR,
DrawMode.TRIANGLES,
DEFAULT_BUFFER_SIZE,
MultiPhaseParameters.builder()
.texture(RenderPhase.Texture(texture, TriState.DEFAULT, false))
.program(RenderPhase.POSITION_TEXTURE_COLOR_PROGRAM)
.transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY)
.depthTest(RenderPhase.ALWAYS_DEPTH_TEST)
.writeMaskState(RenderPhase.COLOR_MASK)
.build(false))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/util/render/RenderCircleProgress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object RenderCircleProgress {
) {
RenderSystem.enableBlend()
drawContext.draw {
val bufferBuilder = it.getBuffer(RenderLayer.getGuiTexturedOverlay(texture))
val bufferBuilder = it.getBuffer(GuiRenderLayers.GUI_TEXTURED_TRIS.apply(texture))
val matrix: Matrix4f = drawContext.matrices.peek().positionMatrix

val corners = listOf(
Expand Down

0 comments on commit 72fed8b

Please sign in to comment.