mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
network: fix some null in pre-flattening versions
This commit is contained in:
parent
a0736183aa
commit
823cd21a07
@ -52,7 +52,7 @@ class EntityPlayerS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
|
||||
val rotation = buffer.readEntityRotation()
|
||||
if (buffer.versionId < ProtocolVersions.V_15W31A) {
|
||||
buffer.connection.registries.item[buffer.readUnsignedShort()] // current item
|
||||
buffer.connection.registries.item.getOrNull(buffer.readUnsignedShort()) // current item
|
||||
}
|
||||
|
||||
var data: Int2ObjectOpenHashMap<Any?>? = null
|
||||
|
@ -141,20 +141,21 @@ class PlayInByteBuffer : InByteBuffer {
|
||||
fun readItemStack(): ItemStack? {
|
||||
if (versionId < V_1_13_2_PRE1) {
|
||||
val id = readShort().toInt()
|
||||
if (id == -1) {
|
||||
if (id <= 0) {
|
||||
return null
|
||||
}
|
||||
val count = readUnsignedByte()
|
||||
var metaData = 0
|
||||
var meta = 0
|
||||
if (!connection.version.flattened) {
|
||||
metaData = readUnsignedShort()
|
||||
meta = readUnsignedShort()
|
||||
}
|
||||
val nbt = readNBT()?.toMutableJsonObject()
|
||||
val nbt = readNBTTag()?.toMutableJsonObject()
|
||||
val item = connection.registries.item.getOrNull(id shl 16 or meta) ?: return null
|
||||
return ItemStackUtil.of(
|
||||
item = connection.registries.item[id shl 16 or metaData],
|
||||
item = item,
|
||||
connection = connection,
|
||||
count = count,
|
||||
durability = metaData,
|
||||
durability = meta,
|
||||
nbt = nbt ?: mutableMapOf(),
|
||||
)
|
||||
}
|
||||
|
@ -59,6 +59,10 @@ class Version(
|
||||
PacketDirections.SERVER_TO_CLIENT -> s2c
|
||||
}
|
||||
|
||||
operator fun compareTo(version: Version): Int {
|
||||
return this.versionId.compareTo(version.versionId)
|
||||
}
|
||||
|
||||
val flattened: Boolean get() = versionId >= V_17W47A
|
||||
val hasOffhand: Boolean get() = versionId >= V_15W31A
|
||||
val maxPacketLength get() = if (versionId < V_1_17_1_RC2) 1 shl 21 else 1 shl 23
|
||||
|
Loading…
x
Reference in New Issue
Block a user