当前位置: 首页>>代码示例>>Java>>正文


Java EntityDamageByEntityEvent类代码示例

本文整理汇总了Java中cn.nukkit.event.entity.EntityDamageByEntityEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByEntityEvent类的具体用法?Java EntityDamageByEntityEvent怎么用?Java EntityDamageByEntityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityDamageByEntityEvent类属于cn.nukkit.event.entity包,在下文中一共展示了EntityDamageByEntityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public void attack(EntityDamageEvent source) {
    super.attack(source);
    if (source.isCancelled()) return;
    if (source instanceof EntityDamageByEntityEvent) {
        Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
        if (damager instanceof Player) {
            if (((Player) damager).isCreative()) {
                this.kill();
            }
            if (this.getHealth() <= 0) {
                if (((Player) damager).isSurvival()) {
                    this.level.dropItem(this, new ItemBoat());
                }
                this.close();
            }
        }
    }

    EntityEventPacket pk = new EntityEventPacket();
    pk.eid = this.getId();
    pk.event = this.getHealth() <= 0 ? EntityEventPacket.DEATH_ANIMATION : EntityEventPacket.HURT_ANIMATION;
    Server.broadcastPacket(this.hasSpawned.values(), pk);
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:25,代码来源:EntityBoat.java

示例2: onDamage

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent event){
	if(this.status == STATUS_STOPPED){
		if(event.getEntity() instanceof Player){
			event.setCancelled();
		}
	}else{
		if(event.getEntity() instanceof Player){
			if(immortal.contains(((Player)event.getEntity()).getName())){
				event.setCancelled();
			}
		}
	}
	
	if(event instanceof EntityDamageByEntityEvent){
		EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
		if(e.getDamager() instanceof Player){
			if(this.isColleague(e.getDamager().getName(), e.getEntity().getName()) || this.status != STATUS_ONGOING){
				event.setCancelled();
			}
		}
	}
}
 
开发者ID:onebone,项目名称:MineCombat-Nukkit,代码行数:24,代码来源:MineCombat.java

