blob: 1f5d89af84bafa08c737a4ee7ca5711b4874ba24 (
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
|
package jp.plusplus.fbs.magic.enchant;
import jp.plusplus.fbs.api.MagicEnchantBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
/**
* Createdby pluslus_Fon 2015/09/18.
*/
public class MagicJump extends MagicEnchantBase {
public MagicJump() {
super(2, 6);
}
@Override
public boolean checkSuccess() {
int d=getLvDiff();
float prob=isSpelled?0.35f:0.1f;
if(d>0) prob+=0.05f*d;
return rand.nextFloat()<=prob;
}
@Override
public void enchant(EntityLivingBase entity, boolean success) {
if(!entity.onGround) return;
int v=getLvDiff();
double d=0.5+Math.max(0, v*0.05);
if(entity instanceof EntityPlayerMP){
if(!success) d*=2;
entity.addVelocity(0, d-player.motionY, 0);
((EntityPlayerMP) entity).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(entity));
}
else{
if(!success) d*=0.5;
entity.addVelocity(0, d-player.motionY, 0);
}
}
@Override
public float damageScale(EntityLivingBase entity){
return 0.5f;
}
}
|