network: support for 21w38a-1.18-pre5

This commit is contained in:
Bixilon 2021-11-20 21:11:25 +01:00
parent beaeafbb5b
commit 5496b1d47e
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
10 changed files with 55 additions and 5 deletions

View File

@ -232,6 +232,7 @@ class AudioPlayer(
Log.log(LogMessageType.AUDIO_LOADING, LogLevels.INFO) { "Unloaded OpenAL!" }
}
@Deprecated("Refactoring needed")
private fun loadSounds() {
Log.log(LogMessageType.AUDIO_LOADING, LogLevels.VERBOSE) { "Loading sounds.json" }
val data = connection.assetsManager.readJsonAsset(SOUNDS_INDEX_FILE)

View File

@ -30,6 +30,7 @@ class ClientSettingsC2SP(
val skinParts: Set<SkinParts> = setOf(*SkinParts.VALUES),
val mainHand: Hands = Hands.MAIN,
val disableTextFiltering: Boolean = true,
val allowListing: Boolean = true,
) : PlayC2SPacket {
override fun write(buffer: PlayOutByteBuffer) {
@ -53,10 +54,13 @@ class ClientSettingsC2SP(
if (buffer.versionId >= ProtocolVersions.V_21W07A) {
buffer.writeBoolean(disableTextFiltering)
}
if (buffer.versionId >= ProtocolVersions.V_21W44A) {
buffer.writeBoolean(allowListing)
}
}
override fun log() {
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Client settings (locale=$locale, renderDistance=$viewDistance)" }
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Client settings (locale=$locale, viewDistance=$viewDistance)" }
}
enum class SkinParts {

View File

@ -130,7 +130,7 @@ class ChunkDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
val xz = buffer.readUnsignedByte()
val y = buffer.readShort()
val type = buffer.connection.registries.blockEntityTypeRegistry[buffer.readVarInt()]
val nbt = buffer.readNBT().asCompound()
val nbt = buffer.readNBT()?.asCompound() ?: continue
val entity = type.build(buffer.connection)
entity.updateNBT(nbt)
blockEntities[Vec3i(xz shr 4, y, xz and 0x0F)] = entity

View File

@ -70,6 +70,8 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
private set
var world: ResourceLocation? = null
private set
var simulationDistance: Int = -1
private set
init {
entityId = buffer.readInt()
@ -131,6 +133,9 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
if (buffer.versionId >= ProtocolVersions.V_19W13A) {
viewDistance = buffer.readVarInt()
}
if (buffer.versionId >= ProtocolVersions.V_21W40A) {
simulationDistance = buffer.readVarInt()
}
if (buffer.versionId >= ProtocolVersions.V_20W20A) {
buffer.readBoolean() // isDebug
if (buffer.readBoolean()) {

View File

@ -0,0 +1,27 @@
/*
* Minosoft
* Copyright (C) 2020 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.packets.s2c.play
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
class SimulationDistanceSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
val simulationDistance: Int = buffer.readVarInt()
override fun log() {
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Simulation distance set (viewDistance=$simulationDistance)" }
}
}

View File

@ -275,6 +275,7 @@ class PacketTypes {
PLAY_ADVANCEMENT_PROGRESS({ TODO() }),
PLAY_VIBRATION_SIGNAL({ VibrationSignalS2CP(it) }),
PLAY_PING({ PingS2CP(it) }),
PLAY_SIMULATION_DISTANCE({ SimulationDistanceSetS2CP(it) }),
;
init {

View File

@ -16,6 +16,18 @@ package de.bixilon.minosoft.protocol.protocol;
@SuppressWarnings("unused")
public class ProtocolVersions {
public static final int
V_1_18_PRE5 = 807,
V_1_18_PRE4 = 806,
V_1_18_PRE3 = 805,
V_1_18_PRE2 = 804,
V_1_18_PRE1 = 803,
V_21W44A = 802,
V_21W43A = 801,
V_21W42A = 800,
V_21W41A = 799,
V_21W40A = 798,
V_21W39A = 797,
V_21W38A = 796,
V_21W37A = 795,
V_1_17_1 = 794,
V_1_17_1_RC2 = 793,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long