本文整理汇总了Java中cn.nukkit.level.particle.CriticalParticle类的典型用法代码示例。如果您正苦于以下问题:Java CriticalParticle类的具体用法?Java CriticalParticle怎么用?Java CriticalParticle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CriticalParticle类属于cn.nukkit.level.particle包,在下文中一共展示了CriticalParticle类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onUpdate
import cn.nukkit.level.particle.CriticalParticle; //导入依赖的package包/类
@Override
public boolean onUpdate(int currentTick) {
if (this.closed) {
return false;
}
this.timing.startTiming();
boolean hasUpdate = super.onUpdate(currentTick);
if (!this.hadCollision && this.isCritical) {
NukkitRandom random = new NukkitRandom();
this.level.addParticle(new CriticalParticle(this.add(
this.getWidth() / 2 + ((double) NukkitMath.randomRange(random, -100, 100)) / 500,
this.getHeight() / 2 + ((double) NukkitMath.randomRange(random, -100, 100)) / 500,
this.getWidth() / 2 + ((double) NukkitMath.randomRange(random, -100, 100)) / 500)));
} else if (this.onGround) {
this.isCritical = false;
}
if (this.age > 1200) {
this.kill();
hasUpdate = true;
}
this.timing.stopTiming();
return hasUpdate;
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:30,代码来源:EntityArrow.java
示例2: attack
import cn.nukkit.level.particle.CriticalParticle; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
if (!this.isAlive()) {
return false;
}
if (this.isCreative()
&& source.getCause() != DamageCause.MAGIC
&& source.getCause() != DamageCause.SUICIDE
&& source.getCause() != DamageCause.VOID
) {
//source.setCancelled();
return false;
} else if (this.getAdventureSettings().get(Type.ALLOW_FLIGHT) && source.getCause() == DamageCause.FALL) {
//source.setCancelled();
return false;
} else if (source.getCause() == DamageCause.FALL) {
if (this.getLevel().getBlock(this.getPosition().floor().add(0.5, -1, 0.5)).getId() == Block.SLIME_BLOCK) {
if (!this.isSneaking()) {
//source.setCancelled();
return false;
}
}
}
if (source instanceof EntityDamageByEntityEvent) {
Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
if (damager instanceof Player) {
((Player) damager).getFoodData().updateFoodExpLevel(0.3);
}
if (!damager.onGround) {
NukkitRandom random = new NukkitRandom();
for (int i = 0; i < 5; i++) {
CriticalParticle par = new CriticalParticle(new Vector3(this.x + random.nextRange(-15, 15) / 10, this.y + random.nextRange(0, 20) / 10, this.z + random.nextRange(-15, 15) / 10));
this.getLevel().addParticle(par);
}
source.setDamage((float) (source.getDamage() * 1.5));
}
}
if (super.attack(source)) { //!source.isCancelled()
if (this.getLastDamageCause() == source && this.spawned) {
this.getFoodData().updateFoodExpLevel(0.3);
EntityEventPacket pk = new EntityEventPacket();
pk.entityRuntimeId = this.id;
pk.event = EntityEventPacket.HURT_ANIMATION;
this.dataPacket(pk);
}
return true;
} else {
return false;
}
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:57,代码来源:Player.java
注:本文中的cn.nukkit.level.particle.CriticalParticle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论