public boolean attack(Entity entity, DamageSource damageSource, float damage) { PetAttackEvent attackEvent = new PetAttackEvent(this.getPet(), entity.getBukkitEntity(), f); EchoPet.getPlugin().getServer().getPluginManager().callEvent(attackEvent); if (!attackEvent.isCancelled()) { if (entity instanceof EntityPlayer) { if (!(EchoPet.getConfig().getBoolean("canAttackPlayers", false))) { return false; } } return entity.damageEntity(damageSource, (float) attackEvent.getDamage()); } return false; }
public static org.bukkit.entity.Entity spawnCustomEntity( org.bukkit.World world, Location at, Class<? extends Entity> clazz, EntityType type) { World handle = ((CraftWorld) world).getHandle(); Entity entity = null; try { Constructor<?> constructor = getCustomEntityConstructor(clazz, type); entity = (Entity) constructor.newInstance(handle); } catch (Exception e) { Messaging.logTr(Messages.ERROR_SPAWNING_CUSTOM_ENTITY, e.getMessage()); return null; } entity.setLocation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); handle.addEntity(entity); entity.setLocation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch()); return entity.getBukkitEntity(); }
@Override public void collide(Entity inEntity) { if (this.getRemoteEntity() == null) { super.collide(inEntity); return; } if (((RemoteBaseEntity) this.m_remoteEntity).onCollide(inEntity.getBukkitEntity())) super.collide(inEntity); }
public static void attack(EntityLiving handle, Entity target) { AttributeInstance attribute = handle.getAttributeInstance(GenericAttributes.e); float damage = (float) (attribute == null ? 1D : attribute.getValue()); if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) { damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); } if (handle.hasEffect(MobEffectList.WEAKNESS)) { damage -= 2 << handle.getEffect(MobEffectList.WEAKNESS).getAmplifier(); } int knockbackLevel = 0; if (target instanceof EntityLiving) { damage += EnchantmentManager.a(handle, (EntityLiving) target); knockbackLevel += EnchantmentManager.getKnockbackEnchantmentLevel(handle, (EntityLiving) target); } boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage); if (!success) return; if (knockbackLevel > 0) { target.g( -Math.sin(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F); handle.motX *= 0.6D; handle.motZ *= 0.6D; } int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle); if (fireAspectLevel > 0) { target.setOnFire(fireAspectLevel * 4); } }
public static void trySwim(org.bukkit.entity.Entity entity, float power) { Entity handle = getHandle(entity); if (RANDOM.nextFloat() < 0.8F && inWater(entity)) { handle.motY += power; } }
public static void look(org.bukkit.entity.Entity entity, float yaw, float pitch) { Entity handle = getHandle(entity); handle.yaw = yaw; setHeadYaw(handle, yaw); handle.pitch = pitch; }
public static boolean inWater(org.bukkit.entity.Entity entity) { Entity mcEntity = getHandle(entity); return mcEntity.M() || mcEntity.P(); }