mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-10-01 05:08:08 +02:00
trying to fix 1.7
This commit is contained in:
parent
883c88727b
commit
770bcc40a9
@ -154,6 +154,7 @@ fun writeFlushClose(ch: Channel, obj: Any) {
|
||||
}
|
||||
|
||||
fun readRemainingBytes(byteBuf: ByteBuf) = Type.REMAINING_BYTES.read(byteBuf)
|
||||
fun ByteBuf.readByteArray(length: Int) = ByteArray(length).also { readBytes(it) }
|
||||
|
||||
suspend fun hasJoined(username: String, hash: String): JsonObject {
|
||||
return httpClient.get(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.creeper123123321.viaaas.packet.login
|
||||
|
||||
import com.github.creeper123123321.viaaas.packet.Packet
|
||||
import com.github.creeper123123321.viaaas.readByteArray
|
||||
import io.netty.buffer.ByteBuf
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion
|
||||
import us.myles.ViaVersion.api.type.Type
|
||||
@ -21,8 +22,8 @@ class CryptoRequest : Packet {
|
||||
token = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
} else {
|
||||
publicKey = KeyFactory.getInstance("RSA")
|
||||
.generatePublic(X509EncodedKeySpec(ByteArray(byteBuf.readUnsignedShort()).also { byteBuf.readBytes(it) }))
|
||||
token = ByteArray(byteBuf.readUnsignedShort()).also { byteBuf.readBytes(it) }
|
||||
.generatePublic(X509EncodedKeySpec(byteBuf.readByteArray(byteBuf.readUnsignedShort())))
|
||||
token = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.creeper123123321.viaaas.packet.login
|
||||
|
||||
import com.github.creeper123123321.viaaas.packet.Packet
|
||||
import com.github.creeper123123321.viaaas.readByteArray
|
||||
import io.netty.buffer.ByteBuf
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion
|
||||
import us.myles.ViaVersion.api.type.Type
|
||||
@ -14,8 +15,8 @@ class CryptoResponse : Packet {
|
||||
encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
encryptedToken = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
} else {
|
||||
encryptedKey = ByteArray(byteBuf.readUnsignedShort()).also { byteBuf.readBytes(it) }
|
||||
encryptedToken = ByteArray(byteBuf.readUnsignedShort()).also { byteBuf.readBytes(it) }
|
||||
encryptedKey = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
encryptedToken = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.creeper123123321.viaaas.packet.play
|
||||
|
||||
import com.github.creeper123123321.viaaas.packet.Packet
|
||||
import com.github.creeper123123321.viaaas.readByteArray
|
||||
import com.github.creeper123123321.viaaas.readRemainingBytes
|
||||
import io.netty.buffer.ByteBuf
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion
|
||||
@ -13,7 +14,7 @@ class PluginMessage : Packet {
|
||||
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
channel = Type.STRING.read(byteBuf)
|
||||
data = if (protocolVersion <= ProtocolVersion.v1_7_6.version) {
|
||||
ByteArray(readExtendedForgeShort(byteBuf)).also { byteBuf.readBytes(it) }
|
||||
byteBuf.readByteArray(readExtendedForgeShort(byteBuf))
|
||||
} else {
|
||||
readRemainingBytes(byteBuf)
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.github.creeper123123321.viaaas.protocol.id47toid5.chunks
|
||||
|
||||
import com.github.creeper123123321.viaaas.readByteArray
|
||||
import com.github.creeper123123321.viaaas.readRemainingBytes
|
||||
import io.netty.buffer.ByteBufAllocator
|
||||
import io.netty.buffer.Unpooled
|
||||
|
||||
class Chunk1_8to1_7_6_10(
|
||||
data: ByteArray?,
|
||||
@ -10,7 +12,7 @@ class Chunk1_8to1_7_6_10(
|
||||
private val skyLight: Boolean,
|
||||
private val groundUp: Boolean
|
||||
) {
|
||||
var storageArrays = arrayOfNulls<ExtendedBlockStorage>(16)
|
||||
var storageSections = arrayOfNulls<ExtendedBlockStorage>(16)
|
||||
var blockBiomeArray = ByteArray(256)
|
||||
|
||||
fun filterChunk(storageArray: ExtendedBlockStorage?, i: Int) =
|
||||
@ -21,7 +23,7 @@ class Chunk1_8to1_7_6_10(
|
||||
val buf = ByteBufAllocator.DEFAULT.buffer()
|
||||
try {
|
||||
var finalSize = 0
|
||||
val filteredChunks = storageArrays.filterIndexed { i, value -> filterChunk(value, i) }.filterNotNull()
|
||||
val filteredChunks = storageSections.filterIndexed { i, value -> filterChunk(value, i) }.filterNotNull()
|
||||
filteredChunks.forEach {
|
||||
val blockIds = it.blockLSBArray
|
||||
val nibblearray = it.metadataArray
|
||||
@ -56,58 +58,48 @@ class Chunk1_8to1_7_6_10(
|
||||
}
|
||||
|
||||
init {
|
||||
var dataSize = 0
|
||||
for (i in storageArrays.indices) {
|
||||
val input = Unpooled.wrappedBuffer(data)
|
||||
for (i in storageSections.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0) {
|
||||
if (storageArrays[i] == null) storageArrays[i] = ExtendedBlockStorage(i shl 4, skyLight)
|
||||
val blockIds = storageArrays[i]!!.blockLSBArray
|
||||
System.arraycopy(data, dataSize, blockIds, 0, blockIds.size)
|
||||
dataSize += blockIds.size
|
||||
} else if (storageArrays[i] != null && groundUp) {
|
||||
storageArrays[i] = null
|
||||
val storageSection = storageSections.getOrElse(i) {
|
||||
ExtendedBlockStorage(i shl 4, skyLight).also { storageSections[i] = it }
|
||||
}!!
|
||||
storageSection.blockLSBArray = input.readByteArray(4096)
|
||||
} else if (storageSections[i] != null && groundUp) {
|
||||
storageSections[i] = null
|
||||
}
|
||||
}
|
||||
for (i in storageArrays.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
|
||||
val nibblearray = storageArrays[i]!!.metadataArray
|
||||
System.arraycopy(data, dataSize, nibblearray.handle, 0, nibblearray.handle.size)
|
||||
dataSize += nibblearray.handle.size
|
||||
for (i in storageSections.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageSections[i] != null) {
|
||||
storageSections[i]!!.metadataArray.handle = input.readByteArray(4096 / 2)
|
||||
}
|
||||
}
|
||||
for (i in storageArrays.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
|
||||
val nibblearray = storageArrays[i]!!.blocklightArray
|
||||
System.arraycopy(data, dataSize, nibblearray.handle, 0, nibblearray.handle.size)
|
||||
dataSize += nibblearray.handle.size
|
||||
for (i in storageSections.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageSections[i] != null) {
|
||||
storageSections[i]!!.blocklightArray.handle = input.readByteArray(4096 / 2)
|
||||
}
|
||||
}
|
||||
if (skyLight) {
|
||||
for (i in storageArrays.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
|
||||
val nibblearray = storageArrays[i]!!.skylightArray
|
||||
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray.handle.size)
|
||||
dataSize += nibblearray.handle.size
|
||||
for (i in storageSections.indices) {
|
||||
if (primaryBitMask and 1 shl i != 0 && storageSections[i] != null) {
|
||||
storageSections[i]!!.skylightArray!!.handle = input.readByteArray(4096 / 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i in storageArrays.indices) {
|
||||
for (i in storageSections.indices) {
|
||||
if (addBitMask and 1 shl i != 0) {
|
||||
if (storageArrays[i] == null) {
|
||||
dataSize += 2048
|
||||
if (storageSections[i] == null) {
|
||||
input.skipBytes(2048)
|
||||
} else {
|
||||
var nibblearray = storageArrays[i]!!.blockMSBArray
|
||||
if (nibblearray == null) {
|
||||
nibblearray = storageArrays[i]!!.createBlockMSBArray()
|
||||
var msbArray = storageSections[i]!!.blockMSBArray ?: storageSections[i]!!.createBlockMSBArray()
|
||||
msbArray!!.handle = input.readByteArray(4096 / 2)
|
||||
}
|
||||
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray.handle.size)
|
||||
dataSize += nibblearray.handle.size
|
||||
}
|
||||
} else if (groundUp && storageArrays[i] != null && storageArrays[i]!!.blockMSBArray != null) {
|
||||
storageArrays[i]!!.clearMSBArray()
|
||||
} else if (groundUp && storageSections[i] != null && storageSections[i]!!.blockMSBArray != null) {
|
||||
storageSections[i]!!.clearMSBArray()
|
||||
}
|
||||
}
|
||||
if (groundUp) {
|
||||
System.arraycopy(data, dataSize, blockBiomeArray, 0, blockBiomeArray.size)
|
||||
blockBiomeArray = input.readByteArray(256)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user