本文整理汇总了Java中cn.nukkit.entity.EntityLiving类的典型用法代码示例。如果您正苦于以下问题:Java EntityLiving类的具体用法?Java EntityLiving怎么用?Java EntityLiving使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityLiving类属于cn.nukkit.entity包,在下文中一共展示了EntityLiving类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDeath
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onEntityDeath(cn.nukkit.event.entity.EntityDeathEvent event) {
if (canIgnore(EntityDeathEvent.getHandlerList())) {
return;
}
List<ItemStack> bukkitDrops = new ArrayList<ItemStack>();
for (Item item : event.getDrops()) {
bukkitDrops.add(PokkitItemStack.toBukkitCopy(item));
}
EntityDeathEvent bukkitEvent = new EntityDeathEvent(
PokkitLivingEntity.toBukkit((EntityLiving) event.getEntity()), bukkitDrops);
callUncancellable(bukkitEvent);
event.setDrops(bukkitEvent.getDrops().stream().map(PokkitItemStack::toNukkitCopy).toArray(Item[]::new));
}
示例2: checkEntity
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public static boolean checkEntity(Entity entity, Plot plot) {
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
return false;
}
if (entity instanceof EntityLiving) {
if (entity instanceof EntityCreature) {
if (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal) {
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
} else if (entity instanceof EntityMob) {
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
} else if (entity instanceof EntityHuman){
return false;
} else {
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.MOB_CAP);
}
} else {
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
}
} else if (entity instanceof EntityVehicle) {
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
} else if (entity instanceof EntityHanging){
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
} else {
return checkEntity(plot, Flags.ENTITY_CAP);
}
}
示例3: computeRedstoneStrength
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@Override
protected int computeRedstoneStrength() {
AxisAlignedBB bb = getCollisionBoundingBox();
for (Entity entity : this.level.getCollidingEntities(bb)) {
if (entity instanceof EntityLiving && entity.doesTriggerPressurePlate()) {
return 15;
}
}
return 0;
}
示例4: applyPotion
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
if (!(entity instanceof EntityLiving)) {
return;
}
Effect applyEffect = getEffect(this.getId(), this.isSplash());
if (applyEffect == null) {
return;
}
if (entity instanceof Player) {
if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
return;
}
}
PotionApplyEvent event = new PotionApplyEvent(this, entity);
entity.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
switch (this.getId()) {
case INSTANT_HEALTH:
case INSTANT_HEALTH_II:
entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
break;
case HARMING:
case HARMING_II:
entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
break;
default:
int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
applyEffect.setDuration(duration);
entity.addEffect(applyEffect);
}
}
示例5: doPostAttack
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@Override
public void doPostAttack(Entity attacker, Entity entity) {
if (attacker instanceof EntityLiving) {
if (this.damageType == TYPE.ARTHROPODS && entity instanceof EntityArthropod) {
int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level);
entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3));
}
}
}
示例6: applyPotion
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
if (!(entity instanceof EntityLiving)) {
return;
}
Effect applyEffect = getEffect(this.getId(), this.isSplash());
if (applyEffect == null) {
return;
}
if (entity instanceof Player) {
if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
return;
}
}
PotionApplyEvent event = new PotionApplyEvent(this, entity);
entity.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
switch (this.getId()) {
case INSTANT_HEALTH:
case INSTANT_HEALTH_II:
entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
break;
case HARMING:
case HARMING_II:
entity.attack(new EntityDamageEvent(entity, EntityDamageEvent.CAUSE_MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
break;
default:
int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
applyEffect.setDuration(duration);
entity.addEffect(applyEffect);
}
}
示例7: canCollideWith
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@Override
public boolean canCollideWith(Entity entity) {
return entity instanceof EntityLiving && !this.onGround;
}
示例8: EntityShootBowEvent
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public EntityShootBowEvent(EntityLiving shooter, Item bow, EntityProjectile projectile, double force) {
this.entity = shooter;
this.bow = bow;
this.projectile = projectile;
this.force = force;
}
示例9: getEntity
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@Override
public EntityLiving getEntity() {
return (EntityLiving) this.entity;
}
示例10: EntityDeathEvent
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public EntityDeathEvent(EntityLiving entity) {
this(entity, new Item[0]);
}
示例11: applyPotion
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
public void applyPotion(Entity entity, double health) {
if (!(entity instanceof EntityLiving)) {
return;
}
Effect applyEffect = getEffect(this.getId(), this.isSplash());
if (applyEffect == null) {
return;
}
if (entity instanceof Player) {
if (!((Player) entity).isSurvival() && applyEffect.isBad()) {
return;
}
}
PotionApplyEvent event = new PotionApplyEvent(this, applyEffect, entity);
entity.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
applyEffect = event.getApplyEffect();
switch (this.getId()) {
case INSTANT_HEALTH:
case INSTANT_HEALTH_II:
entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING));
break;
case HARMING:
case HARMING_II:
entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1)))));
break;
default:
int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5);
applyEffect.setDuration(duration);
entity.addEffect(applyEffect);
}
}
示例12: onUpdate
import cn.nukkit.entity.EntityLiving; //导入依赖的package包/类
@Override
public boolean onUpdate(int currentTick) {
if (this.closed) {
return false;
}
if (this.justCreated) {
if (this.isEffect()) {
for (Entity e : this.level.getNearbyEntities(this.boundingBox.grow(6, 12, 6), this)) {
if (e instanceof EntityLiving) {
e.attack(new EntityDamageByEntityEvent(this, e, EntityDamageEvent.CAUSE_LIGHTNING, 5));
e.setOnFire(5); //how long?
//Creeper
if (e instanceof EntityCreeper) {
if (!((EntityCreeper) e).isPowered()) {
((EntityCreeper) e).setPowered(this);
}
}
//TODO Pig
//TODO Villager
} else if (e instanceof EntityItem) {
e.kill();
}
}
if (Server.getInstance().getDifficulty() >= 2) {
Block block = this.getLevelBlock();
if (block.getId() == 0 || block.getId() == Block.TALL_GRASS) {
BlockFire fire = new BlockFire();
fire.x = block.x;
fire.y = block.y;
fire.z = block.z;
fire.level = level;
this.getLevel().setBlock(fire, fire, true);
if (fire.isBlockTopFacingSurfaceSolid(fire.getSide(Vector3.SIDE_DOWN)) || fire.canNeighborBurn()) {
level.setBlock(fire, fire, true);
level.scheduleUpdate(fire, fire.tickRate() + level.rand.nextInt(10));
}
}
}
}
}
int tickDiff = currentTick - this.lastUpdate;
if (tickDiff <= 0 && !this.justCreated) {
return true;
}
this.lastUpdate = currentTick;
boolean hasUpdate = true;
this.entityBaseTick(tickDiff);
if (this.isAlive()) {
if (this.age >= 1) {
this.close();
hasUpdate = false;
}
}
return hasUpdate;
}