Refine search
@Override protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) { BlockFace facing = BlockDispenser.getFacing(block); Location targetLocation = block.getLocation().clone() .add(facing.getModX(), facing.getModY(), facing.getModZ()); for (Entity entity : targetLocation.getWorld().getNearbyEntities(targetLocation, 3, 3, 3)) { switch (entity.getType()) { case PLAYER: case ARMOR_STAND: targetLocationTest1 = (player.getLocation().getBlockX() == targetLocation.getX() && player.getLocation().getBlockY() == targetLocation.getY() && player.getLocation().getBlockZ() == targetLocation.getZ()); targetLocationTest2 = (player.getEyeLocation().getBlockX() == targetLocation.getX() && player.getEyeLocation().getBlockY() == targetLocation.getY() && player.getEyeLocation().getBlockZ() == targetLocation.getZ()); if ((targetLocationTest1 || targetLocationTest2)) { return ((GlowInventory) ((Player) player).getInventory()) .tryToFillSlots(stack, 36, 40);
private int getProtectionFactor(Entity entity) { if (!(entity instanceof LivingEntity)) { return 0; } LivingEntity livingEntity = (LivingEntity) entity; int level = 0; if (livingEntity.getEquipment() != null) { for (ItemStack stack : livingEntity.getEquipment().getArmorContents()) { if (stack != null) { int stackLevel = stack.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); if (stackLevel > level) { level = stackLevel; } } } } return level << 1; }
/** * Attempts to add the effect represented by this object to the given * {@link LivingEntity}. * * @see LivingEntity#addPotionEffect(PotionEffect) * @param entity The entity to add this effect to * @return Whether the effect could be added */ public boolean apply(LivingEntity entity) { return entity.addPotionEffect(this); }
/** * Constructs the BlockIterator. * * @param entity Information from the entity is used to set up the trace * @param maxDistance This is the maximum distance in blocks for the * trace. Setting this value above 140 may lead to problems with * unloaded chunks. A value of 0 indicates no limit */ public BlockIterator(LivingEntity entity, int maxDistance) { this(entity.getLocation(), entity.getEyeHeight(), maxDistance); }
/** * Process teleportation when collide with an entity. * * @param entity the eneity that the ender pearl collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (source instanceof Entity) { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(entity.getLocation().getBlock()); }
@Override public void collide(LivingEntity entity) { double damage = spigot.getDamage(); ProjectileSource shooter = getShooter(); if (isCritical()) { damage += 1.0; } entity.damage(damage, shooter instanceof Entity ? (Entity) shooter : null, EntityDamageEvent.DamageCause.PROJECTILE); // Burning arrow ignites target, but doesn't stack if target is already on fire. if (getFireTicks() > 0 && entity.getFireTicks() < TARGET_BURN_TICKS) { entity.setFireTicks(TARGET_BURN_TICKS); } // TODO: knockback entity.setArrowsStuck(entity.getArrowsStuck() + 1); remove(); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { Location loc = event.getEntity().getLocation(); if (loc == null) return; World world = loc.getWorld(); if (world == null) return; BorderData border = Config.Border(world.getName()); if (border == null) return; if (!border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound())) { event.setCancelled(true); } }
@Override public void execute(Arena arena, MABoss boss) { Location bLoc = boss.getEntity().getLocation(); for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) { Location loc = p.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); p.setVelocity(v.normalize().setY(0.8)); } } }
Location destination = getLocation(); Entity entity = (Entity) source; Location entityLocation = entity.getLocation(); destination.add(0, 0.3, 0); destination.setPitch(entityLocation.getPitch()); destination.setYaw(entityLocation.getYaw()); entity.teleport(destination, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); ((LivingEntity) entity).damage(ENDER_PEARL_DAMAGE, EntityDamageEvent.DamageCause.FALL);
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSilurianSpawn(CreatureSpawnEvent event) { if (!event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)) { return; } if (!event.getLocation().getWorld().getName().equals("Siluria")) { return; } if (!event.getEntity().getType().equals(EntityType.SKELETON)) { return; } LivingEntity le = event.getEntity(); // it's a Silurian - disguise it! twaAPI.setSilurianEquipment(le, false); } }
/** * Monitor EntityDeath events. * * @param event * The event to watch */ @EventHandler(priority = EventPriority.MONITOR) public void onEntityDeath(EntityDeathEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; LivingEntity entity = event.getEntity(); if (Misc.isNPCEntity(entity)) { return; } Archery.arrowRetrievalCheck(entity); }
@Override public void updated(@Nullable ItemStack itemStack) { Location location = entity instanceof LivingEntity ? ((LivingEntity)entity).getEyeLocation() : entity.getLocation(); location.getWorld().dropItemNaturally(location, itemStack); } });
public static void playGreaterImpactEffect(LivingEntity livingEntity) { if (!Config.getInstance().getGreaterImpactEffectEnabled()) { return; } Location location = livingEntity.getEyeLocation(); livingEntity.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); }
@Override public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) { if (rand.nextInt(chance) == 0) { if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); Location loc = entity.getLocation(); int x = (int) loc.getX(); int y = (int) loc.getY(); int z = (int) loc.getZ(); entity.setHealth(0); String cmd = command.replace("${x}", String.valueOf(x)).replace("${y}", String.valueOf(y)).replace("${z}", String.valueOf(z)); for (int i = 0; i < count; i++) Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd); return PowerResult.ok(damage); } return PowerResult.noop(); }
public static Object armorstandCreation(Location location, Entity entity, ServerMob serverMob) { try { Object armorstand = entity.getWorld().spawnEntity(entity.getLocation().clone().add(0, ((LivingEntity) entity).getEyeHeight() - (entity instanceof Wither ? 0.15 : 0.3), 0), EntityType.valueOf("ARMOR_STAND")); armorstand.getClass().getMethod("setVisible", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setCustomNameVisible", boolean.class).invoke(armorstand, true); armorstand.getClass().getMethod("setGravity", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setBasePlate", boolean.class).invoke(armorstand, false); armorstand.getClass().getMethod("setSmall", boolean.class).invoke(armorstand, true); armorstand.getClass().getMethod("setCanPickupItems", boolean.class).invoke(armorstand, false); return armorstand; } catch (Exception ex) { ex.printStackTrace(); } return null; } }
.filter(entity -> entity instanceof LivingEntity && !entity.isDead()) .forEach(entity -> { Vector pos = entity.getLocation().toVector(); int minY = getHighestBlockYAt(pos.getBlockX(), pos.getBlockZ()); if (pos.getBlockY() >= minY) { .get(ThreadLocalRandom.current().nextInt(livingEntities.size())); Vector newTarget = entity.getLocation().toVector(); x = newTarget.getBlockX(); z = newTarget.getBlockZ(); strikeLightning(new Location(this, x, y, z));
@Override public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) { Location location = entity.getLocation(); Location start = player.getLocation(); if (start.distanceSquared(location) >= distance * distance) { player.sendMessage(I18n.format("message.too.far")); return PowerResult.noop(); } return fire(player, stack, location).with(damage); }
if (sender instanceof Entity) { Entity entity = (Entity) sender; if (entity.isDead()) { new LocalizedStringImpl("kill.self-dead", commandMessages.getResourceBundle()) .send(entity); } else if (entity instanceof LivingEntity) { LivingEntity living = (LivingEntity) entity; living.damage(Double.MAX_VALUE, EntityDamageEvent.DamageCause.SUICIDE); new LocalizedStringImpl("kill.done", commandMessages.getResourceBundle()) .send(sender, CommandUtils.getName(entity)); } else { entity.remove(); new LocalizedStringImpl("kill.done", commandMessages.getResourceBundle()) .send(sender, CommandUtils.getName(entity)); if (entity instanceof LivingEntity) { LivingEntity living = (LivingEntity) entity; living.damage(Double.MAX_VALUE, EntityDamageEvent.DamageCause.VOID); } else { entity.remove(); return false; } else { player.damage(Double.MAX_VALUE, EntityDamageEvent.DamageCause.VOID); new LocalizedStringImpl("kill.done", commandMessages.getResourceBundle()) .send(sender, player.getName()); return true;
setVelocity(velocity); } else { Vector direction = boostedEntity.getLocation().getDirection(); Vector velocity = boostedEntity.getVelocity(); velocity.setZ(velocity.getZ() + dz); boostedEntity.setVelocity(velocity); this.setVelocity(velocity); Location location = boostedEntity.getLocation().add(velocity); if (boostedEntity instanceof GlowEntity) { ((GlowEntity) boostedEntity).setRawLocation(location, false); } else { boostedEntity.teleport(location); setRawLocation(this.location.add(velocity), false);
@Override public void run() { if (livingEntity.isValid()) { Location location = livingEntity.getLocation(); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); } TamingManager.removeFromTracker(this); this.cancel(); }