Search in sources :

Example 81 with LivingEntity

use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.

the class MCAccessSpigotCB1_8_R2 method getHeight.

@Override
public double getHeight(final Entity entity) {
    final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
    AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
    final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
    if (entity instanceof LivingEntity) {
        return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
    } else
        return entityHeight;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R2.AxisAlignedBB) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity)

Example 82 with LivingEntity

use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.

the class MCAccessSpigotCB1_9_R1 method getHeight.

@Override
public double getHeight(final Entity entity) {
    final net.minecraft.server.v1_9_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
    AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
    final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
    if (entity instanceof LivingEntity) {
        return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
    } else
        return entityHeight;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R1.AxisAlignedBB) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity)

Example 83 with LivingEntity

use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.

the class RichEntityLocation method doSet.

/**
 * Do set.<br>
 * For the bounding box height, the maximum of given fullHeight, eyeHeight
 * with sneaking ignored and entity height is used. Sets isLiving and
 * eyeHeight.
 *
 * @param location
 *            the location
 * @param entity
 *            the entity
 * @param fullWidth
 *            the full width
 * @param fullHeight
 *            the full height
 * @param yOnGround
 *            the y on ground
 */
protected void doSet(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) {
    final double eyeHeight;
    final boolean isLiving;
    if (entity instanceof LivingEntity) {
        isLiving = true;
        final LivingEntity living = (LivingEntity) entity;
        eyeHeight = living.getEyeHeight();
        fullHeight = Math.max(Math.max(fullHeight, eyeHeight), living.getEyeHeight(true));
    } else {
        isLiving = false;
        eyeHeight = fullHeight;
    }
    doSetExactHeight(location, entity, isLiving, fullWidth, eyeHeight, fullHeight, fullHeight, yOnGround);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity)

Example 84 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Skills by StarTux.

the class BukkitSkillHunt method onEntityDamageByEntity.

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (!(event.getEntity() instanceof LivingEntity))
        return;
    LivingEntity entity = (LivingEntity) event.getEntity();
    if (!(event.getDamager() instanceof Arrow))
        return;
    Arrow arrow = (Arrow) event.getDamager();
    if (!(arrow.getShooter() instanceof Player))
        return;
    Player player = (Player) arrow.getShooter();
    if (!allowPlayer(player))
        return;
    if (entity.getCustomName() != null && entity.getCustomName().startsWith("" + ChatColor.COLOR_CHAR))
        return;
    if (BukkitExploits.getInstance().recentKillDistance(player, entity.getLocation(), killDistanceInterval) < minKillDistance)
        return;
    double percentage = BukkitExploits.getInstance().getEntityDamageByPlayerRemainderPercentage(entity, Math.min(entity.getHealth(), event.getFinalDamage()));
    if (getSkills().hasDebugMode(player))
        BukkitUtil.msg(player, "&eHunt Dmg=%.02f/%.02f Pct=%.02f", event.getFinalDamage(), entity.getMaxHealth(), percentage);
    giveReward(player, rewardForEntity(entity), percentage);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Arrow(org.bukkit.entity.Arrow) Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 85 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Ublisk by Derkades.

the class EntityDeath method entityDeath.

@EventHandler
public void entityDeath(EntityDeathEvent event) {
    // Never let the entity drop any XP on death
    event.setDroppedExp(0);
    LivingEntity entity = event.getEntity();
    if (entity.getType() == EntityType.PLAYER) {
        return;
    }
    if (entity.getLastDamageCause().getCause() != DamageCause.ENTITY_ATTACK) {
        return;
    }
    if (!Mobs.getEntityTypes().contains(entity.getType())) {
        return;
    }
    // Now we know that the entity has been killed by the player, so it is safe to call getKiller()
    UPlayer player = new UPlayer(entity.getKiller());
    // Track player kills for statistics
    player.tracker(PlayerInfo.MOB_KILLS);
    if (!Mobs.SPAWNED_MOBS.containsKey(entity.getUniqueId())) {
        player.sendActionBarMessage(ChatColor.RED + "Error :(", 0);
    }
    // Get mob from entity UUID
    Mob mob = Mobs.SPAWNED_MOBS.get(entity.getUniqueId());
    // Drop gold and items
    if (mob.getMobDrops().length > 0) {
        for (MobDrop drop : mob.getMobDrops()) drop.drop(entity.getLocation());
    }
    for (MobDrop drop : mob.getGoldDrop().getMobDrops()) drop.drop(entity.getLocation());
    String name = mob.getName();
    String color;
    int xp;
    if (DoubleXP.isActive()) {
        xp = mob.getXP() * 2;
        color = ChatColor.GOLD.toString();
    } else {
        xp = mob.getXP();
        color = ChatColor.GREEN.toString();
    }
    player.sendActionBarMessage(color + "+ " + xp + " XP", 15);
    player.addXP(xp);
    Logger.log(LogLevel.INFO, "XP", "Given " + player.getName() + " " + xp + " for killing a " + name);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) MobDrop(xyz.derkades.ublisk.mob.MobDrop) Mob(xyz.derkades.ublisk.mob.Mob) UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)322 Entity (org.bukkit.entity.Entity)169 Player (org.bukkit.entity.Player)121 Location (org.bukkit.Location)71 EventHandler (org.bukkit.event.EventHandler)63 Vector (org.bukkit.util.Vector)60 ItemStack (org.bukkit.inventory.ItemStack)47 ArrayList (java.util.ArrayList)41 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)37 PotionEffect (org.bukkit.potion.PotionEffect)34 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)30 Block (org.bukkit.block.Block)24 Mage (com.elmakers.mine.bukkit.api.magic.Mage)22 Projectile (org.bukkit.entity.Projectile)20 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)18 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)17 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)16 Target (com.elmakers.mine.bukkit.utility.Target)15 World (org.bukkit.World)14 Creature (org.bukkit.entity.Creature)14