From e52ce868b2b29ba322cbd377e718b0abe78acd82 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Tue, 8 Jun 2021 00:03:45 +0200 Subject: [PATCH] particles: `crit`, `damage_indicator`, `crimson_spore`, `warped_spore` --- .../entities/block/MobSpawnerBlockEntity.kt | 2 +- .../particle/DefaultParticleFactory.kt | 8 ++++ .../texture/simple/damage/CritParticle.kt | 32 ++++++++++++++ .../simple/damage/DamageIndicatorParticle.kt | 36 ++++++++++++++++ .../simple/water/CrimsonSporeParticle.kt | 41 ++++++++++++++++++ .../simple/water/WarpedSporeParticle.kt | 42 +++++++++++++++++++ .../simple/water/WaterSuspendParticle.kt | 32 ++++++++++++++ .../gui/rendering/sound/AudioPlayer.kt | 2 +- 8 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/CritParticle.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/DamageIndicatorParticle.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/CrimsonSporeParticle.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WarpedSporeParticle.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WaterSuspendParticle.kt diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt index 0e5a18333..245f6a467 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt @@ -53,7 +53,7 @@ class MobSpawnerBlockEntity(connection: PlayConnection) : BlockEntity(connection override fun updateNBT(nbt: Map) { nbt["MaxNearbyEntities"]?.let { - requiredPlayerRange = nbt["MaxNearbyEntities"]?.nullCast()?.toInt() ?: 16 + requiredPlayerRange = nbt["MaxNearbyEntities"]?.nullCast()?.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} } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt index da921e1c1..8fbb07ccc 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt @@ -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.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.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.dust.DustParticle 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.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.water.CrimsonSporeParticle +import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.water.WarpedSporeParticle object DefaultParticleFactory : DefaultFactory>( ExplosionEmitterParticle, @@ -62,4 +66,8 @@ object DefaultParticleFactory : DefaultFactory>( ComposterParticle, HappyVillagerParticle, MyceliumParticle, + DamageIndicatorParticle, + CritParticle, + CrimsonSporeParticle, + WarpedSporeParticle, ) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/CritParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/CritParticle.kt new file mode 100644 index 000000000..a953a0473 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/CritParticle.kt @@ -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 . + * + * 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 { + 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) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/DamageIndicatorParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/DamageIndicatorParticle.kt new file mode 100644 index 000000000..c78169a9a --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/damage/DamageIndicatorParticle.kt @@ -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 . + * + * 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 { + 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) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/CrimsonSporeParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/CrimsonSporeParticle.kt new file mode 100644 index 000000000..eacc33337 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/CrimsonSporeParticle.kt @@ -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 . + * + * 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 { + 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) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WarpedSporeParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WarpedSporeParticle.kt new file mode 100644 index 000000000..dbfcff4c3 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WarpedSporeParticle.kt @@ -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 . + * + * 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 { + 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) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WaterSuspendParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WaterSuspendParticle.kt new file mode 100644 index 000000000..9b15b0822 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/water/WaterSuspendParticle.kt @@ -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 . + * + * 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 + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt index 50274bebf..8e9664e71 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt @@ -165,7 +165,7 @@ class AudioPlayer( } val source = getAvailableSource() ?: let { // 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 } position?.let {