本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.entityDamage方法的具体用法?Java CraftEventFactory.entityDamage怎么用?Java CraftEventFactory.entityDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.craftbukkit.event.CraftEventFactory
的用法示例。
在下文中一共展示了CraftEventFactory.entityDamage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: b
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void b(float f) {
if (this.hurtEntities) {
int i = MathHelper.f(f - 1.0F);
if (i > 0) {
ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox));
boolean flag = this.id == Blocks.ANVIL;
DamageSource damagesource = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
CraftEventFactory.entityDamage = this; // CraftBukkit
entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax));
CraftEventFactory.entityDamage = null; // CraftBukkit
}
if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {
int j = this.data >> 2;
int k = this.data & 3;
++j;
if (j > 2) {
this.f = true;
} else {
this.data = k | j << 2;
}
}
}
}
}
示例2: fall
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void fall(float p_70069_1_)
{
if (this.field_145809_g)
{
int i = MathHelper.ceiling_float_int(p_70069_1_ - 1.0F);
if (i > 0)
{
ArrayList arraylist = new ArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox));
boolean flag = this.field_145811_e == Blocks.anvil;
DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext())
{
Entity entity = (Entity) iterator.next();
CraftEventFactory.entityDamage = this; // CraftBukkit
entity.attackEntityFrom(damagesource,(float) Math.min(MathHelper.floor_float((float) i * this.field_145816_i), this.field_145815_h));
CraftEventFactory.entityDamage = null; // CraftBukkit
}
if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
{
int j = this.field_145814_a >> 2;
int k = this.field_145814_a & 3;
++j;
if (j > 2)
{
this.field_145808_f = true;
}
else
{
this.field_145814_a = k | j << 2;
}
}
}
}
}
示例3: bP
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
private void bP() {
if (this.bC != null) {
if (this.bC.dead) {
if (!this.world.isStatic) {
CraftEventFactory.entityDamage = this.bC; // CraftBukkit
this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F);
CraftEventFactory.entityDamage = null; // CraftBukkit
}
this.bC = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.random.nextInt(10) == 0) {
float f = 32.0F;
List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.f(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.bC = entityendercrystal;
}
}
示例4: a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void a(MovingObjectPosition movingobjectposition) {
if (movingobjectposition.entity != null) {
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F);
}
for (int i = 0; i < 32; ++i) {
this.world.addParticle("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian());
}
if (!this.world.isStatic) {
if (this.getShooter() != null && this.getShooter() instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) this.getShooter();
if (entityplayer.playerConnection.b().isConnected() && entityplayer.world == this.world) {
// CraftBukkit start - Fire PlayerTeleportEvent
org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
org.bukkit.Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(teleEvent);
if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
if (this.getShooter().am()) {
this.getShooter().mount((Entity) null);
}
entityplayer.playerConnection.teleport(teleEvent.getTo());
this.getShooter().fallDistance = 0.0F;
CraftEventFactory.entityDamage = this;
this.getShooter().damageEntity(DamageSource.FALL, 5.0F);
CraftEventFactory.entityDamage = null;
}
// CraftBukkit end
}
}
this.die();
}
}
示例5: onImpact
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
protected void onImpact(MovingObjectPosition p_70184_1_)
{
if (p_70184_1_.entityHit != null)
{
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
for (int i = 0; i < 32; ++i)
{
this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}
if (!this.worldObj.isRemote)
{
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower();
if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5);
// Cauldron start - invert condition; return if cancelled otherwise fall through to CB event
if (MinecraftForge.EVENT_BUS.post(event)){
this.setDead();
return;
}
// Cauldron end
// CraftBukkit start
org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayermp.getBukkitEntity();
org.bukkit.Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(teleEvent);
if (!teleEvent.isCancelled() && !entityplayermp.playerNetServerHandler.isDisconnected())
{
entityplayermp.playerNetServerHandler.teleport(teleEvent.getTo());
this.getThrower().fallDistance = 0.0F;
CraftEventFactory.entityDamage = this;
this.getThrower().attackEntityFrom(DamageSource.fall, 5.0F);
CraftEventFactory.entityDamage = null;
}
// CraftBukkit end
}
}
this.setDead();
}
}
示例6: updateDragonEnderCrystal
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
private void updateDragonEnderCrystal()
{
if (this.healingEnderCrystal != null)
{
if (this.healingEnderCrystal.isDead)
{
if (!this.worldObj.isRemote)
{
CraftEventFactory.entityDamage = this.healingEnderCrystal; // CraftBukkit
this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F);
CraftEventFactory.entityDamage = null; // CraftBukkit
}
this.healingEnderCrystal = null;
}
else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth())
{
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.worldObj.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled())
{
this.setHealth((float)(this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.rand.nextInt(10) == 0)
{
float f = 32.0F;
List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double)f, (double)f, (double)f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal)iterator.next();
double d1 = entityendercrystal1.getDistanceSqToEntity(this);
if (d1 < d0)
{
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.healingEnderCrystal = entityendercrystal;
}
}