Skip to content

Commit

Permalink
fix: slate titles update on change
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Nov 14, 2024
1 parent 274bafb commit 9c9e9f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ kotlin_version=2.0.21
fabric_kotlin_version=1.12.3

# mod properties
mod_version=1.9
mod_version=1.9.1
maven_group=net.mcbrawls
mod_id=slate
14 changes: 13 additions & 1 deletion src/main/kotlin/net/mcbrawls/slate/HandledSlate.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.mcbrawls.slate

import net.mcbrawls.slate.screen.SlateScreenHandler
import net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.text.Text

/**
* A slate's handled data.
Expand All @@ -21,4 +23,14 @@ data class HandledSlate<T : Slate>(
* The handler for the slate screen.
*/
val screenHandler: SlateScreenHandler<T>,
)
) {
/**
* Sends a new title for the current screen to the player.
*/
fun sendTitle(title: Text) {
val packet = OpenScreenS2CPacket(screenHandler.syncId, screenHandler.type, title)
player.networkHandler.sendPacket(packet)

screenHandler.syncState()
}
}
4 changes: 4 additions & 0 deletions src/main/kotlin/net/mcbrawls/slate/Slate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ open class Slate {
* The title of the screen handler.
*/
open var title: Text = Text.empty()
set(value) {
field = value
handledSlate?.sendTitle(value)
}

/**
* The base tile grid of this slate.
Expand Down

0 comments on commit 9c9e9f6

Please sign in to comment.