summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/particle/EntityVortexFX.java
blob: 95e85aed4fb21314f29657eaad7dc433cc44a03e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package jp.plusplus.fbs.particle;

import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

/**
 * Created by plusplus_F on 2015/10/18.
 */
public class EntityVortexFX extends EntityFX{
    public static final double spd=0.4;

    protected int delay;
    protected float spinPitch;
    protected float spinYaw;
    protected float radius;
    protected double firstX, firstY, firstZ;

    public EntityVortexFX(World w, double x, double y, double z, int d, double r, float red, float green, float blue, float scale) {
        super(w, x, y, z);
        firstX=x;
        firstY=y;
        firstZ=z;
        rotationPitch=2*(float)Math.PI*rand.nextFloat();
        rotationYaw=2*(float)Math.PI*rand.nextFloat();

        float a=2*(float)Math.PI*rand.nextFloat();
        spinPitch=2*(float)Math.PI/9.f* MathHelper.cos(a);
        spinYaw=2*(float)Math.PI/9.f* MathHelper.sin(a);

        delay=d;
        radius=0;
        particleRed=red;
        particleGreen=green;
        particleBlue=blue;
        particleAlpha=0.f;
        particleScale=scale;
        particleMaxAge=MathHelper.floor_double(r/spd)+delay;
        this.noClip = false;

        this.setParticleTextureIndex(65);
        this.onUpdate();
    }

    @Override
    public void onUpdate() {
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.particleAge++ >= this.particleMaxAge) {
            this.setDead();
        }

        if(particleAge>=delay){
            //座標の決定
            posX=firstX-radius*MathHelper.cos(-rotationPitch)*MathHelper.sin(-rotationYaw);
            posY=firstY+radius*MathHelper.sin(-rotationPitch);
            posZ=firstZ-radius*MathHelper.cos(-rotationPitch)*MathHelper.cos(-rotationYaw);

            rotationPitch+=spinPitch;
            rotationYaw+=spinYaw;
            radius+=spd;

            particleAlpha=1.f;
        }
    }

    @Override
    public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) {
        if(particleAge<delay) return;
        super.renderParticle(p_70539_1_, p_70539_2_, p_70539_3_, p_70539_4_, p_70539_5_, p_70539_6_, p_70539_7_);
    }
}