mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
netty, exceptions, packets: ton of improvements
This commit is contained in:
parent
ce54cd86b5
commit
1389705adb
@ -56,5 +56,5 @@ class Version(
|
|||||||
|
|
||||||
val flattened: Boolean = versionId >= ProtocolDefinition.FLATTING_VERSION_ID
|
val flattened: Boolean = versionId >= ProtocolDefinition.FLATTING_VERSION_ID
|
||||||
val hasOffhand: Boolean = versionId >= V_15W31A
|
val hasOffhand: Boolean = versionId >= V_15W31A
|
||||||
val maxPacketLength = (sortingId < ProtocolVersions.V_1_17_1_RC2).decide(1 shl 21, 1 shl 23)
|
val maxPacketLength = (versionId < ProtocolVersions.V_1_17_1_RC2).decide(1 shl 21, 1 shl 23)
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.protocol.network.network.client
|
package de.bixilon.minosoft.protocol.network.network.client
|
||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
|
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||||
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||||
@ -52,8 +53,8 @@ class NettyClient(
|
|||||||
channel.pipeline().remove(PacketDeflater.NAME)
|
channel.pipeline().remove(PacketDeflater.NAME)
|
||||||
} else {
|
} else {
|
||||||
// enable or update
|
// enable or update
|
||||||
val delater = channel.pipeline()[PacketDeflater.NAME]?.nullCast<PacketDeflater>()
|
val deflater = channel.pipeline()[PacketDeflater.NAME]?.nullCast<PacketDeflater>()
|
||||||
if (delater == null) {
|
if (deflater == null) {
|
||||||
channel.pipeline().addAfter(LengthDecoder.NAME, PacketDeflater.NAME, PacketDeflater())
|
channel.pipeline().addAfter(LengthDecoder.NAME, PacketDeflater.NAME, PacketDeflater())
|
||||||
}
|
}
|
||||||
val inflater = channel.pipeline()[PacketInflater.NAME]?.nullCast<PacketInflater>()
|
val inflater = channel.pipeline()[PacketInflater.NAME]?.nullCast<PacketInflater>()
|
||||||
@ -69,8 +70,8 @@ class NettyClient(
|
|||||||
private var channel: Channel? = null
|
private var channel: Channel? = null
|
||||||
|
|
||||||
fun connect(address: ServerAddress) {
|
fun connect(address: ServerAddress) {
|
||||||
// val workerGroup = NioEventLoopGroup(DefaultThreadPool.threadCount - 1, DefaultThreadPool)
|
val workerGroup = NioEventLoopGroup(DefaultThreadPool.threadCount - 1, DefaultThreadPool)
|
||||||
val workerGroup = NioEventLoopGroup()
|
// val workerGroup = NioEventLoopGroup()
|
||||||
val bootstrap = Bootstrap()
|
val bootstrap = Bootstrap()
|
||||||
.group(workerGroup)
|
.group(workerGroup)
|
||||||
.channel(NioSocketChannel::class.java)
|
.channel(NioSocketChannel::class.java)
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.protocol.network.network.client
|
package de.bixilon.minosoft.protocol.network.network.client
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.pipeline.PacketHandler
|
import de.bixilon.minosoft.protocol.network.network.client.pipeline.ClientPacketHandler
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.pipeline.ExceptionHandler
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding.PacketDecoder
|
import de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding.PacketDecoder
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding.PacketEncoder
|
import de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding.PacketEncoder
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.pipeline.length.LengthDecoder
|
import de.bixilon.minosoft.protocol.network.network.client.pipeline.length.LengthDecoder
|
||||||
@ -35,10 +36,12 @@ class NetworkPipeline(private val client: NettyClient) : ChannelInitializer<Sock
|
|||||||
|
|
||||||
pipeline.addLast(LengthDecoder.NAME, LengthDecoder(maxLength))
|
pipeline.addLast(LengthDecoder.NAME, LengthDecoder(maxLength))
|
||||||
pipeline.addLast(PacketDecoder.NAME, PacketDecoder(client))
|
pipeline.addLast(PacketDecoder.NAME, PacketDecoder(client))
|
||||||
pipeline.addLast(PacketHandler.NAME, PacketHandler(client.connection))
|
pipeline.addLast(ClientPacketHandler.NAME, ClientPacketHandler(client))
|
||||||
|
|
||||||
pipeline.addLast(LengthEncoder.NAME, LengthEncoder(maxLength))
|
pipeline.addLast(LengthEncoder.NAME, LengthEncoder(maxLength))
|
||||||
pipeline.addLast(PacketEncoder.NAME, PacketEncoder(client))
|
pipeline.addLast(PacketEncoder.NAME, PacketEncoder(client))
|
||||||
|
|
||||||
|
pipeline.addLast(ExceptionHandler.NAME, ExceptionHandler(client))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun channelActive(context: ChannelHandlerContext) {
|
override fun channelActive(context: ChannelHandlerContext) {
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
open class NetworkException : Exception()
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes
|
||||||
|
|
||||||
|
class PacketBufferUnderflowException(
|
||||||
|
val type: PacketTypes.S2C,
|
||||||
|
val size: Int,
|
||||||
|
val available: Int,
|
||||||
|
) : NetworkException() {
|
||||||
|
override val message: String = "type=$type, size=$size, available=$available"
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
class PacketHandleException(
|
||||||
|
override val cause: Throwable,
|
||||||
|
) : NetworkException()
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.versions.Version
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
|
||||||
|
class PacketNotAvailableException(
|
||||||
|
val type: PacketTypes.C2S,
|
||||||
|
val state: ProtocolStates,
|
||||||
|
val version: Version?,
|
||||||
|
) : NetworkException() {
|
||||||
|
override val message: String = "type=$type, state=$state, version=$version"
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
class PacketReadException(
|
||||||
|
override val cause: Throwable,
|
||||||
|
) : NetworkException()
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
import de.bixilon.kutil.reflection.ReflectionUtil.realName
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||||
|
|
||||||
|
class WrongConnectionException(
|
||||||
|
val required: Class<out Connection>,
|
||||||
|
val current: Class<out Connection>,
|
||||||
|
) : NetworkException() {
|
||||||
|
override val message: String = "required=${required.realName}, current=${current.realName}"
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
|
||||||
|
class WrongProtocolStateException(
|
||||||
|
val required: ProtocolStates,
|
||||||
|
val current: ProtocolStates,
|
||||||
|
) : NetworkException() {
|
||||||
|
override val message: String = "required=$required, current=$current"
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions.ciritical
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
|
||||||
|
open class CriticalNetworkException : NetworkException()
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions.ciritical
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.versions.Version
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
import de.bixilon.minosoft.util.KUtil.toHex
|
||||||
|
|
||||||
|
class UnknownPacketIdException(
|
||||||
|
val packetId: Int,
|
||||||
|
val state: ProtocolStates,
|
||||||
|
val version: Version?,
|
||||||
|
) : NetworkException() {
|
||||||
|
override val message: String = "packetId=0x${packetId.toHex()}, state=$state, version=$version"
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.exceptions.implementation
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes
|
||||||
|
|
||||||
|
class S2CPacketNotImplementedException(val packetType: PacketTypes.S2C) : NetworkException() {
|
||||||
|
override val message: String = "$packetType"
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.pipeline
|
||||||
|
|
||||||
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
|
import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||||
|
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedList
|
||||||
|
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||||
|
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||||
|
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnection
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.PacketHandleException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.WrongConnectionException
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.StatusS2CPacket
|
||||||
|
import io.netty.channel.ChannelHandlerContext
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler
|
||||||
|
|
||||||
|
class ClientPacketHandler(
|
||||||
|
private val client: NettyClient,
|
||||||
|
) : SimpleChannelInboundHandler<S2CPacket>() {
|
||||||
|
private val connection: Connection = client.connection
|
||||||
|
private val handlers: MutableSet<ThreadPoolRunnable> = synchronizedSetOf()
|
||||||
|
|
||||||
|
init {
|
||||||
|
client::connected.observe(this) {
|
||||||
|
if (!it) {
|
||||||
|
for (handler in handlers.toSynchronizedList()) {
|
||||||
|
handler.interrupt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun channelRead0(context: ChannelHandlerContext, packet: S2CPacket) {
|
||||||
|
if (packet.type.isThreadSafe) {
|
||||||
|
val runnable = ThreadPoolRunnable()
|
||||||
|
runnable.runnable = Runnable { tryHandle(packet);handlers -= runnable }
|
||||||
|
handlers += runnable
|
||||||
|
DefaultThreadPool += runnable
|
||||||
|
} else {
|
||||||
|
tryHandle(packet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun tryHandle(packet: S2CPacket) {
|
||||||
|
if (!client.connected) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
handle(packet)
|
||||||
|
} catch (exception: NetworkException) {
|
||||||
|
packet.type.errorHandler?.onError(connection)
|
||||||
|
throw exception
|
||||||
|
} catch (error: Throwable) {
|
||||||
|
packet.type.errorHandler?.onError(connection)
|
||||||
|
throw PacketHandleException(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handle(packet: S2CPacket) {
|
||||||
|
when (packet) {
|
||||||
|
is PlayS2CPacket -> handle(packet)
|
||||||
|
is StatusS2CPacket -> handle(packet)
|
||||||
|
else -> throw IllegalStateException("Unknown packet type!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handle(packet: PlayS2CPacket) {
|
||||||
|
val connection = connection.nullCast<PlayConnection>() ?: throw WrongConnectionException(PlayConnection::class.java, this.connection::class.java)
|
||||||
|
packet.log(connection.profiles.other.log.reducedProtocolLog)
|
||||||
|
packet.check(connection)
|
||||||
|
packet.handle(connection)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handle(packet: StatusS2CPacket) {
|
||||||
|
val connection = connection.nullCast<StatusConnection>() ?: throw WrongConnectionException(StatusConnection::class.java, this.connection::class.java)
|
||||||
|
packet.log(OtherProfileManager.selected.log.reducedProtocolLog)
|
||||||
|
packet.check(connection)
|
||||||
|
packet.handle(connection)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun exceptionCaught(context: ChannelHandlerContext, cause: Throwable) {
|
||||||
|
cause.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val NAME = "client_packet_handler"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.network.network.client.pipeline
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.ciritical.CriticalNetworkException
|
||||||
|
import io.netty.channel.ChannelDuplexHandler
|
||||||
|
import io.netty.channel.ChannelHandlerContext
|
||||||
|
|
||||||
|
class ExceptionHandler(
|
||||||
|
private val client: NettyClient,
|
||||||
|
) : ChannelDuplexHandler() {
|
||||||
|
|
||||||
|
override fun exceptionCaught(context: ChannelHandlerContext, cause: Throwable) {
|
||||||
|
cause.printStackTrace()
|
||||||
|
if (cause !is NetworkException) {
|
||||||
|
client.disconnect()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (cause is CriticalNetworkException) {
|
||||||
|
client.disconnect()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val NAME = "exception_handler"
|
||||||
|
}
|
||||||
|
}
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.network.network.client.pipeline
|
|
||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
|
||||||
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.StatusS2CPacket
|
|
||||||
import io.netty.channel.ChannelHandlerContext
|
|
||||||
import io.netty.channel.SimpleChannelInboundHandler
|
|
||||||
|
|
||||||
class PacketHandler(
|
|
||||||
private val connection: Connection,
|
|
||||||
) : SimpleChannelInboundHandler<S2CPacket>() {
|
|
||||||
|
|
||||||
override fun channelRead0(context: ChannelHandlerContext, packet: S2CPacket) {
|
|
||||||
if (packet is PlayS2CPacket) {
|
|
||||||
val connection = connection.unsafeCast<PlayConnection>()
|
|
||||||
packet.log(connection.profiles.other.log.reducedProtocolLog)
|
|
||||||
packet.check(connection)
|
|
||||||
packet.handle(connection)
|
|
||||||
} else if (packet is StatusS2CPacket) {
|
|
||||||
packet.log(OtherProfileManager.selected.log.reducedProtocolLog)
|
|
||||||
packet.check(connection.unsafeCast())
|
|
||||||
packet.handle(connection.unsafeCast())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun exceptionCaught(context: ChannelHandlerContext, cause: Throwable) {
|
|
||||||
context.close()
|
|
||||||
cause.printStackTrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val NAME = "packet_handler"
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,14 @@ package de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding
|
|||||||
import de.bixilon.minosoft.data.registries.versions.Version
|
import de.bixilon.minosoft.data.registries.versions.Version
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.NetworkException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.PacketBufferUnderflowException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.PacketReadException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.ciritical.UnknownPacketIdException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.implementation.S2CPacketNotImplementedException
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
import de.bixilon.minosoft.protocol.protocol.Protocol
|
import de.bixilon.minosoft.protocol.protocol.Protocol
|
||||||
import io.netty.channel.ChannelHandlerContext
|
import io.netty.channel.ChannelHandlerContext
|
||||||
@ -34,15 +41,37 @@ class PacketDecoder(
|
|||||||
|
|
||||||
val state = client.state
|
val state = client.state
|
||||||
|
|
||||||
val packetType = version?.s2cPackets?.get(state)?.get(packetId) ?: Protocol.getPacketById(state, packetId) ?: throw IllegalArgumentException("Unknown packet id: $packetId")
|
val packetType = version?.s2cPackets?.get(state)?.get(packetId) ?: Protocol.getPacketById(state, packetId) ?: throw UnknownPacketIdException(packetId, state, version)
|
||||||
val packet = if (client.connection is PlayConnection) {
|
|
||||||
packetType.playFactory?.invoke(PlayInByteBuffer(data, client.connection))
|
val packet = try {
|
||||||
} else {
|
readPacket(packetType, data)
|
||||||
packetType.statusFactory?.invoke(InByteBuffer(data))
|
} catch (exception: NetworkException) {
|
||||||
|
packetType.errorHandler?.onError(client.connection)
|
||||||
|
throw exception
|
||||||
|
} catch (error: Throwable) {
|
||||||
|
packetType.errorHandler?.onError(client.connection)
|
||||||
|
throw PacketReadException(error)
|
||||||
}
|
}
|
||||||
out += packet ?: TODO("Packet $packetType not yet implemented!")
|
|
||||||
|
out += packet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun readPacket(type: PacketTypes.S2C, data: ByteArray): S2CPacket {
|
||||||
|
val dataBuffer: InByteBuffer
|
||||||
|
val packet = if (client.connection is PlayConnection) {
|
||||||
|
dataBuffer = PlayInByteBuffer(data, client.connection)
|
||||||
|
type.playFactory?.invoke(dataBuffer)
|
||||||
|
} else {
|
||||||
|
dataBuffer = InByteBuffer(data)
|
||||||
|
type.statusFactory?.invoke(dataBuffer)
|
||||||
|
}
|
||||||
|
if (dataBuffer.pointer < dataBuffer.size) {
|
||||||
|
throw PacketBufferUnderflowException(type, dataBuffer.size, dataBuffer.pointer)
|
||||||
|
}
|
||||||
|
return packet ?: throw S2CPacketNotImplementedException(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val NAME = "packet_decoder"
|
const val NAME = "packet_decoder"
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,11 @@ package de.bixilon.minosoft.protocol.network.network.client.pipeline.encoding
|
|||||||
|
|
||||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
import de.bixilon.minosoft.data.registries.versions.Version
|
import de.bixilon.minosoft.data.registries.versions.Version
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
import de.bixilon.minosoft.protocol.network.network.client.NettyClient
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.PacketNotAvailableException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.WrongConnectionException
|
||||||
|
import de.bixilon.minosoft.protocol.network.network.client.exceptions.WrongProtocolStateException
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.AllC2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.AllC2SPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||||
@ -34,6 +38,7 @@ class PacketEncoder(
|
|||||||
|
|
||||||
|
|
||||||
override fun encode(context: ChannelHandlerContext, packet: C2SPacket, out: MutableList<Any>) {
|
override fun encode(context: ChannelHandlerContext, packet: C2SPacket, out: MutableList<Any>) {
|
||||||
|
val state = client.state
|
||||||
val packetData: OutByteBuffer
|
val packetData: OutByteBuffer
|
||||||
when (packet) {
|
when (packet) {
|
||||||
is AllC2SPacket -> {
|
is AllC2SPacket -> {
|
||||||
@ -41,14 +46,16 @@ class PacketEncoder(
|
|||||||
packet.write(packetData)
|
packet.write(packetData)
|
||||||
}
|
}
|
||||||
is PlayC2SPacket -> {
|
is PlayC2SPacket -> {
|
||||||
packetData = PlayOutByteBuffer(client.connection.nullCast() ?: throw IllegalStateException("Trying to send a play packet in non play connection"))
|
packetData = PlayOutByteBuffer(client.connection.nullCast() ?: throw WrongConnectionException(PlayConnection::class.java, client.connection::class.java))
|
||||||
packet.write(packetData)
|
packet.write(packetData)
|
||||||
}
|
}
|
||||||
else -> throw IllegalArgumentException("Unknown packet type $packet")
|
else -> throw IllegalArgumentException("Unknown packet type $packet")
|
||||||
}
|
}
|
||||||
val state = client.state
|
|
||||||
val packetType = PacketTypes.C2S.getPacketType(packet::class.java)
|
val packetType = PacketTypes.C2S.getPacketType(packet::class.java)
|
||||||
val packetId = version?.c2sPackets?.get(state)?.index(packetType) ?: Protocol.getPacketId(packetType) ?: throw IllegalArgumentException("Can not get packet id for $packetType")
|
if (packetType.state != state) {
|
||||||
|
throw WrongProtocolStateException(packetType.state, state)
|
||||||
|
}
|
||||||
|
val packetId = version?.c2sPackets?.get(state)?.index(packetType) ?: Protocol.getPacketId(packetType) ?: throw PacketNotAvailableException(packetType, state, version)
|
||||||
|
|
||||||
val data = OutByteBuffer()
|
val data = OutByteBuffer()
|
||||||
data.writeVarInt(packetId)
|
data.writeVarInt(packetId)
|
||||||
|
@ -14,9 +14,9 @@ package de.bixilon.minosoft.protocol.packets.s2c
|
|||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
abstract class PlayS2CPacket : S2CPacket() {
|
interface PlayS2CPacket : S2CPacket {
|
||||||
|
|
||||||
open fun handle(connection: PlayConnection) = Unit
|
fun handle(connection: PlayConnection) = Unit
|
||||||
|
|
||||||
open fun check(connection: PlayConnection) = Unit
|
fun check(connection: PlayConnection) = Unit
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,4 @@ package de.bixilon.minosoft.protocol.packets.s2c
|
|||||||
|
|
||||||
import de.bixilon.minosoft.protocol.packets.Packet
|
import de.bixilon.minosoft.protocol.packets.Packet
|
||||||
|
|
||||||
abstract class S2CPacket : Packet
|
interface S2CPacket : Packet
|
||||||
|
@ -14,9 +14,9 @@ package de.bixilon.minosoft.protocol.packets.s2c
|
|||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnection
|
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnection
|
||||||
|
|
||||||
abstract class StatusS2CPacket : S2CPacket() {
|
interface StatusS2CPacket : S2CPacket {
|
||||||
|
|
||||||
open fun handle(connection: StatusConnection) = Unit
|
fun handle(connection: StatusConnection) = Unit
|
||||||
|
|
||||||
open fun check(connection: StatusConnection) = Unit
|
fun check(connection: StatusConnection) = Unit
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.protocol.packets.s2c.interfaces
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
|
||||||
abstract class CompressionThresholdChange : PlayS2CPacket() {
|
abstract class CompressionThresholdChange : PlayS2CPacket {
|
||||||
abstract val threshold: Int
|
abstract val threshold: Int
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
@ -13,12 +13,14 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.login
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.interfaces.CompressionThresholdChange
|
import de.bixilon.minosoft.protocol.packets.s2c.interfaces.CompressionThresholdChange
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class CompressionSetS2CP(buffer: PlayInByteBuffer) : CompressionThresholdChange() {
|
class CompressionSetS2CP(buffer: PlayInByteBuffer) : CompressionThresholdChange() {
|
||||||
|
override val type = PacketTypes.S2C.PLAY_COMPRESSION_SET
|
||||||
override val threshold: Int = buffer.readVarInt()
|
override val threshold: Int = buffer.readVarInt()
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
|
|
||||||
class EncryptionRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EncryptionRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val serverId: String = buffer.readString()
|
val serverId: String = buffer.readString()
|
||||||
val publicKey: ByteArray = buffer.readByteArray()
|
val publicKey: ByteArray = buffer.readByteArray()
|
||||||
val verifyToken: ByteArray = buffer.readByteArray()
|
val verifyToken: ByteArray = buffer.readByteArray()
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class LoginKickS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class LoginKickS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val reason: ChatComponent = buffer.readChatComponent()
|
val reason: ChatComponent = buffer.readChatComponent()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
@ -24,7 +24,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class LoginSuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class LoginSuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val uuid: UUID = (buffer.versionId < ProtocolVersions.V_20W12A).decide({ buffer.readUUIDString() }, { buffer.readUUID() })
|
val uuid: UUID = (buffer.versionId < ProtocolVersions.V_20W12A).decide({ buffer.readUUIDString() }, { buffer.readUUID() })
|
||||||
val name: String = buffer.readString()
|
val name: String = buffer.readString()
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class PacketLoginPluginRequest(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PacketLoginPluginRequest(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val messageId = buffer.readVarInt()
|
val messageId = buffer.readVarInt()
|
||||||
val channel = buffer.readString()
|
val channel = buffer.readString()
|
||||||
val data: PlayInByteBuffer = PlayInByteBuffer(buffer.readRest(), buffer.connection)
|
val data: PlayInByteBuffer = PlayInByteBuffer(buffer.readRest(), buffer.connection)
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class AutocompletionsS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class AutocompletionsS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
var matches: Array<String> = when {
|
var matches: Array<String> = when {
|
||||||
buffer.versionId < ProtocolVersions.V_14W33A -> {
|
buffer.versionId < ProtocolVersions.V_14W33A -> {
|
||||||
buffer.readVarInt() // ToDo: count?
|
buffer.readVarInt() // ToDo: count?
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BedUseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BedUseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readInt()
|
val entityId: Int = buffer.readInt()
|
||||||
val blockPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
val blockPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
buffer.readByteBlockPosition()
|
buffer.readByteBlockPosition()
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BlockActionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BlockActionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
||||||
buffer.readShortBlockPosition()
|
buffer.readShortBlockPosition()
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BlockBreakAckS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BlockBreakAckS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val blockPosition: Vec3i = buffer.readBlockPosition()
|
val blockPosition: Vec3i = buffer.readBlockPosition()
|
||||||
val blockState: BlockState? = buffer.connection.registries.blockStateRegistry[buffer.readVarInt()]
|
val blockState: BlockState? = buffer.connection.registries.blockStateRegistry[buffer.readVarInt()]
|
||||||
val actions: Actions = Actions[buffer.readVarInt()]
|
val actions: Actions = Actions[buffer.readVarInt()]
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BlockBreakAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BlockBreakAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
/**
|
/**
|
||||||
* Entity id of the entity who is breaking the block
|
* Entity id of the entity who is breaking the block
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BlockEntityMetaDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BlockEntityMetaDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
||||||
buffer.readShortBlockPosition()
|
buffer.readShortBlockPosition()
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class BlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val blockPosition: Vec3i
|
val blockPosition: Vec3i
|
||||||
val blockState: BlockState?
|
val blockState: BlockState?
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class BookOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class BookOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val hand: Hands = Hands[buffer.readVarInt()]
|
val hand: Hands = Hands[buffer.readVarInt()]
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class CameraS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class CameraS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readVarInt()
|
val entityId: Int = buffer.readVarInt()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val message: ChatComponent = buffer.readChatComponent()
|
val message: ChatComponent = buffer.readChatComponent()
|
||||||
var position: ChatTextPositions = ChatTextPositions.CHAT_BOX
|
var position: ChatTextPositions = ChatTextPositions.CHAT_BOX
|
||||||
private set
|
private set
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
|
|
||||||
class ChunkCenterSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ChunkCenterSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
private val position: Vec2i = Vec2i(buffer.readVarInt(), buffer.readVarInt())
|
private val position: Vec2i = Vec2i(buffer.readVarInt(), buffer.readVarInt())
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
|
@ -45,7 +45,7 @@ import glm_.vec2.Vec2i
|
|||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ChunkDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ChunkDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val chunkPosition: Vec2i
|
val chunkPosition: Vec2i
|
||||||
val chunkData: ChunkData = ChunkData()
|
val chunkData: ChunkData = ChunkData()
|
||||||
var unloadChunk: Boolean = false
|
var unloadChunk: Boolean = false
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ChunkLightDataS2CP(buffer: PlayInByteBuffer, chunkPositionGetter: () -> Vec2i = { Vec2i(buffer.readVarInt(), buffer.readVarInt()) }) : PlayS2CPacket() {
|
class ChunkLightDataS2CP(buffer: PlayInByteBuffer, chunkPositionGetter: () -> Vec2i = { Vec2i(buffer.readVarInt(), buffer.readVarInt()) }) : PlayS2CPacket {
|
||||||
val chunkPosition: Vec2i = chunkPositionGetter()
|
val chunkPosition: Vec2i = chunkPositionGetter()
|
||||||
var trustEdges: Boolean = false
|
var trustEdges: Boolean = false
|
||||||
private set
|
private set
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
|
|
||||||
class ChunkUnloadS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ChunkUnloadS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val chunkPosition: Vec2i = buffer.readChunkPosition()
|
val chunkPosition: Vec2i = buffer.readChunkPosition()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
@ -28,6 +28,9 @@ class ChunkUnloadS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
|
if (reducedLog) {
|
||||||
|
return
|
||||||
|
}
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Chunk unload (chunkPosition=$chunkPosition)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Chunk unload (chunkPosition=$chunkPosition)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class CompassPositionSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class CompassPositionSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
var spawnPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
var spawnPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
||||||
buffer.readIntBlockPosition()
|
buffer.readIntBlockPosition()
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerActionStatusS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerActionStatusS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = buffer.readUnsignedByte()
|
val containerId = buffer.readUnsignedByte()
|
||||||
val actionId = buffer.readUnsignedShort()
|
val actionId = buffer.readUnsignedShort()
|
||||||
val accepted = buffer.readBoolean()
|
val accepted = buffer.readBoolean()
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerCloseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerCloseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId: Int = buffer.readUnsignedByte()
|
val containerId: Int = buffer.readUnsignedByte()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerItemSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerItemSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = buffer.readUnsignedByte()
|
val containerId = buffer.readUnsignedByte()
|
||||||
val revision: Int = if (buffer.versionId >= V_1_17_1_PRE_1) {
|
val revision: Int = if (buffer.versionId >= V_1_17_1_PRE_1) {
|
||||||
buffer.readVarInt()
|
buffer.readVarInt()
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerItemsSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerItemsSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = buffer.readUnsignedByte()
|
val containerId = buffer.readUnsignedByte()
|
||||||
val revision: Int = if (buffer.versionId >= V_1_17_1_PRE_1) {
|
val revision: Int = if (buffer.versionId >= V_1_17_1_PRE_1) {
|
||||||
buffer.readVarInt()
|
buffer.readVarInt()
|
||||||
|
@ -28,7 +28,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = if (buffer.versionId <= V_1_14) { // ToDo: This is completely guessed, it has changed between 1.13 and 1.14, same as #L38
|
val containerId = if (buffer.versionId <= V_1_14) { // ToDo: This is completely guessed, it has changed between 1.13 and 1.14, same as #L38
|
||||||
buffer.readUnsignedByte()
|
buffer.readUnsignedByte()
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ContainerPropertySetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ContainerPropertySetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId: Byte = buffer.readByte()
|
val containerId: Byte = buffer.readByte()
|
||||||
val property = buffer.readUnsignedShort()
|
val property = buffer.readUnsignedShort()
|
||||||
val value = buffer.readUnsignedShort()
|
val value = buffer.readUnsignedShort()
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class CraftingRecipeResponseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class CraftingRecipeResponseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = buffer.readUnsignedByte()
|
val containerId = buffer.readUnsignedByte()
|
||||||
var recipeId: Int? = null
|
var recipeId: Int? = null
|
||||||
private set
|
private set
|
||||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EmptyEntityMoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EmptyEntityMoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readVarInt()
|
val entityId: Int = buffer.readVarInt()
|
||||||
val animation: EntityAnimations = buffer.connection.registries.entityAnimationRegistry[buffer.readVarInt()]!!
|
val animation: EntityAnimations = buffer.connection.registries.entityAnimationRegistry[buffer.readVarInt()]!!
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityAttachS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityAttachS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readInt()
|
val entityId: Int = buffer.readInt()
|
||||||
val vehicleEntityId: Int = buffer.readInt()
|
val vehicleEntityId: Int = buffer.readInt()
|
||||||
val leash: Boolean = if (buffer.versionId < ProtocolVersions.V_15W41A) {
|
val leash: Boolean = if (buffer.versionId < ProtocolVersions.V_15W41A) {
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityCollectAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityCollectAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val itemEntityId: Int = buffer.readEntityId()
|
val itemEntityId: Int = buffer.readEntityId()
|
||||||
var collectorEntityId: Int = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
var collectorEntityId: Int = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
buffer.readInt()
|
buffer.readInt()
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityDestroyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityDestroyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityIds: List<Int> = if (buffer.versionId < ProtocolVersions.V_21W17A || buffer.versionId >= V_1_17_1_RC1) {
|
val entityIds: List<Int> = if (buffer.versionId < ProtocolVersions.V_21W17A || buffer.versionId >= V_1_17_1_RC1) {
|
||||||
buffer.readEntityIdArray(if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
buffer.readEntityIdArray(if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
buffer.readUnsignedByte()
|
buffer.readUnsignedByte()
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class EntityEffectAttributesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityEffectAttributesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val attributes: Map<ResourceLocation, EntityAttribute>
|
val attributes: Map<ResourceLocation, EntityAttribute>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityEquipmentS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityEquipmentS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val equipment: Map<EquipmentSlots, ItemStack?>
|
val equipment: Map<EquipmentSlots, ItemStack?>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityHeadRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityHeadRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val headYaw: Int = buffer.readAngle()
|
val headYaw: Int = buffer.readAngle()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityMetadataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityMetadataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId = buffer.readEntityId()
|
val entityId = buffer.readEntityId()
|
||||||
val metaData: EntityMetaData = buffer.readMetaData()
|
val metaData: EntityMetaData = buffer.readMetaData()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class EntityMoveAndRotateS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityMoveAndRotateS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
var delta: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
var delta: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
||||||
Vec3d(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte())
|
Vec3d(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte())
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class EntityObjectSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityObjectSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
var entityUUID: UUID? = null
|
var entityUUID: UUID? = null
|
||||||
private set
|
private set
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityPassengerSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityPassengerSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val vehicleEntityId: Int = buffer.readVarInt()
|
val vehicleEntityId: Int = buffer.readVarInt()
|
||||||
val passengerEntityIds: Set<Int> = buffer.readVarIntArray().toSet()
|
val passengerEntityIds: Set<Int> = buffer.readVarIntArray().toSet()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class EntityRelativeMoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityRelativeMoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val delta: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
val delta: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
||||||
Vec3d(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte())
|
Vec3d(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte())
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val yaw: Int = buffer.readAngle()
|
val yaw: Int = buffer.readAngle()
|
||||||
val pitch: Int = buffer.readAngle()
|
val pitch: Int = buffer.readAngle()
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntitySoundEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntitySoundEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val soundEvent: ResourceLocation = buffer.connection.registries.soundEventRegistry[buffer.readVarInt()]!!
|
val soundEvent: ResourceLocation = buffer.connection.registries.soundEventRegistry[buffer.readVarInt()]!!
|
||||||
val category: SoundCategories = SoundCategories[buffer.readVarInt()]
|
val category: SoundCategories = SoundCategories[buffer.readVarInt()]
|
||||||
val entityId: Int = buffer.readVarInt()
|
val entityId: Int = buffer.readVarInt()
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityStatusEffectRemoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityStatusEffectRemoveS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val effect: StatusEffect = buffer.connection.registries.statusEffectRegistry[buffer.readUnsignedByte()]
|
val effect: StatusEffect = buffer.connection.registries.statusEffectRegistry[buffer.readUnsignedByte()]
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityStatusEffectS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityStatusEffectS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
var effect: StatusEffectInstance = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
var effect: StatusEffectInstance = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
StatusEffectInstance(buffer.connection.registries.statusEffectRegistry[buffer.readUnsignedByte()], buffer.readByte() + 1, buffer.readUnsignedShort())
|
StatusEffectInstance(buffer.connection.registries.statusEffectRegistry[buffer.readUnsignedByte()], buffer.readByte() + 1, buffer.readUnsignedShort())
|
||||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class EntityStatusS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityStatusS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
private val entityId: Int = buffer.readInt()
|
private val entityId: Int = buffer.readInt()
|
||||||
private val eventId: Int = buffer.readUnsignedByte()
|
private val eventId: Int = buffer.readUnsignedByte()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class EntityTeleportS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityTeleportS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val position: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
val position: Vec3d = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
||||||
Vec3d(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt())
|
Vec3d(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt())
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class EntityVelocityS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class EntityVelocityS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val velocity: Vec3d = buffer.readVelocity()
|
val velocity: Vec3d = buffer.readVelocity()
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class ExperienceOrbSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ExperienceOrbSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val entity: ExperienceOrb = ExperienceOrb(
|
val entity: ExperienceOrb = ExperienceOrb(
|
||||||
connection = buffer.connection,
|
connection = buffer.connection,
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ExperienceSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ExperienceSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val bar = buffer.readFloat()
|
val bar = buffer.readFloat()
|
||||||
val level: Int
|
val level: Int
|
||||||
val total: Int
|
val total: Int
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position = buffer.readVec3f()
|
val position = buffer.readVec3f()
|
||||||
val power = buffer.readFloat()
|
val power = buffer.readFloat()
|
||||||
val explodedBlocks: List<Vec3i> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { Vec3i(buffer.readByte(), buffer.readByte(), buffer.readByte()) }.toList() // ToDo: Find out version
|
val explodedBlocks: List<Vec3i> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { Vec3i(buffer.readByte(), buffer.readByte(), buffer.readByte()) }.toList() // ToDo: Find out version
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class GameEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class GameEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val event: GameEvent = buffer.connection.registries.gameEventRegistry[buffer.readUnsignedByte()]
|
val event: GameEvent = buffer.connection.registries.gameEventRegistry[buffer.readUnsignedByte()]
|
||||||
val data: Float = buffer.readFloat()
|
val data: Float = buffer.readFloat()
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class GlobalEntitySpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class GlobalEntitySpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readVarInt()
|
val entityId: Int = buffer.readVarInt()
|
||||||
val entity: LightningBolt
|
val entity: LightningBolt
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class HealthSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class HealthSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val hp: Float = clamp(buffer.readFloat(), 0.0f, Float.MAX_VALUE)
|
val hp: Float = clamp(buffer.readFloat(), 0.0f, Float.MAX_VALUE)
|
||||||
val hunger = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
val hunger = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
buffer.readUnsignedShort()
|
buffer.readUnsignedShort()
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class HeartbeatS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class HeartbeatS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
var id: Long = when {
|
var id: Long = when {
|
||||||
buffer.versionId < ProtocolVersions.V_14W31A -> {
|
buffer.versionId < ProtocolVersions.V_14W31A -> {
|
||||||
buffer.readInt().toLong()
|
buffer.readInt().toLong()
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class HorseContainerOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class HorseContainerOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val containerId = buffer.readUnsignedByte()
|
val containerId = buffer.readUnsignedByte()
|
||||||
val slotCount: Int = buffer.readVarInt()
|
val slotCount: Int = buffer.readVarInt()
|
||||||
val entityId: Int = buffer.readInt()
|
val entityId: Int = buffer.readInt()
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val slot: Int = buffer.readUnsignedByte()
|
val slot: Int = buffer.readUnsignedByte()
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ItemCooldownSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ItemCooldownSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val item = buffer.connection.registries.itemRegistry[buffer.readVarInt()]
|
val item = buffer.connection.registries.itemRegistry[buffer.readVarInt()]
|
||||||
val time = buffer.readVarInt()
|
val time = buffer.readVarInt()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.listCast
|
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.listCast
|
||||||
|
|
||||||
class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int
|
val entityId: Int
|
||||||
val isHardcore: Boolean
|
val isHardcore: Boolean
|
||||||
val gamemode: Gamemodes
|
val gamemode: Gamemodes
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class KickS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class KickS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val reason: ChatComponent = buffer.readChatComponent()
|
val reason: ChatComponent = buffer.readChatComponent()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class MassBlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class MassBlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val blocks: MutableMap<Vec3i, BlockState?> = mutableMapOf()
|
val blocks: MutableMap<Vec3i, BlockState?> = mutableMapOf()
|
||||||
var chunkPosition: Vec2i
|
var chunkPosition: Vec2i
|
||||||
private set
|
private set
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MassChunkDataS2CP() : PlayS2CPacket() {
|
class MassChunkDataS2CP() : PlayS2CPacket {
|
||||||
val data: MutableMap<Vec2i, ChunkData?> = mutableMapOf()
|
val data: MutableMap<Vec2i, ChunkData?> = mutableMapOf()
|
||||||
|
|
||||||
constructor(buffer: PlayInByteBuffer) : this() {
|
constructor(buffer: PlayInByteBuffer) : this() {
|
||||||
|
@ -27,7 +27,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MobSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class MobSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val entityUUID: UUID? = if (buffer.versionId >= ProtocolVersions.V_15W31A) {
|
val entityUUID: UUID? = if (buffer.versionId >= ProtocolVersions.V_15W31A) {
|
||||||
buffer.readUUID()
|
buffer.readUUID()
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class NBTQueryResponseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class NBTQueryResponseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val transactionId: Int = buffer.readVarInt()
|
val transactionId: Int = buffer.readVarInt()
|
||||||
val nbt: Map<String, Any> = buffer.readNBT().asJsonObject()
|
val nbt: Map<String, Any> = buffer.readNBT().asJsonObject()
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
class NamedSoundEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class NamedSoundEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val soundEvent: ResourceLocation?
|
val soundEvent: ResourceLocation?
|
||||||
val volume: Float
|
val volume: Float
|
||||||
val pitch: Float
|
val pitch: Float
|
||||||
|
@ -27,7 +27,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class PaintingSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PaintingSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
private val entityId: Int = buffer.readVarInt()
|
private val entityId: Int = buffer.readVarInt()
|
||||||
private var entityUUID: UUID? = if (buffer.versionId >= ProtocolVersions.V_16W02A) {
|
private var entityUUID: UUID? = if (buffer.versionId >= ProtocolVersions.V_16W02A) {
|
||||||
buffer.readUUID()
|
buffer.readUUID()
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val type: ParticleType = if (buffer.versionId < ProtocolVersions.V_14W19A) {
|
val type: ParticleType = if (buffer.versionId < ProtocolVersions.V_14W19A) {
|
||||||
buffer.connection.registries.particleTypeRegistry[buffer.readResourceLocation()]!!
|
buffer.connection.registries.particleTypeRegistry[buffer.readResourceLocation()]!!
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class PingS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PingS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val id = buffer.readInt()
|
val id = buffer.readInt()
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val isInvulnerable: Boolean
|
val isInvulnerable: Boolean
|
||||||
val isFlying: Boolean
|
val isFlying: Boolean
|
||||||
val canFly: Boolean
|
val canFly: Boolean
|
||||||
|
@ -29,7 +29,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class PlayerEntitySpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PlayerEntitySpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
private val entityId: Int
|
private val entityId: Int
|
||||||
private var entityUUID: UUID? = null
|
private var entityUUID: UUID? = null
|
||||||
val entity: PlayerEntity
|
val entity: PlayerEntity
|
||||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class PlayerFaceS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PlayerFaceS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val face: PlayerFaces = PlayerFaces[buffer.readVarInt()]
|
val face: PlayerFaces = PlayerFaces[buffer.readVarInt()]
|
||||||
val position: Vec3d = buffer.readVec3d()
|
val position: Vec3d = buffer.readVec3d()
|
||||||
var entityId: Int? = null
|
var entityId: Int? = null
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class PluginMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PluginMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val channel: ResourceLocation = buffer.readResourceLocation()
|
val channel: ResourceLocation = buffer.readResourceLocation()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class PositionAndRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class PositionAndRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position: Vec3d
|
val position: Vec3d
|
||||||
val rotation: EntityRotation
|
val rotation: EntityRotation
|
||||||
var isOnGround = false
|
var isOnGround = false
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ResourcepackRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ResourcepackRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val url: String = buffer.readString().apply { toURL().checkWeb() }
|
val url: String = buffer.readString().apply { toURL().checkWeb() }
|
||||||
val hash: String = buffer.readString()
|
val hash: String = buffer.readString()
|
||||||
val forced = if (buffer.versionId >= ProtocolVersions.V_20W45A) {
|
val forced = if (buffer.versionId >= ProtocolVersions.V_20W45A) {
|
||||||
|
@ -29,7 +29,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3d
|
import glm_.vec3.Vec3d
|
||||||
|
|
||||||
class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
var dimension: DimensionProperties
|
var dimension: DimensionProperties
|
||||||
private set
|
private set
|
||||||
var difficulty: Difficulties = Difficulties.NORMAL
|
var difficulty: Difficulties = Difficulties.NORMAL
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val difficulty: Difficulties = Difficulties[buffer.readUnsignedByte()]
|
val difficulty: Difficulties = Difficulties[buffer.readUnsignedByte()]
|
||||||
var locked = false
|
var locked = false
|
||||||
private set
|
private set
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class SignEditorOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class SignEditorOpenS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
var blockPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
var blockPosition: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
||||||
buffer.readIntBlockPosition()
|
buffer.readIntBlockPosition()
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.util.logging.LogLevels
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class SignTextSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class SignTextSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W04A) {
|
||||||
buffer.readShortBlockPosition()
|
buffer.readShortBlockPosition()
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
class SimulationDistanceSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class SimulationDistanceSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val simulationDistance: Int = buffer.readVarInt()
|
val simulationDistance: Int = buffer.readVarInt()
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user