示例3: getDrops

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public Item[] getDrops() {
    if (this.lastDamageCause instanceof EntityDamageByEntityEvent) {
        return new Item[]{Item.get(Item.GUNPOWDER, level.rand.nextInt(2) + 1)};
    }
    return new Item[0];
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:EntityCreeper.java

示例4: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (invulnerable) {
        return false;
    } else {
        Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
        boolean instantKill = damager instanceof Player && ((Player) damager).isCreative();
        if (!instantKill) performHurtAnimation((int) source.getFinalDamage());

        if (instantKill || getDamage() > 40) {
            if (linkedEntity != null) {
                mountEntity(linkedEntity);
            }

            if (instantKill && (!hasCustomName())) {
                kill();
            } else {
                if (level.getGameRules().getBoolean("doEntityDrops")) {
                    dropItem();
                }
                close();
            }
        }
    }

    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:28,代码来源:EntityMinecartAbstract.java

示例5: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (super.attack(source)) {
        if (source instanceof EntityDamageByEntityEvent) {
            Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
            if (damager instanceof Player && ((Player) damager).isSurvival() && this.level.getGameRules().getBoolean("doEntityDrops")) {
                this.level.dropItem(this, new ItemPainting());
            }
        }
        this.close();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:EntityPainting.java

示例6: getDrops

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public Item[] getDrops() {
    if (this.lastDamageCause instanceof EntityDamageByEntityEvent) {
        return new Item[]{Item.get(Item.WOOL, getColor(), 1)};
    }
    return new Item[0];
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:EntitySheep.java

示例7: getDrops

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public Item[] getDrops() {
    Item drops[] = new Item[4];
    drops[0] = new ItemPrismarineCrystals(0, random.nextRange(0, 1));
    drops[1] = new ItemPrismarineShard(0, random.nextRange(0, 2));
    //TODO: 60%の確率で生魚、25%の確率で生鮭、2%の確率でクマノミ、13%の確率でフグ。また焼死時には焼き魚、焼き鮭をドロップ
    if (this.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
        drops[2] = new ItemBlock(new BlockSponge());
    }
    return drops;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:12,代码来源:EntityElderGuardian.java

示例8: getDrops

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public Item[] getDrops(){
    if(this.getLastDamageCause() instanceof EntityDamageByEntityEvent){
        if(((EntityDamageByEntityEvent) this.getLastDamageCause()).getDamager() instanceof EntitySkeleton){
            return new Item[]{Item.get(500 + new NukkitRandom().nextRange(0, 12), 0, 1)}; //レコード
        }else{
            return new Item[]{new ItemGunpowder(0, new NukkitRandom().nextRange(0, 2))};
        }
    }
    return new Item[]{};
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:12,代码来源:EntityCreeper.java

示例9: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (invulnerable) {
        return false;
    } else {
        Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
        boolean instantKill = damager instanceof Player && ((Player) damager).isCreative();
        if (!instantKill) performHurtAnimation((int) source.getFinalDamage());

        if (instantKill || getDamage() > 40) {
            if (linkedEntity != null) {
                mountEntity(linkedEntity);
            }

            if (instantKill && (!hasCustomName())) {
                kill();
            } else {
                if (level.getGameRules().getBoolean("doentitydrops")) {
                    dropItem();
                }
                close();
            }
        }
    }
    
    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityMinecartAbstract.java

示例10: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (invulnerable) {
        return false;
    } else {
        performHurtAnimation((int) source.getFinalDamage());

        Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
        boolean instantKill = damager instanceof Player && ((Player) damager).isCreative();
        if (instantKill || getDamage() > 40) {
            if (linkedEntity != null) {
                mountEntity(linkedEntity);
            }

            if (instantKill && (!hasCustomName())) {
                kill();
            } else {
                if (level.getGameRules().getBoolean("doentitydrops")) {
                    this.level.dropItem(this, new ItemBoat());
                }
                close();
            }
        }
    }
    
    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityBoat.java

示例11: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (super.attack(source)){
        if (source instanceof EntityDamageByEntityEvent) {
            Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
            if (damager instanceof Player && ((Player) damager).isSurvival()) {
                this.level.dropItem(this, new ItemPainting());
            }
        }
        this.close();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:16,代码来源:EntityPainting.java

示例12: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (this.attackTime > 0 || this.noDamageTicks > 0) {
        EntityDamageEvent lastCause = this.getLastDamageCause();
        if (lastCause != null && lastCause.getDamage() >= source.getDamage()) {
            return false;
        }
    }

    if (super.attack(source)) {
        if (source instanceof EntityDamageByEntityEvent) {
            Entity e = ((EntityDamageByEntityEvent) source).getDamager();
            if (source instanceof EntityDamageByChildEntityEvent) {
                e = ((EntityDamageByChildEntityEvent) source).getChild();
            }

            if (e.isOnFire() && !(e instanceof Player)) {
                this.setOnFire(2 * this.server.getDifficulty());
            }

            double deltaX = this.x - e.x;
            double deltaZ = this.z - e.z;
            this.knockBack(e, source.getDamage(), deltaX, deltaZ, ((EntityDamageByEntityEvent) source).getKnockBack());
        }

        EntityEventPacket pk = new EntityEventPacket();
        pk.entityRuntimeId = this.getId();
        pk.event = this.getHealth() <= 0 ? EntityEventPacket.DEATH_ANIMATION : EntityEventPacket.HURT_ANIMATION;
        Server.broadcastPacket(this.level.getPlayers().values(), pk);

        this.attackTime = 10;

        return true;
    } else {
        return false;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:38,代码来源:EntityLiving.java

示例13: onStruckByLightning

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
public void onStruckByLightning(Entity entity) {
    this.attack(new EntityDamageByEntityEvent(entity, this, DamageCause.LIGHTNING, 5));

    if (this.fireTicks < 8 * 20) {
        this.setOnFire(8);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:8,代码来源:Entity.java

示例14: getDrops

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public Item[] getDrops() {
    Item drops[] = new Item[3];
    drops[0] = this.isOnFire() ? new ItemRabbitCooked(0, random.nextRange(0, 1)) : new ItemRabbitRaw(0, random.nextRange(0, 1));
    drops[1] = new ItemRabbitHide(0, random.nextRange(0, 1));

    if (this.getLastDamageCause() instanceof EntityDamageByEntityEvent && random.nextRange(1, 10) == 1) {
        drops[2] = new ItemRabbitFoot(random.nextRange(0, 1));
    }

    return drops;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:13,代码来源:EntityRabbit.java

示例15: attack

import cn.nukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public boolean attack(EntityDamageEvent source) {
    if (super.attack(source)) {
        if (source instanceof EntityDamageByEntityEvent) {
            Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
            if (damager instanceof Player) {
                if (((Player) damager).isCreative()) {
                    this.kill();
                }
                if (this.getHealth() <= 0) {
                    if (((Player) damager).isSurvival()) {
                        this.level.dropItem(this, new ItemBoat());
                    }
                    this.close();
                }
            }
        }

        EntityEventPacket pk = new EntityEventPacket();
        pk.eid = this.getId();
        pk.event = this.getHealth() <= 0 ? EntityEventPacket.DEATH_ANIMATION : EntityEventPacket.HURT_ANIMATION;
        Server.broadcastPacket(this.hasSpawned.values(), pk);

        return true;
    } else {
        return false;
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:29,代码来源:EntityBoat.java


注:本文中的cn.nukkit.event.entity.EntityDamageByEntityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。