update viaver, fix deprecations

This commit is contained in:
creeper123123321 2022-07-17 15:19:33 -03:00
parent 9b7821b704
commit 9a99fb4620
3 changed files with 12 additions and 12 deletions

View File

@ -57,8 +57,8 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
val vvVer = "4.4.0-1.19.1-pre4-SNAPSHOT"
val vbVer = "4.4.0-1.19.1-pre4-SNAPSHOT"
val vvVer = "4.4.0-1.19.1-pre5-SNAPSHOT"
val vbVer = "4.4.0-1.19.1-pre5-SNAPSHOT"
val vrVer = "d189537"
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }

View File

@ -17,7 +17,7 @@ class LoginSuccess : Packet {
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
id = when {
protocolVersion >= ProtocolVersion.v1_16.version -> {
Type.UUID_INT_ARRAY.read(byteBuf)
Type.UUID.read(byteBuf)
}
protocolVersion >= ProtocolVersion.v1_7_6.version || protocolVersion == 1 -> {
UUID.fromString(Type.STRING.read(byteBuf))
@ -33,7 +33,7 @@ class LoginSuccess : Packet {
override fun encode(byteBuf: ByteBuf, protocolVersion: Int) {
when {
protocolVersion >= ProtocolVersion.v1_16.version -> {
Type.UUID_INT_ARRAY.write(byteBuf, id)
Type.UUID.write(byteBuf, id)
}
protocolVersion >= ProtocolVersion.v1_7_6.version || protocolVersion == 1 -> {
Type.STRING.write(byteBuf, id.toString())

View File

@ -19,8 +19,7 @@ object MetadataRewriter {
}
entry.setId(metaIndex.newIndex)
entry.setMetaTypeUnsafe(metaIndex.newType)
when (metaIndex.newType) {
val newValue = when (metaIndex.newType) {
MetaType1_8.Byte -> {
var byteValue = (oldValue as Number).toByte()
@ -28,15 +27,16 @@ object MetadataRewriter {
val cape = byteValue.toInt() == 2
byteValue = (if (cape) 127 else 125).toByte()
}
entry.value = byteValue
byteValue
}
MetaType1_8.Int -> entry.value = (oldValue as Number).toInt()
MetaType1_8.Short -> entry.value = (oldValue as Number).toShort()
MetaType1_8.Float -> entry.value = (oldValue as Number).toFloat()
MetaType1_8.String -> entry.value = oldValue.toString()
MetaType1_8.Slot, MetaType1_8.Position, MetaType1_8.Rotation -> entry.value = oldValue
MetaType1_8.Int -> (oldValue as Number).toInt()
MetaType1_8.Short -> (oldValue as Number).toShort()
MetaType1_8.Float -> (oldValue as Number).toFloat()
MetaType1_8.String -> oldValue.toString()
MetaType1_8.Slot, MetaType1_8.Position, MetaType1_8.Rotation -> oldValue
else -> throw Exception("unknown metatype ${metaIndex.newType}")
}
entry.setTypeAndValue(metaIndex.newType, newValue)
} catch (e: Exception) {
if (!Via.getPlatform().conf.isSuppressMetadataErrors) {
Via.getPlatform().logger.warning("Metadata Exception: $e $list")