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

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

/**
 * Createdby pluslus_Fon 2015/11/09.
 */
public class MagicCleverness extends MagicEnchantBase {
    public MagicCleverness() {
        super(1, 6);
    }

    @Override
    public boolean checkSuccess() {
        int d=getLvDiff();
        float prob=isSpelled?0.5f:0.3f;
        if(d>0) prob+=0.08f*d;
        return rand.nextFloat()<=prob;
    }
    @Override
    public void enchant(EntityLivingBase entity, boolean success) {
        int d = getDuration(90, 0.5f);
        int a = getAmplifier(7);

        if(success){
            if(this.isSpelled) d+=120*20;
            entity.addPotionEffect(new PotionEffect(Registry.potionCleverness.getId(), d, a));
        }
    }
}