mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
particle data: sculk, shriek, vibration
This commit is contained in:
parent
bef8e29d12
commit
bbf445d82b
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 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.particle.data
|
||||
|
||||
import de.bixilon.minosoft.data.registries.particle.ParticleType
|
||||
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
|
||||
|
||||
class SculkChargeParticleData(val roll: Float, type: ParticleType) : ParticleData(type) {
|
||||
|
||||
override fun toString(): String {
|
||||
return "$type: $roll"
|
||||
}
|
||||
|
||||
companion object : ParticleDataFactory<SculkChargeParticleData> {
|
||||
override fun read(buffer: PlayInByteBuffer, type: ParticleType): SculkChargeParticleData {
|
||||
return SculkChargeParticleData(buffer.readFloat(), type)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 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.particle.data
|
||||
|
||||
import de.bixilon.minosoft.data.registries.particle.ParticleType
|
||||
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
|
||||
|
||||
class ShriekParticleData(val delay: Int, type: ParticleType) : ParticleData(type) {
|
||||
override fun toString(): String {
|
||||
return "$type: $delay"
|
||||
}
|
||||
|
||||
companion object : ParticleDataFactory<ShriekParticleData> {
|
||||
override fun read(buffer: PlayInByteBuffer, type: ParticleType): ShriekParticleData {
|
||||
return ShriekParticleData(buffer.readVarInt(), type)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 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.particle.data
|
||||
|
||||
import de.bixilon.minosoft.data.registries.particle.ParticleType
|
||||
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
|
||||
|
||||
class VibrationParticleData(val source: Any, val arrival: Int, type: ParticleType) : ParticleData(type) {
|
||||
override fun toString(): String {
|
||||
return "$type: $source in $arrival"
|
||||
}
|
||||
|
||||
companion object : ParticleDataFactory<VibrationParticleData> {
|
||||
override fun read(buffer: PlayInByteBuffer, type: ParticleType): VibrationParticleData {
|
||||
val sourceType = buffer.readResourceLocation()
|
||||
val source: Any = when (sourceType.toString()) { // TODO: combine with VibrationS2CP
|
||||
"minecraft:block" -> buffer.readBlockPosition()
|
||||
"minecraft:entity" -> buffer.readEntityId()
|
||||
else -> error("Unknown target type: $sourceType")
|
||||
}
|
||||
val arrival = buffer.readVarInt()
|
||||
return VibrationParticleData(source, arrival, type)
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ class VibrationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
/**
|
||||
* @return Depends on vibration target type, if block: block postion, if entity: entity id
|
||||
*/
|
||||
val targetData: Any = when (targetType.toString()) {
|
||||
val targetData: Any = when (targetType.toString()) { // todo: combine with VibrationParticleData
|
||||
"minecraft:block" -> buffer.readBlockPosition()
|
||||
"minecraft:entity" -> buffer.readEntityId()
|
||||
else -> error("Unknown target type: $targetType")
|
||||
|
@ -16,17 +16,15 @@ import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.json.JsonUtil.toMutableJsonObject
|
||||
import de.bixilon.minosoft.data.chat.signature.*
|
||||
import de.bixilon.minosoft.data.chat.signature.ChatSignatureProperties
|
||||
import de.bixilon.minosoft.data.chat.signature.MessageHeader
|
||||
import de.bixilon.minosoft.data.container.ItemStackUtil
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.textures.PlayerTextures
|
||||
import de.bixilon.minosoft.data.registries.chat.ChatParameter
|
||||
import de.bixilon.minosoft.data.registries.particle.ParticleType
|
||||
import de.bixilon.minosoft.data.registries.particle.data.BlockParticleData
|
||||
import de.bixilon.minosoft.data.registries.particle.data.DustParticleData
|
||||
import de.bixilon.minosoft.data.registries.particle.data.ItemParticleData
|
||||
import de.bixilon.minosoft.data.registries.particle.data.ParticleData
|
||||
import de.bixilon.minosoft.data.registries.particle.data.*
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.AbstractRegistry
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.EnumRegistry
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.Registry
|
||||
@ -117,9 +115,12 @@ class PlayInByteBuffer : InByteBuffer {
|
||||
}
|
||||
|
||||
return when (type.identifier.toString()) {
|
||||
"minecraft:block", "minecraft:falling_dust" -> BlockParticleData.read(this, type)
|
||||
"minecraft:block", "minecraft:falling_dust", "minecraft:block_marker" -> BlockParticleData.read(this, type)
|
||||
"minecraft:dust" -> DustParticleData.read(this, type)
|
||||
"minecraft:item" -> ItemParticleData.read(this, type)
|
||||
"minecraft:shriek" -> ShriekParticleData.read(this, type)
|
||||
"minecraft:sculk_charge" -> SculkChargeParticleData.read(this, type)
|
||||
"minecraft:vibration" -> VibrationParticleData.read(this, type)
|
||||
else -> ParticleData(type)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user