mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
fix joining with some non vanilla servers
This commit is contained in:
parent
9d91b45483
commit
b401c8d439
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.data.registries.dimension
|
||||
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.ResourceLocationDeserializer
|
||||
|
||||
data class Dimension(
|
||||
override val resourceLocation: ResourceLocation,
|
||||
val type: DimensionType,
|
||||
) : RegistryItem() {
|
||||
|
||||
override fun toString(): String {
|
||||
return resourceLocation.full
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Dimension> {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): Dimension {
|
||||
return Dimension(
|
||||
resourceLocation = resourceLocation,
|
||||
type = DimensionType.deserialize(data)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,7 @@
|
||||
/*
|
||||
* 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.data.registries
|
||||
package de.bixilon.minosoft.data.registries.dimension
|
||||
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.ResourceLocationDeserializer
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.lerp
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.nullCast
|
||||
import de.bixilon.minosoft.util.KUtil.toBoolean
|
||||
@ -23,8 +9,7 @@ import de.bixilon.minosoft.util.KUtil.toInt
|
||||
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.get
|
||||
|
||||
data class Dimension(
|
||||
override val resourceLocation: ResourceLocation,
|
||||
data class DimensionType(
|
||||
val piglinSafe: Boolean = false,
|
||||
val natural: Boolean = true,
|
||||
val ambientLight: Float = 0.0f,
|
||||
@ -32,7 +17,7 @@ data class Dimension(
|
||||
val respawnAnchorWorks: Boolean = false,
|
||||
val hasSkyLight: Boolean = true,
|
||||
val bedWorks: Boolean = true,
|
||||
val effects: ResourceLocation = ResourceLocation("overworld"),
|
||||
val skyProperties: ResourceLocation = ResourceLocation("overworld"),
|
||||
val hasRaids: Boolean = true,
|
||||
val logicalHeight: Int = 256,
|
||||
val coordinateScale: Double = 0.0,
|
||||
@ -41,7 +26,7 @@ data class Dimension(
|
||||
val ultraWarm: Boolean = false,
|
||||
val height: Int = 256,
|
||||
val supports3DBiomes: Boolean = true,
|
||||
) : RegistryItem() {
|
||||
) {
|
||||
val lowestSection = if (minY < 0) {
|
||||
(minY + 1) / ProtocolDefinition.SECTION_HEIGHT_Y - 1
|
||||
} else {
|
||||
@ -60,19 +45,14 @@ data class Dimension(
|
||||
for (i in lightLevels.indices) {
|
||||
val asFloat = i / 15.0f
|
||||
|
||||
lightLevels[i] = lerp(ambientLight, asFloat / (4.0f - 3.0f * asFloat), 1.0f)
|
||||
lightLevels[i] = VecUtil.lerp(ambientLight, asFloat / (4.0f - 3.0f * asFloat), 1.0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return resourceLocation.full
|
||||
}
|
||||
|
||||
companion object : ResourceLocationDeserializer<Dimension> {
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): Dimension {
|
||||
return Dimension(
|
||||
resourceLocation = resourceLocation,
|
||||
companion object {
|
||||
fun deserialize(data: Map<String, Any>): DimensionType {
|
||||
return DimensionType(
|
||||
piglinSafe = data["piglin_safe"]?.toBoolean() ?: false,
|
||||
natural = data["natural"]?.toBoolean() ?: false,
|
||||
ambientLight = data["ambient_light"]?.unsafeCast<Float>() ?: 0.0f,
|
||||
@ -80,7 +60,7 @@ data class Dimension(
|
||||
respawnAnchorWorks = data["respawn_anchor_works"]?.toBoolean() ?: false,
|
||||
hasSkyLight = data["has_skylight", "has_sky_light"]?.toBoolean() ?: false,
|
||||
bedWorks = data["bed_works"]?.toBoolean() ?: false,
|
||||
effects = ResourceLocation(data["effects"].nullCast<String>() ?: "overworld"),
|
||||
skyProperties = ResourceLocation(data["effects"].nullCast<String>() ?: "overworld"),
|
||||
hasRaids = data["has_raids"]?.toBoolean() ?: false,
|
||||
logicalHeight = data["logical_height"]?.toInt() ?: 256,
|
||||
coordinateScale = data["coordinate_scale"].nullCast() ?: 0.0,
|
@ -114,7 +114,7 @@ open class Item(
|
||||
"PowderSnowBucketItem" -> PowderSnowBucketItem(resourceLocation, registries, data)
|
||||
"SnowballItem" -> SnowballItem(resourceLocation, registries, data)
|
||||
"MilkBucketItem" -> MilkBucketItem(resourceLocation, registries, data)
|
||||
"EntityBucketItem" -> EntityBucketItem(resourceLocation, registries, data)
|
||||
"FishBucketItem", "EntityBucketItem" -> EntityBucketItem(resourceLocation, registries, data)
|
||||
"BookItem" -> BookItem(resourceLocation, registries, data)
|
||||
"EggItem" -> EggItem(resourceLocation, registries, data)
|
||||
"CompassItem" -> CompassItem(resourceLocation, registries, data)
|
||||
|
@ -23,6 +23,7 @@ import de.bixilon.minosoft.data.registries.biomes.BiomePrecipitation
|
||||
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityType
|
||||
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityTypeRegistry
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.dimension.Dimension
|
||||
import de.bixilon.minosoft.data.registries.effects.StatusEffect
|
||||
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
|
||||
import de.bixilon.minosoft.data.registries.entities.EntityType
|
||||
|
@ -15,11 +15,11 @@ package de.bixilon.minosoft.data.world
|
||||
import de.bixilon.minosoft.data.Difficulties
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.AABB
|
||||
import de.bixilon.minosoft.data.registries.Dimension
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.FluidBlock
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType
|
||||
import de.bixilon.minosoft.data.registries.sounds.SoundEvent
|
||||
import de.bixilon.minosoft.data.registries.tweaker.VersionTweaker
|
||||
import de.bixilon.minosoft.data.world.biome.accessor.BiomeAccessor
|
||||
@ -61,7 +61,7 @@ class World(
|
||||
val chunks: MutableMap<Vec2i, Chunk> = synchronizedMapOf()
|
||||
val entities = WorldEntities()
|
||||
var hardcore = false
|
||||
var dimension: Dimension? = null
|
||||
var dimension: DimensionType? = null
|
||||
var difficulty: Difficulties? = null
|
||||
var difficultyLocked = false
|
||||
val worldLightAccessor = WorldLightAccessor(this)
|
||||
|
@ -261,7 +261,7 @@ class DebugHUDElement(hudRenderer: HUDRenderer) : HUDElement<GridLayout>(hudRend
|
||||
}
|
||||
clear()
|
||||
|
||||
this@DebugWorldInfo += AutoTextElement(hudRenderer, 1) { BaseComponent("Dimension ", connection.world.dimension?.resourceLocation) }
|
||||
this@DebugWorldInfo += AutoTextElement(hudRenderer, 1) { BaseComponent("Sky properties ", connection.world.dimension?.skyProperties) }
|
||||
this@DebugWorldInfo += AutoTextElement(hudRenderer, 1) { BaseComponent("Biome ", connection.world.getBiome(blockPosition)) }
|
||||
this@DebugWorldInfo += AutoTextElement(hudRenderer, 1) { with(connection.world.worldLightAccessor) { BaseComponent("Light block=", getBlockLight(blockPosition), ", sky=", getSkyLight(blockPosition)) } }
|
||||
|
||||
|
@ -15,27 +15,28 @@ package de.bixilon.minosoft.modding.event.events;
|
||||
|
||||
import de.bixilon.minosoft.data.Difficulties;
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes;
|
||||
import de.bixilon.minosoft.data.registries.Dimension;
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType;
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent;
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection;
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.RespawnS2CP;
|
||||
|
||||
@Deprecated
|
||||
public class RespawnEvent extends PlayConnectionEvent {
|
||||
private final Gamemodes gamemode;
|
||||
private final Dimension dimension;
|
||||
private final DimensionType dimensionType;
|
||||
private final Difficulties difficulty;
|
||||
|
||||
public RespawnEvent(PlayConnection connection, Gamemodes gamemode, Dimension dimension, Difficulties difficulty) {
|
||||
public RespawnEvent(PlayConnection connection, Gamemodes gamemode, DimensionType dimensionType, Difficulties difficulty) {
|
||||
super(connection);
|
||||
this.gamemode = gamemode;
|
||||
this.dimension = dimension;
|
||||
this.dimensionType = dimensionType;
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
public RespawnEvent(PlayConnection connection, RespawnS2CP pkg) {
|
||||
super(connection);
|
||||
this.gamemode = pkg.getGamemode();
|
||||
this.dimension = pkg.getDimension();
|
||||
this.dimensionType = pkg.getDimension();
|
||||
this.difficulty = pkg.getDifficulty();
|
||||
}
|
||||
|
||||
@ -43,8 +44,8 @@ public class RespawnEvent extends PlayConnectionEvent {
|
||||
return this.gamemode;
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
return this.dimension;
|
||||
public DimensionType getDimensionType() {
|
||||
return this.dimensionType;
|
||||
}
|
||||
|
||||
public Difficulties getDifficulty() {
|
||||
|
@ -128,6 +128,7 @@ public class BlockingSocketNetwork extends Network {
|
||||
socketSendThread.interrupt();
|
||||
}
|
||||
if (exception instanceof SocketException && exception.getMessage().equals("Socket closed")) {
|
||||
Log.log(LogMessageType.NETWORK_STATUS, LogLevels.INFO, "Socket closed, disconnecting...");
|
||||
this.connection.setProtocolState(ProtocolStates.DISCONNECTED);
|
||||
return;
|
||||
}
|
||||
|
@ -16,8 +16,9 @@ import com.google.common.collect.HashBiMap
|
||||
import de.bixilon.minosoft.data.Difficulties
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.registries.DefaultRegistries
|
||||
import de.bixilon.minosoft.data.registries.Dimension
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.dimension.Dimension
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType
|
||||
import de.bixilon.minosoft.data.world.biome.accessor.BlockBiomeAccessor
|
||||
import de.bixilon.minosoft.data.world.biome.accessor.NoiseBiomeAccessor
|
||||
import de.bixilon.minosoft.modding.channels.DefaultPluginChannels
|
||||
@ -47,7 +48,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
val entityId: Int
|
||||
val isHardcore: Boolean
|
||||
val gamemode: Gamemodes
|
||||
var dimension: Dimension
|
||||
var dimensionType: DimensionType
|
||||
private set
|
||||
var difficulty: Difficulties = Difficulties.NORMAL
|
||||
private set
|
||||
@ -65,6 +66,10 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
private set
|
||||
var dimensions: HashBiMap<ResourceLocation, Dimension> = HashBiMap.create()
|
||||
private set
|
||||
var worlds: Array<ResourceLocation>? = null
|
||||
private set
|
||||
var world: ResourceLocation? = null
|
||||
private set
|
||||
|
||||
init {
|
||||
entityId = buffer.readInt()
|
||||
@ -80,7 +85,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
if (buffer.versionId < ProtocolVersions.V_1_9_1) {
|
||||
dimension = buffer.connection.registries.dimensionRegistry[buffer.readByte().toInt()]
|
||||
dimensionType = buffer.connection.registries.dimensionRegistry[buffer.readByte().toInt()].type
|
||||
difficulty = Difficulties[buffer.readUnsignedByte()]
|
||||
maxPlayers = buffer.readByte().toInt()
|
||||
if (buffer.versionId >= ProtocolVersions.V_13W42B) {
|
||||
@ -94,20 +99,19 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
buffer.readByte() // previous game mode
|
||||
}
|
||||
if (buffer.versionId >= ProtocolVersions.V_20W22A) {
|
||||
buffer.readStringArray() // dimensions
|
||||
worlds = buffer.readArray { buffer.readResourceLocation() }
|
||||
}
|
||||
if (buffer.versionId < ProtocolVersions.V_20W21A) {
|
||||
dimension = buffer.connection.registries.dimensionRegistry[buffer.readInt()]
|
||||
dimensionType = buffer.connection.registries.dimensionRegistry[buffer.readInt()].type
|
||||
} else {
|
||||
val dimensionCodec = buffer.readNBT().asCompound()
|
||||
dimensions = parseDimensionCodec(dimensionCodec, buffer.versionId)
|
||||
if (buffer.versionId < ProtocolVersions.V_1_16_2_PRE3) {
|
||||
dimension = dimensions[buffer.readResourceLocation()]!!
|
||||
dimensionType = if (buffer.versionId < ProtocolVersions.V_1_16_2_PRE3) {
|
||||
dimensions[buffer.readResourceLocation()]!!.type
|
||||
} else {
|
||||
buffer.readNBT()!!.compoundCast() // dimension tag
|
||||
DimensionType.deserialize(buffer.readNBT().asCompound())
|
||||
}
|
||||
val currentDimension = buffer.readResourceLocation()
|
||||
dimension = dimensions[currentDimension] ?: buffer.connection.registries.dimensionRegistry[currentDimension]!!
|
||||
world = buffer.readResourceLocation()
|
||||
}
|
||||
|
||||
if (buffer.versionId >= ProtocolVersions.V_19W36A) {
|
||||
@ -146,7 +150,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
|
||||
connection.world.hardcore = isHardcore
|
||||
connection.registries.dimensionRegistry.setData(dimensions)
|
||||
connection.world.dimension = dimension
|
||||
connection.world.dimension = dimensionType
|
||||
|
||||
connection.world.entities.add(entityId, null, playerEntity)
|
||||
connection.world.hashedSeed = hashedSeed
|
||||
@ -178,7 +182,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
"key"
|
||||
} else {
|
||||
"name"
|
||||
}].unsafeCast<String>())
|
||||
}].unsafeCast())
|
||||
val dimensionPropertyTag = if (versionId < ProtocolVersions.V_1_16_PRE3 || versionId >= ProtocolVersions.V_1_16_2_PRE1) {
|
||||
tag["element"].asCompound()
|
||||
} else {
|
||||
@ -190,7 +194,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Join game (entityId=$entityId, gamemode=$gamemode, dimension=$dimension, difficulty=$difficulty, hardcore=$isHardcore, viewDistance=$viewDistance)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Join game (entityId=$entityId, gamemode=$gamemode, dimensionType=$dimensionType, difficulty=$difficulty, hardcore=$isHardcore, viewDistance=$viewDistance)" }
|
||||
}
|
||||
|
||||
companion object : ErrorHandler {
|
||||
|
@ -14,7 +14,8 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||
|
||||
import de.bixilon.minosoft.data.Difficulties
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.registries.Dimension
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.events.RespawnEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
@ -24,11 +25,11 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.asCompound
|
||||
import glm_.vec3.Vec3d
|
||||
|
||||
class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
lateinit var dimension: Dimension
|
||||
lateinit var dimension: DimensionType
|
||||
private set
|
||||
var difficulty: Difficulties = Difficulties.NORMAL
|
||||
private set
|
||||
@ -43,6 +44,8 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
private set
|
||||
var copyMetaData = false
|
||||
private set
|
||||
var world: ResourceLocation? = null
|
||||
private set
|
||||
|
||||
init {
|
||||
when {
|
||||
@ -51,20 +54,20 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
buffer.readByte().toInt()
|
||||
} else {
|
||||
buffer.readInt()
|
||||
}]
|
||||
}].type
|
||||
}
|
||||
buffer.versionId < ProtocolVersions.V_1_16_2_PRE3 -> {
|
||||
dimension = buffer.connection.registries.dimensionRegistry[buffer.readResourceLocation()]!!
|
||||
dimension = buffer.connection.registries.dimensionRegistry[buffer.readResourceLocation()]!!.type
|
||||
}
|
||||
else -> {
|
||||
buffer.readNBT()?.compoundCast() // current dimension data
|
||||
dimension = DimensionType.deserialize(buffer.readNBT().asCompound()) // current dimension data
|
||||
}
|
||||
}
|
||||
if (buffer.versionId < ProtocolVersions.V_19W11A) {
|
||||
difficulty = Difficulties[buffer.readUnsignedByte()]
|
||||
}
|
||||
if (buffer.versionId >= ProtocolVersions.V_20W22A) {
|
||||
dimension = buffer.connection.registries.dimensionRegistry[buffer.readResourceLocation()]!!
|
||||
world = buffer.readResourceLocation()
|
||||
}
|
||||
if (buffer.versionId >= ProtocolVersions.V_19W36A) {
|
||||
hashedSeed = buffer.readLong()
|
||||
|
@ -29,7 +29,7 @@ class StatusPongS2CP(buffer: InByteBuffer) : StatusS2CPacket() {
|
||||
val pingQuery = connection.pingQuery ?: return
|
||||
if (pingQuery.pingId != pingId) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN) { "Unknown status pong (pingId=$pingId, expected=${pingQuery.pingId})" }
|
||||
return
|
||||
// return ToDo: feather-rs is sending a wrong ping id back
|
||||
}
|
||||
val latency = System.currentTimeMillis() - pingQuery.time
|
||||
connection.disconnect()
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
package de.bixilon.minosoft.util.chunk
|
||||
|
||||
import de.bixilon.minosoft.data.registries.Dimension
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType
|
||||
import de.bixilon.minosoft.data.world.ChunkData
|
||||
import de.bixilon.minosoft.data.world.ChunkSection
|
||||
import de.bixilon.minosoft.data.world.biome.source.XZBiomeArray
|
||||
@ -30,14 +30,14 @@ import java.util.*
|
||||
|
||||
object ChunkUtil {
|
||||
|
||||
fun readChunkPacket(buffer: PlayInByteBuffer, dimension: Dimension, sectionBitMask: BitSet, addBitMask: BitSet? = null, isFullChunk: Boolean, containsSkyLight: Boolean): ChunkData? {
|
||||
fun readChunkPacket(buffer: PlayInByteBuffer, dimension: DimensionType, sectionBitMask: BitSet, addBitMask: BitSet? = null, isFullChunk: Boolean, containsSkyLight: Boolean): ChunkData? {
|
||||
if (buffer.versionId < V_15W35A) { // ToDo: was this really changed in 62?
|
||||
return readLegacyChunk(buffer, dimension, sectionBitMask, addBitMask, isFullChunk, containsSkyLight)
|
||||
}
|
||||
return readPaletteChunk(buffer, dimension, sectionBitMask, isFullChunk, containsSkyLight)
|
||||
}
|
||||
|
||||
private fun readLegacyChunkWithAddBitSet(buffer: PlayInByteBuffer, dimension: Dimension, sectionBitMask: BitSet, addBitMask: BitSet, isFullChunk: Boolean, containsSkyLight: Boolean): ChunkData {
|
||||
private fun readLegacyChunkWithAddBitSet(buffer: PlayInByteBuffer, dimension: DimensionType, sectionBitMask: BitSet, addBitMask: BitSet, isFullChunk: Boolean, containsSkyLight: Boolean): ChunkData {
|
||||
val chunkData = ChunkData()
|
||||
chunkData.lightAccessor = DummyLightAccessor // ToDo
|
||||
|
||||
@ -97,7 +97,7 @@ object ChunkUtil {
|
||||
return chunkData
|
||||
}
|
||||
|
||||
fun readLegacyChunk(buffer: PlayInByteBuffer, dimension: Dimension, sectionBitMask: BitSet, addBitMask: BitSet? = null, isFullChunk: Boolean, containsSkyLight: Boolean = false): ChunkData? {
|
||||
fun readLegacyChunk(buffer: PlayInByteBuffer, dimension: DimensionType, sectionBitMask: BitSet, addBitMask: BitSet? = null, isFullChunk: Boolean, containsSkyLight: Boolean = false): ChunkData? {
|
||||
if (sectionBitMask.length() == 0 && isFullChunk) {
|
||||
// unload chunk
|
||||
return null
|
||||
@ -142,7 +142,7 @@ object ChunkUtil {
|
||||
return chunkData
|
||||
}
|
||||
|
||||
fun readPaletteChunk(buffer: PlayInByteBuffer, dimension: Dimension, sectionBitMask: BitSet, isFullChunk: Boolean, containsSkyLight: Boolean = false): ChunkData {
|
||||
fun readPaletteChunk(buffer: PlayInByteBuffer, dimension: DimensionType, sectionBitMask: BitSet, isFullChunk: Boolean, containsSkyLight: Boolean = false): ChunkData {
|
||||
val chunkData = ChunkData()
|
||||
val sectionMap: MutableMap<Int, ChunkSection> = synchronizedMapOf()
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.chunk
|
||||
|
||||
import de.bixilon.minosoft.data.registries.Dimension
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionType
|
||||
import de.bixilon.minosoft.data.world.light.ChunkLightAccessor
|
||||
import de.bixilon.minosoft.data.world.light.LightAccessor
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
@ -23,7 +23,7 @@ import java.util.*
|
||||
|
||||
object LightUtil {
|
||||
|
||||
fun readLightPacket(buffer: PlayInByteBuffer, skyLightMask: BitSet, blockLightMask: BitSet, dimension: Dimension): LightAccessor {
|
||||
fun readLightPacket(buffer: PlayInByteBuffer, skyLightMask: BitSet, blockLightMask: BitSet, dimension: DimensionType): LightAccessor {
|
||||
// ToDo
|
||||
val skyLight = if (dimension.hasSkyLight || buffer.versionId > V_1_16) { // ToDo: find out version
|
||||
readLightArray(buffer, skyLightMask, dimension)
|
||||
@ -34,7 +34,7 @@ object LightUtil {
|
||||
return ChunkLightAccessor(blockLight, skyLight)
|
||||
}
|
||||
|
||||
private fun readLightArray(buffer: PlayInByteBuffer, lightMask: BitSet, dimension: Dimension): MutableMap<Int, ByteArray> {
|
||||
private fun readLightArray(buffer: PlayInByteBuffer, lightMask: BitSet, dimension: DimensionType): MutableMap<Int, ByteArray> {
|
||||
var highestSectionIndex = dimension.highestSection + 1
|
||||
val lowesSectionIndex = dimension.lowestSection - 1
|
||||
if (buffer.versionId >= ProtocolVersions.V_20W49A) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user