diff --git a/src/main/kotlin/com/bytedice/bde_particles/DisplayEntity.kt b/src/main/kotlin/com/bytedice/bde_particles/DisplayEntity.kt index 7598534..810feaf 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/DisplayEntity.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/DisplayEntity.kt @@ -8,14 +8,14 @@ import net.minecraft.nbt.NbtList import net.minecraft.nbt.NbtString import net.minecraft.server.world.ServerWorld -class DisplayEntity(val properties: DisplayEntityProperties?) { +class DisplayEntity(var properties: DisplayEntityProperties?) { private var hasSpawned = false private var entity: BlockDisplayEntity? = null fun spawn(world: ServerWorld) : BlockDisplayEntity? { if (hasSpawned || properties == null) { return null } - val e = updateProperties(world, properties) + val e = updateProperties(world, properties!!) world.spawnEntity(e) this.hasSpawned = true @@ -72,6 +72,8 @@ class DisplayEntity(val properties: DisplayEntityProperties?) { e.refreshPositionAndAngles(properties.pos.x, properties.pos.y, properties.pos.z, properties.rot.x, properties.rot.y) entity = e + this.properties = properties + return e } diff --git a/src/main/kotlin/com/bytedice/bde_particles/particle/Particle.kt b/src/main/kotlin/com/bytedice/bde_particles/particle/Particle.kt index f9f5e26..b1e367b 100644 --- a/src/main/kotlin/com/bytedice/bde_particles/particle/Particle.kt +++ b/src/main/kotlin/com/bytedice/bde_particles/particle/Particle.kt @@ -65,7 +65,7 @@ class Particle(private val particleParams: ParticleParams) { val properties = blockDisplay?.properties ?: return - val newProperties = calculateNewProperties(properties, particleParams) + val newProperties = calculateNewProperties() blockDisplay?.updateProperties(world, newProperties) @@ -75,14 +75,14 @@ class Particle(private val particleParams: ParticleParams) { } - private fun calculateNewProperties(propetries: DisplayEntityProperties, params: ParticleParams) : DisplayEntityProperties { + private fun calculateNewProperties() : DisplayEntityProperties { val newBlockIdx = round(lerp( 0.0f, - params.blockCurve.lastIndex.toFloat(), - (timeAlive.toFloat() / params.lifeTime.toFloat()).coerceIn(0.0f, 1.0f) + particleParams.blockCurve.lastIndex.toFloat(), + (timeAlive.toFloat() / particleParams.lifeTime.toFloat()).coerceIn(0.0f, 1.0f) )).toInt() - val newBlock = params.blockCurve[newBlockIdx] + val newBlock = particleParams.blockCurve[newBlockIdx] val newProperties = DisplayEntityProperties(