rework entity data reading

This commit is contained in:
Bixilon 2022-04-24 16:22:04 +02:00
parent 71369fde96
commit 0dfc70dd23
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
51 changed files with 759 additions and 163 deletions

View File

@ -16,11 +16,9 @@ import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.entities.entities.animal.Axolotl
import de.bixilon.minosoft.data.entities.entities.decoration.armorstand.ArmorStandArmRotation
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerData
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerLevels
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerTypes
import de.bixilon.minosoft.data.entities.entities.vehicle.boat.Boat
import de.bixilon.minosoft.data.entities.meta.ArmorStandArmRotation
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.particle.ParticleType
import de.bixilon.minosoft.data.registries.particle.data.ParticleData

View File

@ -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.data.entities
class GlobalPosition

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* 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.
*
@ -19,13 +19,13 @@ import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
import de.bixilon.minosoft.data.registries.registries.registry.ResourceLocationDeserializer
class BlockEntityMetaType(
class BlockDataDataType(
override val resourceLocation: ResourceLocation,
) : RegistryItem() {
companion object : ResourceLocationDeserializer<BlockEntityMetaType> {
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): BlockEntityMetaType {
return BlockEntityMetaType(resourceLocation)
companion object : ResourceLocationDeserializer<BlockDataDataType> {
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): BlockDataDataType {
return BlockDataDataType(resourceLocation)
}
}
}

View File

@ -11,26 +11,21 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.meta
package de.bixilon.minosoft.data.entities.data
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.Poses
import de.bixilon.minosoft.data.entities.entities.decoration.armorstand.ArmorStandArmRotation
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerData
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerLevels
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerTypes
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.data.registries.particle.data.ParticleData
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import de.bixilon.minosoft.util.BitByte
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
@ -48,94 +43,13 @@ class EntityData(
return sets.toString()
}
fun getData(type: EntityDataDataTypes, buffer: PlayInByteBuffer): Any? {
return when (type) {
EntityDataDataTypes.BYTE -> buffer.readByte()
EntityDataDataTypes.VAR_INT -> buffer.readVarInt()
EntityDataDataTypes.SHORT -> buffer.readUnsignedShort()
EntityDataDataTypes.INTEGER -> if (buffer.versionId < ProtocolVersions.V_1_13) buffer.readInt() else buffer.readVarInt() // ToDo: version
EntityDataDataTypes.FLOAT -> buffer.readFloat()
EntityDataDataTypes.STRING -> buffer.readString()
EntityDataDataTypes.TEXT_COMPONENT -> buffer.readChatComponent()
EntityDataDataTypes.BOOLEAN -> buffer.readBoolean()
EntityDataDataTypes.VEC3I -> {
if (buffer.versionId < ProtocolVersions.V_1_8_PRE3) {
Vec3i(buffer.readInt(), buffer.readInt(), buffer.readInt())
} else {
buffer.readBlockPosition()
}
}
EntityDataDataTypes.ITEM_STACK -> buffer.readItemStack()
EntityDataDataTypes.ROTATION -> ArmorStandArmRotation(buffer.readFloat(), buffer.readFloat(), buffer.readFloat())
EntityDataDataTypes.OPTIONAL_TEXT_COMPONENT -> buffer.readOptional { buffer.readChatComponent() }
EntityDataDataTypes.OPTIONAL_VEC3I -> buffer.readOptional { buffer.readBlockPosition() }
EntityDataDataTypes.DIRECTION -> buffer.readDirection()
EntityDataDataTypes.OPTIONAL_UUID -> buffer.readOptional { buffer.readUUID() }
EntityDataDataTypes.NBT -> buffer.readNBT()
EntityDataDataTypes.PARTICLE -> buffer.readParticle()
EntityDataDataTypes.POSE -> buffer.readPose()
EntityDataDataTypes.BLOCK_STATE -> buffer.connection.registries.blockStateRegistry[buffer.readVarInt()] // ToDo
EntityDataDataTypes.VILLAGER_DATA -> VillagerData(VillagerTypes[buffer.readVarInt()], connection.registries.villagerProfessionRegistry[buffer.readVarInt()].resourceLocation, VillagerLevels[buffer.readVarInt()])
EntityDataDataTypes.OPTIONAL_BLOCK_STATE -> buffer.connection.registries.blockStateRegistry[buffer.readVarInt()]
EntityDataDataTypes.OPTIONAL_INTEGER, EntityDataDataTypes.FIREWORK_DATA -> {
val int = buffer.readVarInt()
if (int == 0) {
return null
}
return int - 1
}
EntityDataDataTypes.GLOBAL_POSITION -> buffer.readNBT() // ToDo
EntityDataDataTypes.OPTIONAL_GLOBAL_POSITION -> buffer.readPlayOptional { readNBT() } // ToDo
EntityDataDataTypes.MOTIVE -> buffer.connection.registries.motiveRegistry[buffer.readVarInt()]
EntityDataDataTypes.CAT_VARIANT, EntityDataDataTypes.FROG_VARIANT -> buffer.readVarInt() // ToDo
}
}
enum class EntityDataDataTypes {
BYTE,
SHORT,
INTEGER,
VAR_INT,
FLOAT,
STRING,
TEXT_COMPONENT,
OPTIONAL_TEXT_COMPONENT,
ITEM_STACK,
BOOLEAN,
VEC3I,
ROTATION,
OPTIONAL_VEC3I,
DIRECTION,
OPTIONAL_UUID,
BLOCK_STATE,
OPTIONAL_BLOCK_STATE,
NBT,
PARTICLE,
VILLAGER_DATA,
POSE,
OPTIONAL_INTEGER,
FIREWORK_DATA,
GLOBAL_POSITION,
OPTIONAL_GLOBAL_POSITION,
MOTIVE,
CAT_VARIANT,
FROG_VARIANT,
;
companion object : ValuesEnum<EntityDataDataTypes> {
override val VALUES = values()
override val NAME_MAP: Map<String, EntityDataDataTypes> = EnumUtil.getEnumValues(VALUES)
}
}
inner class EntityDataHashMap : Int2ObjectOpenHashMap<Any>() {
operator fun <K> get(field: EntityDataFields): K {
inline operator fun <reified K> get(field: EntityDataFields): K? {
lock.acquire()
try {
val index: Int = this@EntityData.connection.registries.getEntityMetaDataIndex(field) ?: return field.defaultValue.unsafeCast() // Can not find field.
val data = get(index) ?: return null
get(index)?.let {
try {
return it as K

View File

@ -0,0 +1,25 @@
/*
* 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.data.entities.data.types
import de.bixilon.minosoft.data.entities.data.types.registry.RegistryEntityDataType
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object BlockStateEntityDataType : RegistryEntityDataType<BlockState> {
override fun read(buffer: PlayInByteBuffer): BlockState? {
return read(buffer, buffer.connection.registries.blockStateRegistry)
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* 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.
*
@ -11,21 +11,13 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.entities.npc.villager.data
package de.bixilon.minosoft.data.entities.data.types
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
enum class VillagerLevels {
NOVICE,
APPRENTICE,
JOURNEYMAN,
EXPERT,
MASTER,
;
object BooleanEntityDataType : EntityDataType<Boolean> {
companion object : ValuesEnum<VillagerLevels> {
override val VALUES = values()
override val NAME_MAP: Map<String, VillagerLevels> = EnumUtil.getEnumValues(VALUES)
override fun read(buffer: PlayInByteBuffer): Boolean {
return buffer.readBoolean()
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* 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.
*
@ -11,23 +11,13 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.entities.npc.villager.data
package de.bixilon.minosoft.data.entities.data.types
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
enum class VillagerTypes {
DESSERT,
JUNGLE,
PLAINS,
SAVANNA,
SNOW,
SWAMP,
TAIGA,
;
object ByteEntityDataType : EntityDataType<Byte> {
companion object : ValuesEnum<VillagerTypes> {
override val VALUES = values()
override val NAME_MAP: Map<String, VillagerTypes> = EnumUtil.getEnumValues(VALUES)
override fun read(buffer: PlayInByteBuffer): Byte {
return buffer.readByte()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object ChatComponentEntityDataType : EntityDataType<ChatComponent> {
override fun read(buffer: PlayInByteBuffer): ChatComponent {
return buffer.readChatComponent()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object DirectionEntityDataType : EntityDataType<Directions> {
override fun read(buffer: PlayInByteBuffer): Directions {
return buffer.readDirection()
}
}

View File

@ -0,0 +1,58 @@
/*
* 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.data.entities.data.types
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.minosoft.data.entities.data.types.registry.MotiveEntityDataType
import de.bixilon.minosoft.data.entities.data.types.registry.VariantsEntityDataType
enum class EntityDataDataTypes(val type: EntityDataType<*>) {
BYTE(ByteEntityDataType),
SHORT(ShortEntityDataType),
INTEGER(IntEntityDataType),
VAR_INT(VarIntEntityDataType),
FLOAT(FloatEntityDataType),
STRING(StringEntityDataType),
TEXT_COMPONENT(ChatComponentEntityDataType),
OPTIONAL_TEXT_COMPONENT(OptionalChatComponentEntityDataType),
ITEM_STACK(ItemStackEntityDataType),
BOOLEAN(BooleanEntityDataType),
VEC3I(Vec3iEntityDataType),
ROTATION(Vec3EntityDataType),
OPTIONAL_VEC3I(OptionalVec3iEntityDataType),
DIRECTION(DirectionEntityDataType),
OPTIONAL_UUID(OptionalUUIDEntityDataType),
BLOCK_STATE(BlockStateEntityDataType),
OPTIONAL_BLOCK_STATE(BlockStateEntityDataType),
NBT(NbtEntityDataType),
PARTICLE(ParticleDataEntityDataType),
VILLAGER_DATA(VillagerDataEntityDataType),
POSE(PoseEntityDataType),
OPTIONAL_INTEGER(OptionalIntEntityDataType),
FIREWORK_DATA(OptionalIntEntityDataType),
GLOBAL_POSITION(GlobalPositionEntityDataType),
OPTIONAL_GLOBAL_POSITION(OptionalGlobalPositionEntityDataType),
MOTIVE(MotiveEntityDataType),
CAT_VARIANT(VariantsEntityDataType.CatVariantType),
FROG_VARIANT(VariantsEntityDataType.FrogVariantType),
;
companion object : ValuesEnum<EntityDataDataTypes> {
override val VALUES = values()
override val NAME_MAP: Map<String, EntityDataDataTypes> = EnumUtil.getEnumValues(VALUES)
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
interface EntityDataType<T> {
fun read(buffer: PlayInByteBuffer): T?
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object FloatEntityDataType : EntityDataType<Float> {
override fun read(buffer: PlayInByteBuffer): Float {
return buffer.readFloat()
}
}

View File

@ -0,0 +1,31 @@
/*
* 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.data.entities.data.types
import de.bixilon.kutil.json.JsonObject
import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.minosoft.data.entities.GlobalPosition
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object GlobalPositionEntityDataType : EntityDataType<GlobalPosition> {
override fun read(buffer: PlayInByteBuffer): GlobalPosition? {
return buffer.readNBT()?.toJsonObject()?.toGlobalPosition()
}
fun JsonObject.toGlobalPosition(): GlobalPosition {
TODO("Not yet implemented")
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_13
object IntEntityDataType : EntityDataType<Int> {
override fun read(buffer: PlayInByteBuffer): Int {
if (buffer.versionId < V_1_13) { // ToDo: Version
return buffer.readInt()
}
return buffer.readVarInt()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object ItemStackEntityDataType : EntityDataType<ItemStack> {
override fun read(buffer: PlayInByteBuffer): ItemStack? {
return buffer.readItemStack()
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.data.entities.data.types
import com.google.gson.JsonObject
import de.bixilon.kutil.cast.CastUtil.nullCast
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object NbtEntityDataType : EntityDataType<JsonObject> {
override fun read(buffer: PlayInByteBuffer): JsonObject? {
return buffer.readNBT().nullCast()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object OptionalChatComponentEntityDataType : EntityDataType<ChatComponent> {
override fun read(buffer: PlayInByteBuffer): ChatComponent? {
return buffer.readPlayOptional { readChatComponent() }
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.entities.GlobalPosition
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object OptionalGlobalPositionEntityDataType : EntityDataType<GlobalPosition> {
override fun read(buffer: PlayInByteBuffer): GlobalPosition? {
return buffer.readOptional { GlobalPositionEntityDataType.read(buffer) }
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object OptionalIntEntityDataType : EntityDataType<Int> {
override fun read(buffer: PlayInByteBuffer): Int? {
val int = buffer.readVarInt()
if (int == 0) {
return null
}
return int - 1
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import java.util.*
object OptionalUUIDEntityDataType : EntityDataType<UUID> {
override fun read(buffer: PlayInByteBuffer): UUID? {
return buffer.readPlayOptional { buffer.readUUID() }
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object OptionalVec3iEntityDataType : EntityDataType<Vec3i> {
override fun read(buffer: PlayInByteBuffer): Vec3i? {
return buffer.readPlayOptional { buffer.readBlockPosition() }
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.registries.particle.data.ParticleData
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object ParticleDataEntityDataType : EntityDataType<ParticleData> {
override fun read(buffer: PlayInByteBuffer): ParticleData {
return buffer.readParticleData()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.data.entities.Poses
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object PoseEntityDataType : EntityDataType<Poses> {
override fun read(buffer: PlayInByteBuffer): Poses {
return buffer.readPose()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object ShortEntityDataType : EntityDataType<Short> {
override fun read(buffer: PlayInByteBuffer): Short {
return buffer.readShort()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object StringEntityDataType : EntityDataType<String> {
override fun read(buffer: PlayInByteBuffer): String {
return buffer.readString()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object VarIntEntityDataType : EntityDataType<Int> {
override fun read(buffer: PlayInByteBuffer): Int {
return buffer.readVarInt()
}
}

View File

@ -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.data.entities.data.types
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object Vec3EntityDataType : EntityDataType<Vec3> {
override fun read(buffer: PlayInByteBuffer): Vec3 {
return buffer.readVec3f()
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.data.entities.data.types
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
object Vec3iEntityDataType : EntityDataType<Vec3i> {
override fun read(buffer: PlayInByteBuffer): Vec3i {
if (buffer.versionId < ProtocolVersions.V_1_8_PRE3) {
return Vec3i(buffer.readInt(), buffer.readInt(), buffer.readInt())
}
return buffer.readBlockPosition()
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.data.entities.data.types
import de.bixilon.minosoft.data.entities.data.types.registry.RegistryEntityDataType
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerData
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object VillagerDataEntityDataType : RegistryEntityDataType<VillagerData> {
override fun read(buffer: PlayInByteBuffer): VillagerData? {
val type = read(buffer, buffer.connection.registries.villagerTypeRegistry) ?: return null
val profession = read(buffer, buffer.connection.registries.villagerProfessionRegistry) ?: return null
val level = buffer.readVarInt()
return VillagerData(type, profession, level)
}
}

View File

@ -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.data.entities.data.types.registry
import de.bixilon.minosoft.data.registries.Motive
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
object MotiveEntityDataType : RegistryEntityDataType<Motive> {
override fun read(buffer: PlayInByteBuffer): Motive? {
return read(buffer, buffer.connection.registries.motiveRegistry)
}
}

View File

@ -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.data.entities.data.types.registry
import de.bixilon.minosoft.data.entities.data.types.EntityDataType
import de.bixilon.minosoft.data.registries.registries.registry.AbstractRegistry
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
interface RegistryEntityDataType<T> : EntityDataType<T> {
fun <R> read(buffer: PlayInByteBuffer, registry: AbstractRegistry<R>): R? {
return registry[buffer.readVarInt()]
}
}

View File

@ -0,0 +1,31 @@
/*
* 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.data.entities.data.types.registry
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
class VariantsEntityDataType {
object CatVariantType : RegistryEntityDataType<Any> {
override fun read(buffer: PlayInByteBuffer): Any? {
TODO("Cat variant")
}
}
object FrogVariantType : RegistryEntityDataType<Any> {
override fun read(buffer: PlayInByteBuffer): Any? {
TODO("Frog variant")
}
}
}

View File

@ -28,9 +28,9 @@ import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.Poses
import de.bixilon.minosoft.data.entities.StatusEffectInstance
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
import de.bixilon.minosoft.data.entities.entities.vehicle.boat.Boat
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.physics.PhysicsEntity
import de.bixilon.minosoft.data.player.LocalPlayerEntity
import de.bixilon.minosoft.data.registries.AABB

View File

@ -10,14 +10,13 @@
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.entities.decoration
package de.bixilon.minosoft.data.entities.entities.decoration.armorstand
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.entities.LivingEntity
import de.bixilon.minosoft.data.entities.entities.SynchronizedEntityData
import de.bixilon.minosoft.data.entities.meta.ArmorStandArmRotation
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.entities.EntityFactory
import de.bixilon.minosoft.data.registries.entities.EntityType

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* 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.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.meta
package de.bixilon.minosoft.data.entities.entities.decoration.armorstand
data class ArmorStandArmRotation(
val yaw: Float,

View File

@ -14,7 +14,7 @@ package de.bixilon.minosoft.data.entities.entities.monster
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.entities.EntityFactory
import de.bixilon.minosoft.data.registries.entities.EntityType

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
* 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.
*
@ -13,9 +13,10 @@
package de.bixilon.minosoft.data.entities.entities.npc.villager.data
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.entities.villagers.VillagerProfession
data class VillagerData(
val type: VillagerTypes,
val profession: ResourceLocation,
val level: VillagerLevels,
val type: ResourceLocation,
val profession: VillagerProfession,
val level: Int,
)

View File

@ -18,8 +18,8 @@ import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.assets.util.FileUtil.readJsonObject
import de.bixilon.minosoft.data.container.InventorySlots
import de.bixilon.minosoft.data.entities.EntityObjectType
import de.bixilon.minosoft.data.entities.block.BlockEntityMetaType
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.entities.block.BlockDataDataType
import de.bixilon.minosoft.data.entities.data.types.EntityDataDataTypes
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
import de.bixilon.minosoft.data.registries.registries.registry.PerVersionEnumRegistry
import de.bixilon.minosoft.data.registries.registries.registry.PerVersionRegistry
@ -40,7 +40,7 @@ object DefaultRegistries {
val ARMOR_EQUIPMENT_SLOTS_REGISTRY = PerVersionEnumRegistry(InventorySlots.EquipmentSlots)
val ARMOR_STAND_EQUIPMENT_SLOTS_REGISTRY = PerVersionEnumRegistry(InventorySlots.EquipmentSlots)
val ENTITY_META_DATA_DATA_TYPES_REGISTRY = PerVersionEnumRegistry(EntityData.EntityDataDataTypes)
val ENTITY_DATA_DATA_TYPES_REGISTRY = PerVersionEnumRegistry(EntityDataDataTypes)
val TITLE_ACTIONS_REGISTRY = PerVersionEnumRegistry(TitleS2CF.TitleActions)
@ -49,7 +49,7 @@ object DefaultRegistries {
val ENTITY_OBJECT_REGISTRY: Registry<EntityObjectType> = Registry()
val BLOCK_ENTITY_META_TYPE_REGISTRY: PerVersionRegistry<BlockEntityMetaType, Registry<BlockEntityMetaType>> = PerVersionRegistry { Registry() }
val BLOCK_DATA_TYPE_REGISTRY: PerVersionRegistry<BlockDataDataType, Registry<BlockDataDataType>> = PerVersionRegistry { Registry() }
val DEFAULT_PLUGIN_CHANNELS_REGISTRY: PerVersionRegistry<PluginChannel, Registry<PluginChannel>> = PerVersionRegistry { Registry() }
@ -69,7 +69,7 @@ object DefaultRegistries {
ARMOR_EQUIPMENT_SLOTS_REGISTRY.initialize(enumJson[ResourceLocation("armor_equipment_slots")].asJsonObject())
ARMOR_STAND_EQUIPMENT_SLOTS_REGISTRY.initialize(enumJson[ResourceLocation("armor_stand_equipment_slots")].asJsonObject())
ENTITY_META_DATA_DATA_TYPES_REGISTRY.initialize(enumJson[ResourceLocation("entity_meta_data_data_types")].asJsonObject()) // ToDo
ENTITY_DATA_DATA_TYPES_REGISTRY.initialize(enumJson[ResourceLocation("entity_data_data_types")].asJsonObject()) // ToDo
TITLE_ACTIONS_REGISTRY.initialize(enumJson[ResourceLocation("title_actions")].asJsonObject())
@ -83,7 +83,7 @@ object DefaultRegistries {
ENTITY_OBJECT_REGISTRY.rawInitialize(registriesJson[ResourceLocation("entity_objects")].asJsonObject(), null, EntityObjectType)
BLOCK_ENTITY_META_TYPE_REGISTRY.initialize(registriesJson[ResourceLocation("block_entity_meta_data_types")].asJsonObject(), BlockEntityMetaType)
BLOCK_DATA_TYPE_REGISTRY.initialize(registriesJson[ResourceLocation("block_data_data_types")].asJsonObject(), BlockDataDataType)
CONTAINER_TYPE_REGISTRY.initialize(registriesJson[ResourceLocation("container_types")].asJsonObject(), ContainerType)

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.data.registries.entities
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.EvokerFangs
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.*
import de.bixilon.minosoft.data.entities.entities.ambient.Bat
import de.bixilon.minosoft.data.entities.entities.animal.*
@ -25,6 +26,7 @@ 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.wither.WitherBoss
import de.bixilon.minosoft.data.entities.entities.decoration.*
import de.bixilon.minosoft.data.entities.entities.decoration.armorstand.ArmorStand
import de.bixilon.minosoft.data.entities.entities.item.FallingBlockEntity
import de.bixilon.minosoft.data.entities.entities.item.ItemEntity
import de.bixilon.minosoft.data.entities.entities.item.PrimedTNT
@ -39,7 +41,6 @@ import de.bixilon.minosoft.data.entities.entities.projectile.*
import de.bixilon.minosoft.data.entities.entities.vehicle.*
import de.bixilon.minosoft.data.entities.entities.vehicle.boat.Boat
import de.bixilon.minosoft.data.entities.entities.vehicle.boat.ChestBoat
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection

View File

@ -15,8 +15,8 @@ package de.bixilon.minosoft.data.registries.entities
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.registries.CompanionResourceLocation
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection

View File

@ -20,8 +20,8 @@ import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.kutil.primitive.BooleanUtil.toBoolean
import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.language.Translatable
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.items.SpawnEggItem

View File

@ -17,8 +17,8 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.minosoft.data.container.InventorySlots
import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.block.BlockEntityMetaType
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.entities.block.BlockDataDataType
import de.bixilon.minosoft.data.entities.data.types.EntityDataDataTypes
import de.bixilon.minosoft.data.registries.*
import de.bixilon.minosoft.data.registries.biomes.Biome
import de.bixilon.minosoft.data.registries.biomes.BiomeCategory
@ -66,13 +66,14 @@ class Registries {
val recipes = RecipeRegistry()
val villagerProfessionRegistry: Registry<VillagerProfession> = Registry()
val villagerTypeRegistry = ResourceLocationRegistry()
val equipmentSlotRegistry: EnumRegistry<InventorySlots.EquipmentSlots> = EnumRegistry(values = InventorySlots.EquipmentSlots)
val handEquipmentSlotRegistry: EnumRegistry<InventorySlots.EquipmentSlots> = EnumRegistry(values = InventorySlots.EquipmentSlots)
val armorEquipmentSlotRegistry: EnumRegistry<InventorySlots.EquipmentSlots> = EnumRegistry(values = InventorySlots.EquipmentSlots)
val armorStandEquipmentSlotRegistry: EnumRegistry<InventorySlots.EquipmentSlots> = EnumRegistry(values = InventorySlots.EquipmentSlots)
val entityDataDataDataTypesRegistry: EnumRegistry<EntityData.EntityDataDataTypes> = EnumRegistry(values = EntityData.EntityDataDataTypes)
val entityDataDataDataTypesRegistry: EnumRegistry<EntityDataDataTypes> = EnumRegistry(values = EntityDataDataTypes)
val titleActionsRegistry: EnumRegistry<TitleS2CF.TitleActions> = EnumRegistry(values = TitleS2CF.TitleActions)
@ -90,7 +91,7 @@ class Registries {
val entityTypeRegistry: Registry<EntityType> = Registry()
val blockEntityTypeRegistry = BlockEntityTypeRegistry()
val blockEntityMetaDataTypeRegistry: Registry<BlockEntityMetaType> = Registry()
val blockDataDataDataTypeRegistry: Registry<BlockDataDataType> = Registry()
val containerTypeRegistry: Registry<ContainerType> = Registry()
val gameEventRegistry: ResourceLocationRegistry = ResourceLocationRegistry()
@ -135,7 +136,7 @@ class Registries {
loadEnumRegistry(version, pixlyzerData["armor_equipment_slots"], armorEquipmentSlotRegistry, DefaultRegistries.ARMOR_EQUIPMENT_SLOTS_REGISTRY)
loadEnumRegistry(version, pixlyzerData["armor_stand_equipment_slots"], armorStandEquipmentSlotRegistry, DefaultRegistries.ARMOR_STAND_EQUIPMENT_SLOTS_REGISTRY)
loadEnumRegistry(version, pixlyzerData["entity_data_data_types"], entityDataDataDataTypesRegistry, DefaultRegistries.ENTITY_META_DATA_DATA_TYPES_REGISTRY)
loadEnumRegistry(version, pixlyzerData["entity_data_data_types"], entityDataDataDataTypesRegistry, DefaultRegistries.ENTITY_DATA_DATA_TYPES_REGISTRY)
loadEnumRegistry(version, pixlyzerData["title_actions"], titleActionsRegistry, DefaultRegistries.TITLE_ACTIONS_REGISTRY)
loadEnumRegistry(version, pixlyzerData["entity_animations"], entityAnimationRegistry, DefaultRegistries.ENTITY_ANIMATION_REGISTRY)
@ -169,9 +170,10 @@ class Registries {
blockEntityTypeRegistry.rawInitialize(pixlyzerData["block_entities"]?.toJsonObject(), this, BlockEntityType)
villagerProfessionRegistry.rawInitialize(pixlyzerData["villager_professions"]?.toJsonObject(), this, VillagerProfession)
villagerTypeRegistry.rawInitialize(pixlyzerData["villager_types"]?.toJsonObject(), this, VillagerProfession)
blockEntityMetaDataTypeRegistry.rawInitialize(pixlyzerData["block_entity_meta_data_types"]?.toJsonObject(), this, BlockEntityMetaType, alternative = DefaultRegistries.BLOCK_ENTITY_META_TYPE_REGISTRY.forVersion(version))
blockDataDataDataTypeRegistry.rawInitialize(pixlyzerData["block_data_data_types"]?.toJsonObject(), this, BlockDataDataType, alternative = DefaultRegistries.BLOCK_DATA_TYPE_REGISTRY.forVersion(version))
// post init

View File

@ -13,11 +13,11 @@
package de.bixilon.minosoft.data.registries.tweaker
import de.bixilon.minosoft.data.entities.EntityDataFields
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.entities.entities.animal.horse.*
import de.bixilon.minosoft.data.entities.entities.monster.*
import de.bixilon.minosoft.data.entities.entities.vehicle.*
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
object VersionTweaker {

View File

@ -14,7 +14,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
import de.bixilon.minosoft.data.Trade
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.entities.entities.npc.villager.data.VillagerLevels
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer

View File

@ -35,7 +35,7 @@ class BlockDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
val type = if (buffer.versionId >= V_21W37A) {
buffer.connection.registries.blockEntityTypeRegistry[buffer.readVarInt()].resourceLocation
} else {
buffer.connection.registries.blockEntityMetaDataTypeRegistry[buffer.readUnsignedByte()].resourceLocation
buffer.connection.registries.blockDataDataDataTypeRegistry[buffer.readUnsignedByte()].resourceLocation
}
val nbt = buffer.readNBT().asJsonObject()

View File

@ -12,7 +12,7 @@
*/
package de.bixilon.minosoft.protocol.packets.s2c.play.entity
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.modding.event.events.EntityDataChangeEvent
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket

View File

@ -14,9 +14,9 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.entity
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
import de.bixilon.minosoft.data.entities.entities.player.RemotePlayerEntity
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.player.properties.PlayerProperties
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection

View File

@ -14,8 +14,8 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket

View File

@ -16,7 +16,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.json.JsonUtil.toMutableJsonObject
import de.bixilon.minosoft.data.container.ItemStackUtil
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.entities.meta.EntityData
import de.bixilon.minosoft.data.entities.data.EntityData
import de.bixilon.minosoft.data.player.properties.PlayerProperties
import de.bixilon.minosoft.data.player.properties.textures.PlayerTextures
import de.bixilon.minosoft.data.registries.biomes.Biome
@ -84,7 +84,7 @@ class PlayInByteBuffer : InByteBuffer {
return ChatComponent.of(readString(), connection.language, null)
}
fun readParticle(): ParticleData {
fun readParticleData(): ParticleData {
val type = connection.registries.particleTypeRegistry[readVarInt()]
return readParticleData(type)
}

View File

@ -108,7 +108,7 @@
}
}
},
"minecraft:block_entity_meta_data_types": {
"minecraft:block_data_data_types": {
"0": {
"minecraft:spawner": {
"id": 1

View File

@ -40,7 +40,7 @@
"OFF_HAND"
]
},
"minecraft:entity_meta_data_data_types": {
"minecraft:entity_data_data_types": {
"0": [
"BYTE",
"SHORT",