fix several issues in new snapshots (with negative build height, new entities)

This commit is contained in:
Bixilon 2021-04-08 18:10:46 +02:00
parent 4b36103db1
commit 08e1227868
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 48 additions and 20 deletions

View File

@ -23,10 +23,7 @@ import de.bixilon.minosoft.data.entities.entities.animal.water.*
import de.bixilon.minosoft.data.entities.entities.boss.enderdragon.EndCrystal import de.bixilon.minosoft.data.entities.entities.boss.enderdragon.EndCrystal
import de.bixilon.minosoft.data.entities.entities.boss.enderdragon.EnderDragon import de.bixilon.minosoft.data.entities.entities.boss.enderdragon.EnderDragon
import de.bixilon.minosoft.data.entities.entities.boss.wither.WitherBoss import de.bixilon.minosoft.data.entities.entities.boss.wither.WitherBoss
import de.bixilon.minosoft.data.entities.entities.decoration.ArmorStand import de.bixilon.minosoft.data.entities.entities.decoration.*
import de.bixilon.minosoft.data.entities.entities.decoration.ItemFrame
import de.bixilon.minosoft.data.entities.entities.decoration.LeashFenceKnotEntity
import de.bixilon.minosoft.data.entities.entities.decoration.Painting
import de.bixilon.minosoft.data.entities.entities.item.FallingBlock import de.bixilon.minosoft.data.entities.entities.item.FallingBlock
import de.bixilon.minosoft.data.entities.entities.item.ItemEntity import de.bixilon.minosoft.data.entities.entities.item.ItemEntity
import de.bixilon.minosoft.data.entities.entities.item.PrimedTNT import de.bixilon.minosoft.data.entities.entities.item.PrimedTNT
@ -91,6 +88,7 @@ object DefaultEntityFactories {
Illusioner, Illusioner,
IronGolem, IronGolem,
ItemEntity, ItemEntity,
GlowItemFrame,
ItemFrame, ItemFrame,
LargeFireball, LargeFireball,
LeashFenceKnotEntity, LeashFenceKnotEntity,

View File

@ -0,0 +1,31 @@
/*
* Minosoft
* Copyright (C) 2021 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.entities.entities.decoration
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.entities.EntityFactory
import de.bixilon.minosoft.data.mappings.entities.EntityType
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import glm_.vec3.Vec3
class GlowItemFrame(connection: PlayConnection, entityType: EntityType, position: Vec3, rotation: EntityRotation) : ItemFrame(connection, entityType, position, rotation) {
companion object : EntityFactory<GlowItemFrame> {
override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("glow_item_frame")
override fun build(connection: PlayConnection, entityType: EntityType, position: Vec3, rotation: EntityRotation): GlowItemFrame {
return GlowItemFrame(connection, entityType, position, rotation)
}
}
}

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.data.mappings.entities.EntityType
import de.bixilon.minosoft.protocol.network.connection.PlayConnection import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import glm_.vec3.Vec3 import glm_.vec3.Vec3
class ItemFrame(connection: PlayConnection, entityType: EntityType, position: Vec3, rotation: EntityRotation) : HangingEntity(connection, entityType, position, rotation) { open class ItemFrame(connection: PlayConnection, entityType: EntityType, position: Vec3, rotation: EntityRotation) : HangingEntity(connection, entityType, position, rotation) {
@get:EntityMetaDataFunction(name = "Item") @get:EntityMetaDataFunction(name = "Item")
val item: ItemStack? val item: ItemStack?

View File

@ -89,7 +89,7 @@ data class Dimension(
hasRaids = data.get("has_raids")?.asBoolean == true, hasRaids = data.get("has_raids")?.asBoolean == true,
logicalHeight = data.get("logical_height")?.asInt ?: 256, logicalHeight = data.get("logical_height")?.asInt ?: 256,
coordinateScale = data.get("coordinate_scale")?.asDouble ?: 0.0, coordinateScale = data.get("coordinate_scale")?.asDouble ?: 0.0,
minY = data.get("min_y")?.asInt ?: 0, minY = data.get("minimum_y")?.asInt ?: 0,
hasCeiling = data.get("has_ceiling")?.asBoolean == true, hasCeiling = data.get("has_ceiling")?.asBoolean == true,
ultraWarm = data.get("ultrawarm")?.asBoolean == true, ultraWarm = data.get("ultrawarm")?.asBoolean == true,
height = data.get("height")?.asInt ?: 256, height = data.get("height")?.asInt ?: 256,

View File

@ -95,7 +95,7 @@ enum class BlockProperties {
LEGACY_SMOOTH("smooth", BooleanBlocKPropertiesSerializer), LEGACY_SMOOTH("smooth", BooleanBlocKPropertiesSerializer),
SCULK_SENSOR_PHASE("sculk_sensor_phase", SensorPhases), SCULK_SENSOR_PHASE("sculk_sensor_phase", SensorPhases),
DRIPSTONE_TILT("tilt", Tilts), DRIPSTONE_TILT("tilt", Tilts),
CAVE_VINES_BERRIES(BooleanBlocKPropertiesSerializer), CAVE_VINES_BERRIES("berries", BooleanBlocKPropertiesSerializer),
; ;
val group: String val group: String
@ -141,7 +141,7 @@ enum class BlockProperties {
throw IllegalArgumentException("Can not parse value $value for group $group") throw IllegalArgumentException("Can not parse value $value for group $group")
} }
return Pair(retProperty, retValue) return Pair(retProperty, retValue)
} ?: throw IllegalArgumentException("Can not find group: $group") } ?: throw IllegalArgumentException("Can not find group: $group, expected value $value")
} }
} }

View File

@ -99,11 +99,10 @@ class PacketJoinGame(buffer: PlayInByteBuffer) : PlayClientboundPacket() {
} else { } else {
buffer.readNBT() as CompoundTag // dimension tag buffer.readNBT() as CompoundTag // dimension tag
} }
val currentDimension = buffer.readResourceLocation()
dimension = dimensions[currentDimension] ?: buffer.connection.mapping.dimensionRegistry.get(currentDimension)!!
} }
if (buffer.versionId >= ProtocolVersions.V_20W22A) {
dimension = buffer.connection.mapping.dimensionRegistry.get(buffer.readResourceLocation())!!
}
if (buffer.versionId >= ProtocolVersions.V_19W36A) { if (buffer.versionId >= ProtocolVersions.V_19W36A) {
hashedSeed = buffer.readLong() hashedSeed = buffer.readLong()
} }

View File

@ -60,8 +60,8 @@ object ChunkUtil {
// parse data // parse data
var arrayPosition = 0 var arrayPosition = 0
val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap()) val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap())
for (sectionHeight in dimension.lowestSection until dimension.highestSection) { for ((sectionIndex, sectionHeight) in (dimension.lowestSection until dimension.highestSection).withIndex()) {
if (!sectionBitMask.get(sectionHeight)) { if (!sectionBitMask[sectionIndex]) {
continue continue
} }
@ -94,7 +94,7 @@ object ChunkUtil {
blocks[blockNumber] = buffer.connection.mapping.getBlockState(blockId) ?: continue blocks[blockNumber] = buffer.connection.mapping.getBlockState(blockId) ?: continue
} }
sectionMap[dimension.lowestSection + sectionHeight] = ChunkSection(blocks) sectionMap[sectionHeight] = ChunkSection(blocks)
} }
chunkData.blocks = sectionMap chunkData.blocks = sectionMap
return chunkData return chunkData
@ -129,8 +129,8 @@ object ChunkUtil {
var arrayPos = 0 var arrayPos = 0
val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap()) val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap())
for (sectionHeight in dimension.lowestSection until dimension.highestSection) { // max sections per chunks in chunk column for ((sectionIndex, sectionHeight) in (dimension.lowestSection until dimension.highestSection).withIndex()) { // max sections per chunks in chunk column
if (!sectionBitMask.get(sectionHeight)) { if (!sectionBitMask[sectionIndex]) {
continue continue
} }
val blocks = arrayOfNulls<BlockState>(ProtocolDefinition.BLOCKS_PER_SECTION) val blocks = arrayOfNulls<BlockState>(ProtocolDefinition.BLOCKS_PER_SECTION)
@ -139,7 +139,7 @@ object ChunkUtil {
val block = buffer.connection.mapping.getBlockState(blockId) ?: continue val block = buffer.connection.mapping.getBlockState(blockId) ?: continue
blocks[blockNumber] = block blocks[blockNumber] = block
} }
sectionMap[dimension.lowestSection + sectionHeight] = ChunkSection(blocks) sectionMap[sectionHeight] = ChunkSection(blocks)
} }
chunkData.blocks = sectionMap chunkData.blocks = sectionMap
return chunkData return chunkData
@ -149,8 +149,8 @@ object ChunkUtil {
val chunkData = ChunkData() val chunkData = ChunkData()
val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap()) val sectionMap: MutableMap<Int, ChunkSection> = Collections.synchronizedMap(ConcurrentHashMap())
for (sectionHeight in dimension.lowestSection until sectionBitMask.length()) { // max sections per chunks in chunk column for ((sectionIndex, sectionHeight) in (dimension.lowestSection until sectionBitMask.length()).withIndex()) { // max sections per chunks in chunk column
if (!sectionBitMask[sectionHeight]) { if (!sectionBitMask[sectionIndex]) {
continue continue
} }
if (buffer.versionId >= V_18W43A) { if (buffer.versionId >= V_18W43A) {
@ -195,7 +195,7 @@ object ChunkUtil {
} }
// ToDo // ToDo
} }
sectionMap[dimension.lowestSection + sectionHeight] = ChunkSection(blocks) sectionMap[sectionHeight] = ChunkSection(blocks)
} }
chunkData.blocks = sectionMap chunkData.blocks = sectionMap