mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
particles: end_rod
This commit is contained in:
parent
cebbf7a019
commit
38297daf21
@ -20,6 +20,7 @@ import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.advanced.
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.ExplosionParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.NoteParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.PortalParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.animated.EndRodParticle
|
||||
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
|
||||
@ -78,4 +79,5 @@ object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
||||
PortalParticle,
|
||||
HeartParticle,
|
||||
AngryVillagerParticle,
|
||||
EndRodParticle,
|
||||
)
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.animated
|
||||
|
||||
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.SimpleTextureParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3d
|
||||
|
||||
abstract class AnimatedParticle(connection: PlayConnection, position: Vec3d, gravityStrength: Float, data: ParticleData? = null) : SimpleTextureParticle(connection, position, Vec3d.EMPTY, data) {
|
||||
var targetColor: RGBColor? = null
|
||||
|
||||
init {
|
||||
this.friction = 0.91f
|
||||
this.gravityStrength = gravityStrength
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
if (age > maxAge / 2) {
|
||||
color = color.with(alpha = (floatAge - (maxAge / 2)) / maxAge)
|
||||
|
||||
targetColor?.let {
|
||||
this.color = this.color.with(
|
||||
red = this.color.floatRed + (it.floatRed - this.color.floatRed) * 0.2f,
|
||||
green = this.color.floatGreen + (it.floatGreen - this.color.floatGreen) * 0.2f,
|
||||
blue = this.color.floatBlue + (it.floatBlue - this.color.floatBlue) * 0.2f,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.animated
|
||||
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||
import de.bixilon.minosoft.data.text.RGBColor.Companion.asRGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.assign
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
import glm_.vec3.Vec3d
|
||||
|
||||
class EndRodParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData? = null) : AnimatedParticle(connection, position, 0.0125f, data) {
|
||||
|
||||
init {
|
||||
this.velocity assign velocity
|
||||
|
||||
this.scale *= 0.75f
|
||||
this.maxAge = 60 + random.nextInt(12)
|
||||
|
||||
targetColor = 15916745.asRGBColor()
|
||||
}
|
||||
|
||||
companion object : ParticleFactory<EndRodParticle> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:end_rod".asResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): EndRodParticle {
|
||||
return EndRodParticle(connection, position, velocity, data)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user