mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
particles: portal
, ender_chest particles
This commit is contained in:
parent
a27df8f91e
commit
a5f9a0867d
@ -121,6 +121,7 @@ open class Block(
|
||||
"SlimeBlock" to { resourceLocation, registries, data -> SlimeBlock(resourceLocation, registries, data) },
|
||||
"BedBlock" to { resourceLocation, registries, data -> BedBlock(resourceLocation, registries, data) },
|
||||
"BrewingStandBlock" to { resourceLocation, registries, data -> BrewingStandBlock(resourceLocation, registries, data) },
|
||||
"EnderChestBlock" to { resourceLocation, registries, data -> EnderChestBlock(resourceLocation, registries, data) },
|
||||
)
|
||||
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Block {
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.data.mappings.blocks.types
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.PortalParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3d
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import glm_.vec3.Vec3d
|
||||
import glm_.vec3.Vec3i
|
||||
import kotlin.random.Random
|
||||
|
||||
open class EnderChestBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
|
||||
private val portalParticle = registries.particleTypeRegistry[PortalParticle]
|
||||
|
||||
|
||||
override fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {
|
||||
portalParticle ?: return
|
||||
for (i in 0 until 3) {
|
||||
val xFactor = random.nextInt(2) * 2 - 1
|
||||
val zFactor = random.nextInt(2) * 2 - 1
|
||||
val position = blockPosition.toVec3d + Vec3d(
|
||||
0.5 + 0.25 * xFactor,
|
||||
random.nextDouble(),
|
||||
0.5 + 0.25 * zFactor,
|
||||
)
|
||||
val velocity = Vec3d(
|
||||
random.nextDouble() * xFactor,
|
||||
(random.nextDouble() - 0.5) * 0.125,
|
||||
random.nextDouble() * zFactor,
|
||||
)
|
||||
|
||||
connection.world += PortalParticle(connection, position, velocity, portalParticle.default())
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.gui.rendering.particle.types.norender.ExplosionEmitte
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.advanced.block.BlockDustParticle
|
||||
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.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
|
||||
@ -72,4 +73,5 @@ object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
||||
CrimsonSporeParticle,
|
||||
WarpedSporeParticle,
|
||||
NoteParticle,
|
||||
PortalParticle,
|
||||
)
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
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.EMPTY
|
||||
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_.pow
|
||||
import glm_.vec3.Vec3d
|
||||
|
||||
class PortalParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData? = null) : SimpleTextureParticle(connection, Vec3d(position), Vec3d.EMPTY, data) {
|
||||
private val startPosition = Vec3d(position)
|
||||
|
||||
override var scale: Float
|
||||
get() = super.scale * (1.0f - (1.0f - (floatAge / maxAge)).pow(2))
|
||||
set(value) {
|
||||
super.scale = value
|
||||
}
|
||||
|
||||
init {
|
||||
this.velocity assign velocity
|
||||
this.position assign position
|
||||
|
||||
this.scale = 0.1f * (random.nextFloat() * 0.2f + 0.5f)
|
||||
|
||||
(random.nextFloat() * 0.6f + 0.4f).let {
|
||||
this.color = RGBColor(it * 0.9f, it * 0.3f, it)
|
||||
}
|
||||
|
||||
this.maxAge = (random.nextInt(10) + 40)
|
||||
movement = false
|
||||
}
|
||||
|
||||
override fun move(velocity: Vec3d) {
|
||||
this.position += velocity
|
||||
}
|
||||
|
||||
override fun realTick() {
|
||||
super.realTick()
|
||||
if (dead) {
|
||||
return
|
||||
}
|
||||
|
||||
val lifeTime = floatAge / maxAge
|
||||
val velocityMultiplier = 1.0f - (-lifeTime + lifeTime * lifeTime * 2.0f)
|
||||
|
||||
this.position assign (startPosition + velocity * velocityMultiplier)
|
||||
this.position.y += 1.0 - lifeTime
|
||||
}
|
||||
|
||||
|
||||
companion object : ParticleFactory<PortalParticle> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:portal".asResourceLocation()
|
||||
|
||||
override fun build(connection: PlayConnection, position: Vec3d, velocity: Vec3d, data: ParticleData): PortalParticle {
|
||||
return PortalParticle(connection, position, velocity, data)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user