Skip to content

Commit

Permalink
fix: not transforming entity-data where DataValue is NMS Component
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Aug 23, 2024
1 parent 88fafa6 commit 7828da4
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.jeff_media.morepersistentdatatypes.DataType
import com.mineinabyss.emojy.*
import com.mineinabyss.emojy.nms.IEmojyNMSHandler
import com.mineinabyss.idofront.items.editItemMeta
import com.mineinabyss.idofront.messaging.logError
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.textcomponents.miniMsg
import com.mineinabyss.idofront.textcomponents.serialize
Expand All @@ -20,12 +21,14 @@ import net.minecraft.core.NonNullList
import net.minecraft.network.Connection
import net.minecraft.network.chat.ChatType
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.MutableComponent
import net.minecraft.network.protocol.Packet
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket
import net.minecraft.network.protocol.common.ClientboundServerLinksPacket
import net.minecraft.network.protocol.game.*
import net.minecraft.network.syncher.EntityDataSerializer
import net.minecraft.network.syncher.EntityDataSerializers
import net.minecraft.network.syncher.SynchedEntityData
import net.minecraft.world.item.ItemStack
import org.bukkit.NamespacedKey
Expand Down Expand Up @@ -79,11 +82,15 @@ class EmojyNMSHandler(emojy: EmojyPlugin) : IEmojyNMSHandler {
is ClientboundResourcePackPushPacket -> ClientboundResourcePackPushPacket(packet.id, packet.url, packet.hash, packet.required, packet.prompt.map { it.transformEmotes(connection.locale()) })
is ClientboundDisconnectPacket -> ClientboundDisconnectPacket(packet.reason.transformEmotes(connection.locale()))
is ClientboundSetEntityDataPacket -> ClientboundSetEntityDataPacket(packet.id, packet.packedItems.map {
(it.value as? AdventureComponent)?.let { value ->
SynchedEntityData.DataValue(it.id, it.serializer as EntityDataSerializer<AdventureComponent>,
when (val value = it.value) {
is AdventureComponent -> SynchedEntityData.DataValue(it.id, it.serializer as EntityDataSerializer<AdventureComponent>,
AdventureComponent(value.`adventure$component`().transformEmotes(connection.locale()))
)
} ?: it
is Component -> SynchedEntityData.DataValue(it.id, EntityDataSerializers.COMPONENT,
value.transformEmotes(connection.locale())
)
else -> it
}
})
is ClientboundContainerSetSlotPacket -> ClientboundContainerSetSlotPacket(packet.containerId, packet.stateId, packet.slot, packet.item.transformItemNameLore(connection.player.bukkitEntity))
is ClientboundContainerSetContentPacket -> ClientboundContainerSetContentPacket(
Expand Down

0 comments on commit 7828da4

Please sign in to comment.