1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-04-11 03:15:44 +02:00

Add a base class for floating particles (no gravity/collisions/random motion)

This commit is contained in:
chylex 2018-09-28 22:12:18 +02:00
parent 37351f8c6a
commit b951c5335c
2 changed files with 25 additions and 12 deletions
src/main/java/chylex/hee/game/particle

View File

@ -1,4 +1,5 @@
package chylex.hee.game.particle
import chylex.hee.game.particle.base.ParticleBaseFloating
import chylex.hee.game.particle.spawner.factory.IParticleData
import chylex.hee.game.particle.spawner.factory.IParticleMaker
import chylex.hee.system.util.floorToInt
@ -32,19 +33,13 @@ object ParticleTeleport : IParticleMaker{
private val DEFAULT_DATA = Data()
@SideOnly(Side.CLIENT)
private class Instance(world: World, posX: Double, posY: Double, posZ: Double, motX: Double, motY: Double, motZ: Double, unsafeData: IntArray) : Particle(world, posX, posY, posZ, motX, motY, motZ){
private class Instance(world: World, posX: Double, posY: Double, posZ: Double, motX: Double, motY: Double, motZ: Double, unsafeData: IntArray) : ParticleBaseFloating(world, posX, posY, posZ, motX, motY, motZ){
private val initialScale: Float
init{
val data = DEFAULT_DATA.validate(unsafeData)
initialScale = rand.nextFloat(data[2] * 0.01F, data[3] * 0.01F)
motionX = motX
motionY = motY
motionZ = motZ
particleGravity = 0F
particleTextureIndexX = rand.nextInt(8)
particleTextureIndexY = 0
@ -55,11 +50,6 @@ object ParticleTeleport : IParticleMaker{
particleMaxAge = rand.nextInt(data[0], data[1])
}
override fun move(x: Double, y: Double, z: Double){ // skips collision checking
boundingBox = boundingBox.offset(x, y, z)
resetPositionToBB()
}
override fun renderParticle(buffer: BufferBuilder, entity: Entity, partialTicks: Float, rotationX: Float, rotationZ: Float, rotationYZ: Float, rotationXY: Float, rotationXZ: Float){
particleScale = initialScale * (1F - (particleAge + partialTicks) / (particleMaxAge + 1F))
super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ)

View File

@ -0,0 +1,23 @@
package chylex.hee.game.particle.base
import net.minecraft.client.particle.Particle
import net.minecraft.world.World
import net.minecraftforge.fml.relauncher.Side
import net.minecraftforge.fml.relauncher.SideOnly
/**
* Particle with no gravity, no block collisions, and no motion randomness.
*/
@SideOnly(Side.CLIENT)
abstract class ParticleBaseFloating(world: World, posX: Double, posY: Double, posZ: Double, motX: Double, motY: Double, motZ: Double) : Particle(world, posX, posY, posZ, motX, motY, motZ){
init{
motionX = motX
motionY = motY
motionZ = motZ
particleGravity = 0F
}
override fun move(x: Double, y: Double, z: Double){ // skips collision checking
boundingBox = boundingBox.offset(x, y, z)
resetPositionToBB()
}
}