particles: crit, damage_indicator, crimson_spore, warped_spore

This commit is contained in:
Bixilon 2021-06-08 00:03:45 +02:00 committed by Lukas
parent a7985eb554
commit e52ce868b2
8 changed files with 193 additions and 2 deletions

View File

@ -53,7 +53,7 @@ class MobSpawnerBlockEntity(connection: PlayConnection) : BlockEntity(connection
override fun updateNBT(nbt: Map<String, Any>) { override fun updateNBT(nbt: Map<String, Any>) {
nbt["MaxNearbyEntities"]?.let { nbt["MaxNearbyEntities"]?.let {
requiredPlayerRange = nbt["MaxNearbyEntities"]?.nullCast<Short>()?.toInt() ?: 16 requiredPlayerRange = nbt["MaxNearbyEntities"]?.nullCast<Number>()?.toInt() ?: 16
} }
// ToDo: {MaxNearbyEntities: 6s, RequiredPlayerRange: 16s, SpawnCount: 4s, x: -80, y: 4, SpawnData: {id: "minecraft:zombie"}, z: 212, id: "minecraft:mob_spawner", MaxSpawnDelay: 800s, SpawnRange: 4s, Delay: 0s, MinSpawnDelay: 200s} // ToDo: {MaxNearbyEntities: 6s, RequiredPlayerRange: 16s, SpawnCount: 4s, x: -80, y: 4, SpawnData: {id: "minecraft:zombie"}, z: 212, id: "minecraft:mob_spawner", MaxSpawnDelay: 800s, SpawnRange: 4s, Delay: 0s, MinSpawnDelay: 200s}
} }

View File

@ -21,6 +21,8 @@ import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.Ex
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.campfire.CampfireSmokeParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.campfire.CampfireSmokeParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.cloud.CloudParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.cloud.CloudParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.cloud.SneezeParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.cloud.SneezeParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.CritParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.DamageIndicatorParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.EnchantedHitParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.EnchantedHitParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant.EnchantParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant.EnchantParticle
@ -37,6 +39,8 @@ import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.su
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.HappyVillagerParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.HappyVillagerParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.MyceliumParticle import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.MyceliumParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.water.CrimsonSporeParticle
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.water.WarpedSporeParticle
object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>( object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
ExplosionEmitterParticle, ExplosionEmitterParticle,
@ -62,4 +66,8 @@ object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
ComposterParticle, ComposterParticle,
HappyVillagerParticle, HappyVillagerParticle,
MyceliumParticle, MyceliumParticle,
DamageIndicatorParticle,
CritParticle,
CrimsonSporeParticle,
WarpedSporeParticle,
) )

View File

@ -0,0 +1,32 @@
/*
* 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.gui.rendering.particle.types.render.texture.simple.damage
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import glm_.vec3.Vec3d
class CritParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData? = null) : DamageParticle(connection, position, velocity, data) {
companion object : ParticleFactory<CritParticle> {
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:crit".asResourceLocation()
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): CritParticle {
return CritParticle(connection, position, velocity, data)
}
}
}

View File

@ -0,0 +1,36 @@
/*
* 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.gui.rendering.particle.types.render.texture.simple.damage
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import glm_.vec3.Vec3d
class DamageIndicatorParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData? = null) : DamageParticle(connection, position, velocity + Vec3d(0.0, 1.0, 0.0), data) {
init {
maxAge = 20
}
companion object : ParticleFactory<DamageIndicatorParticle> {
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:damage_indicator".asResourceLocation()
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): DamageIndicatorParticle {
return DamageIndicatorParticle(connection, position, velocity, data)
}
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.gui.rendering.particle.types.render.texture.simple.water
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.data.text.RGBColor
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
import de.bixilon.minosoft.gui.rendering.util.VecUtil.times
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import glm_.vec3.Vec3d
import java.util.*
class CrimsonSporeParticle(connection: PlayConnection, position: Vec3d, data: ParticleData? = null) : WaterSuspendParticle(connection, position, Vec3d(9.999999974752427E-7) * { random.nextGaussian() }, data) {
init {
color = RGBColor(0.9f, 0.4f, 0.5f)
}
companion object : ParticleFactory<CrimsonSporeParticle> {
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:crimson_spore".asResourceLocation()
private val random = Random()
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): CrimsonSporeParticle {
return CrimsonSporeParticle(connection, position, data)
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.gui.rendering.particle.types.render.texture.simple.water
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.data.text.RGBColor
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import glm_.vec3.Vec3
import glm_.vec3.Vec3d
import java.util.*
class WarpedSporeParticle(connection: PlayConnection, position: Vec3d, data: ParticleData? = null) : WaterSuspendParticle(connection, position, Vec3d(0.0, (random.nextDouble() * -1.9 * random.nextDouble() * 0.1), 0.0), data) {
init {
color = RGBColor(0.1f, 0.1f, 0.3f)
spacing = Vec3(0.001f)
}
companion object : ParticleFactory<WarpedSporeParticle> {
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:warped_spore".asResourceLocation()
private val random = Random()
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): WarpedSporeParticle {
return WarpedSporeParticle(connection, position, data)
}
}
}

View File

@ -0,0 +1,32 @@
/*
* 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.gui.rendering.particle.types.render.texture.simple.water
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.SimpleTextureParticle
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import glm_.vec3.Vec3
import glm_.vec3.Vec3d
abstract class WaterSuspendParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData? = null) : SimpleTextureParticle(connection, position - Vec3d(0.0, -0.125, 0.0), velocity, data) {
init {
spacing = Vec3(0.01f)
super.scale *= random.nextFloat() * 0.6f + 0.6f
maxAge = (16.0f / ((random.nextFloat() * 0.8f + 0.2f))).toInt()
physics = false
friction = 1.0f
gravityStrength = 0.0f
}
}

View File

@ -165,7 +165,7 @@ class AudioPlayer(
} }
val source = getAvailableSource() ?: let { val source = getAvailableSource() ?: let {
// ToDo: Queue sound for later (and check a certain delay to not make the game feel laggy) // ToDo: Queue sound for later (and check a certain delay to not make the game feel laggy)
Log.log(LogMessageType.AUDIO_LOADING, LogLevels.WARN) { "Can not play sound: No source available!" } Log.log(LogMessageType.AUDIO_LOADING, LogLevels.WARN) { "Can not play sound: No source available: $sound" }
return@add return@add
} }
position?.let { position?.let {