summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/magic/enchant/MagicPoison.java
blob: 46c0c8704432c63b154c8e72a0afed79a24fd7b7 (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
package jp.plusplus.fbs.magic.enchant;

import jp.plusplus.fbs.api.MagicEnchantBase;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

/**
 * Createdby pluslus_Fon 2015/10/22.
 */
public class MagicPoison extends MagicEnchantBase {
    public MagicPoison() {
        super(4, 6);
    }

    @Override
    public boolean checkSuccess() {
        if(!isSpelled) return false;

        float prob=0.4f+0.02f*property.getMagicLevel();
        return rand.nextFloat()<=prob;
    }

    @Override
    public void success() {
        Entity e=getTouchEntity();
        if(e instanceof EntityLivingBase){
            enchant((EntityLivingBase)e, true);
        }
    }


    @Override
    public void enchant(EntityLivingBase entity, boolean success) {
        int d = getDuration(5, 3);
        int a = getAmplifier(10);

        if(success){
            if(isSpelled) d+=3*20;
            entity.addPotionEffect(new PotionEffect(Potion.poison.getId(), d, a));
        }
    }

    @Override
    public ParticleColor setParticleColor(){
        ParticleColor col=new ParticleColor();
        float v=0.1f+0.5f*rand.nextFloat();
        col.blue-=v;
        col.red-=v;
        col.green=0;
        return col;
    }
}