summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/magic/MagicArrow.java
blob: dc7cb20bb5fc4ffb5d8a52ac947acc213a76d6c9 (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;

import jp.plusplus.fbs.api.MagicBase;
import jp.plusplus.fbs.entity.EntityMagicArrow;
import net.minecraft.entity.Entity;

/**
 * Createdby pluslus_Fon 2015/06/08.
 */
public class MagicArrow extends MagicBase {
    @Override
    public boolean checkSuccess() {
        if(isSpelled) return true;

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

    @Override
    public void success() {
        int d=getLvDiff();
        float dm=isSpelled?2.0f:1.0f;
        if(d>0) dm+=0.5f*(d/5);

        Entity e=new EntityMagicArrow(world, player, 1.0F, 1.0F, dm);
        world.spawnEntityInWorld(e);
    }

    @Override
    public void failure() {
        sanity(1, 6);
    }
}