mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
forbid server to update local skin layers
This commit is contained in:
parent
aa9533712f
commit
789e8834e3
@ -14,6 +14,8 @@
|
||||
package de.bixilon.minosoft.config.profile.profiles.connection.skin
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.set.SetObserver.Companion.observedSet
|
||||
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||
import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfile
|
||||
import de.bixilon.minosoft.data.entities.entities.player.SkinParts
|
||||
@ -62,30 +64,24 @@ class SkinC(profile: ConnectionProfile) {
|
||||
var hat by BooleanDelegate(profile, true)
|
||||
|
||||
|
||||
@get:JsonIgnore val skinParts: Array<SkinParts>
|
||||
get() {
|
||||
val parts: MutableSet<SkinParts> = mutableSetOf()
|
||||
if (cape) {
|
||||
parts += SkinParts.CAPE
|
||||
}
|
||||
if (jacket) {
|
||||
parts += SkinParts.JACKET
|
||||
}
|
||||
if (leftSleeve) {
|
||||
parts += SkinParts.LEFT_SLEEVE
|
||||
}
|
||||
if (rightSleeve) {
|
||||
parts += SkinParts.RIGHT_SLEEVE
|
||||
}
|
||||
if (leftPants) {
|
||||
parts += SkinParts.LEFT_PANTS
|
||||
}
|
||||
if (rightPants) {
|
||||
parts += SkinParts.RIGHT_PANTS
|
||||
}
|
||||
if (hat) {
|
||||
parts += SkinParts.HAT
|
||||
}
|
||||
return parts.toTypedArray()
|
||||
@get:JsonIgnore val parts: MutableSet<SkinParts> by observedSet(mutableSetOf())
|
||||
|
||||
private fun updateParts(part: SkinParts, add: Boolean) {
|
||||
if (add) {
|
||||
parts += part
|
||||
} else {
|
||||
parts -= part
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
this::cape.observe(this, true) { updateParts(SkinParts.CAPE, it) }
|
||||
this::jacket.observe(this, true) { updateParts(SkinParts.JACKET, it) }
|
||||
this::leftSleeve.observe(this, true) { updateParts(SkinParts.LEFT_SLEEVE, it) }
|
||||
this::rightSleeve.observe(this, true) { updateParts(SkinParts.RIGHT_SLEEVE, it) }
|
||||
this::leftPants.observe(this, true) { updateParts(SkinParts.LEFT_PANTS, it) }
|
||||
this::rightPants.observe(this, true) { updateParts(SkinParts.RIGHT_PANTS, it) }
|
||||
this::hat.observe(this, true) { updateParts(SkinParts.HAT, it) }
|
||||
}
|
||||
}
|
||||
|
@ -82,22 +82,19 @@ abstract class PlayerEntity(
|
||||
val skinParts: MutableSet<SkinParts> by observedSet(mutableSetOf())
|
||||
|
||||
|
||||
init {
|
||||
data.observe(SKIN_PARTS_DATA) { raw: Any? ->
|
||||
if (raw == null) {
|
||||
skinParts.clear()
|
||||
return@observe
|
||||
}
|
||||
val flags = raw.toInt()
|
||||
for (part in SkinParts.VALUES) {
|
||||
if (!flags.isBitMask(part.bitmask)) {
|
||||
skinParts -= part
|
||||
}
|
||||
skinParts += part
|
||||
protected open fun updateSkinParts(flags: Int) {
|
||||
for (part in SkinParts.VALUES) {
|
||||
if (!flags.isBitMask(part.bitmask)) {
|
||||
skinParts -= part
|
||||
}
|
||||
skinParts += part
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
data.observe(SKIN_PARTS_DATA) { raw: Any? -> updateSkinParts(raw?.toInt() ?: 0) }
|
||||
}
|
||||
|
||||
@get:SynchronizedEntityData
|
||||
open val mainArm: Arms
|
||||
get() = if (data.get(MAIN_ARM_DATA, 0x00.toByte()).toInt() == 0x01) Arms.RIGHT else Arms.LEFT
|
||||
|
@ -30,6 +30,7 @@ import de.bixilon.kutil.collections.map.bi.SynchronizedBiMap
|
||||
import de.bixilon.kutil.math.interpolation.DoubleInterpolation.interpolateLinear
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.observer.set.SetObserver.Companion.observeSet
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.Axes
|
||||
@ -105,6 +106,7 @@ class LocalPlayerEntity(
|
||||
equipment.remove(EquipmentSlots.MAIN_HAND)
|
||||
equipment[EquipmentSlots.MAIN_HAND] = inventory.getHotbarSlot(it) ?: return@observe
|
||||
}
|
||||
connection.profiles.connection.skin::parts.observeSet(this, true) { skinParts += it.adds; skinParts -= it.removes }
|
||||
}
|
||||
|
||||
var openedContainer: Container? = null
|
||||
@ -593,6 +595,9 @@ class LocalPlayerEntity(
|
||||
override val pushableByFluids: Boolean
|
||||
get() = !baseAbilities.isFlying
|
||||
|
||||
|
||||
override fun updateSkinParts(flags: Int) = Unit
|
||||
|
||||
override fun tick() {
|
||||
if (connection.world[positionInfo.blockPosition.chunkPosition] == null) {
|
||||
// chunk not loaded, so we don't tick?
|
||||
|
@ -56,6 +56,7 @@ class ArmOverlay(private val renderWindow: RenderWindow) : Overlay {
|
||||
private fun poll() {
|
||||
val model = renderWindow.connection.player.model.nullCast<PlayerModel>()
|
||||
val skin = model?.skin
|
||||
// TODO: check skin parts
|
||||
if (this.model == model && this.skin == skin) {
|
||||
return
|
||||
}
|
||||
|
@ -44,15 +44,6 @@ class ClientSettingsManager(
|
||||
profile::mainArm.observe(this) { sendClientSettings() }
|
||||
profile::playerListing.observe(this) { sendClientSettings() }
|
||||
|
||||
val skin = profile.skin
|
||||
skin::cape.observe(this) { sendClientSettings() }
|
||||
skin::jacket.observe(this) { sendClientSettings() }
|
||||
skin::leftSleeve.observe(this) { sendClientSettings() }
|
||||
skin::rightSleeve.observe(this) { sendClientSettings() }
|
||||
skin::leftPants.observe(this) { sendClientSettings() }
|
||||
skin::rightPants.observe(this) { sendClientSettings() }
|
||||
skin::hat.observe(this) { sendClientSettings() }
|
||||
|
||||
profile::language.observe(this) { sendLanguage() }
|
||||
connection.profiles.eros.general::language.observe(this) { sendLanguage() }
|
||||
}
|
||||
@ -72,15 +63,17 @@ class ClientSettingsManager(
|
||||
if (connection.network.state != ProtocolStates.PLAY) {
|
||||
return
|
||||
}
|
||||
connection.sendPacket(SettingsC2SP(
|
||||
locale = language,
|
||||
chatColors = connection.profiles.gui.chat.chatColors,
|
||||
viewDistance = connection.profiles.block.viewDistance,
|
||||
chatMode = connection.profiles.gui.chat.chatMode,
|
||||
skinParts = profile.skin.skinParts,
|
||||
mainArm = profile.mainArm,
|
||||
disableTextFiltering = !connection.profiles.gui.chat.textFiltering,
|
||||
allowListing = profile.playerListing,
|
||||
))
|
||||
connection.sendPacket(
|
||||
SettingsC2SP(
|
||||
locale = language,
|
||||
chatColors = connection.profiles.gui.chat.chatColors,
|
||||
viewDistance = connection.profiles.block.viewDistance,
|
||||
chatMode = connection.profiles.gui.chat.chatMode,
|
||||
skinParts = profile.skin.parts.toTypedArray(),
|
||||
mainArm = profile.mainArm,
|
||||
disableTextFiltering = !connection.profiles.gui.chat.textFiltering,
|
||||
allowListing = profile.playerListing,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user