mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -04:00
fix parsing bug in chat component api
This commit is contained in:
parent
34f15d2baf
commit
2e9e20a5cf
@ -133,11 +133,21 @@ class BaseComponent : ChatComponent {
|
||||
}
|
||||
|
||||
constructor(translator: Translator? = null, parent: TextComponent? = null, json: Map<String, Any>, restrictedMode: Boolean = false) {
|
||||
val currentParent: TextComponent?
|
||||
var currentParent: TextComponent? = null
|
||||
var currentText = ""
|
||||
|
||||
fun parseExtra() {
|
||||
json["extra"]?.listCast()?.let {
|
||||
for (data in it) {
|
||||
parts += ChatComponent.of(data, translator, currentParent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json["text"]?.nullCast<String>()?.let {
|
||||
if (it.indexOf(ProtocolDefinition.TEXT_COMPONENT_SPECIAL_PREFIX_CHAR) != -1) {
|
||||
this += ChatComponent.of(it, translator, parent)
|
||||
parseExtra()
|
||||
return
|
||||
}
|
||||
currentText = it
|
||||
@ -170,13 +180,7 @@ class BaseComponent : ChatComponent {
|
||||
}
|
||||
currentParent = textComponent
|
||||
|
||||
|
||||
json["extra"]?.listCast()?.let {
|
||||
for (data in it) {
|
||||
parts += ChatComponent.of(data, translator, currentParent)
|
||||
}
|
||||
}
|
||||
|
||||
parseExtra()
|
||||
|
||||
json["translate"]?.nullCast<String>()?.let {
|
||||
val with: MutableList<Any> = mutableListOf()
|
||||
|
@ -37,7 +37,7 @@ open class TextComponent(
|
||||
var clickEvent: ClickEvent? = null,
|
||||
var hoverEvent: HoverEvent? = null,
|
||||
) : ChatComponent, TextStyle {
|
||||
override var message: String = message?.toString() ?: "null"
|
||||
override var message: String = message?.toString()?.replace(ProtocolDefinition.TEXT_COMPONENT_SPECIAL_PREFIX_CHAR, '&') ?: "null"
|
||||
|
||||
fun obfuscate(): TextComponent {
|
||||
formatting.add(PreChatFormattingCodes.OBFUSCATED)
|
||||
|
@ -131,7 +131,6 @@ class HotbarHealthElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Poll
|
||||
atlasManager["minecraft:hardcore_half_frozen_heart"],
|
||||
),
|
||||
)
|
||||
private val whiteHeartContainer = atlasManager["minecraft:white_heart_container"]!!
|
||||
private val blackHeartContainer = atlasManager["minecraft:black_heart_container"]!!
|
||||
|
||||
private var hardcode = false
|
||||
@ -150,7 +149,7 @@ class HotbarHealthElement(hudRenderer: HUDRenderer) : Element(hudRenderer), Poll
|
||||
private var rows = 0
|
||||
|
||||
override fun forceRender(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?): Int {
|
||||
// ToDo: Damage animation, regeneration, caching, stacking
|
||||
// ToDo: Damage animation, regeneration, caching, stacking (and eventual text replace)
|
||||
for (heart in 0 until totalMaxHearts) {
|
||||
val row = heart / HEARTS_PER_ROW
|
||||
val column = heart % HEARTS_PER_ROW
|
||||
|
@ -44,6 +44,11 @@ class HealthSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun check(connection: PlayConnection) {
|
||||
check(hunger in 0..20)
|
||||
check(saturation in 0.0..20.0)
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Health set (hp=$hp, hunger=$hunger, saturation=$saturation)" }
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.registries.particle.ParticleType
|
||||
import de.bixilon.minosoft.data.registries.particle.data.ParticleData
|
||||
import de.bixilon.minosoft.modding.event.events.ParticleSpawnEvent
|
||||
@ -54,6 +55,9 @@ class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
if (Minosoft.config.config.general.reduceProtocolLog) {
|
||||
return
|
||||
}
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Particle (type=$type, longDistance=$longDistance, position=$position, offset=$offset, speed=$speed, count=$count, data=$data)" }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user