org.bukkit.entity.Entity.getType()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(230)

本文整理了Java中org.bukkit.entity.Entity.getType()方法的一些代码示例,展示了Entity.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getType()方法的具体详情如下:
包路径:org.bukkit.entity.Entity
类名称:Entity
方法名:getType

Entity.getType介绍

[英]Get the type of the entity.
[中]获取实体的类型。

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
   * Gets the EntityType of the Entity involved in this event.
   *
   * @return EntityType of the Entity involved in this event
   */
  public EntityType getEntityType() {
    return entity.getType();
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Gets the name of an entity.
 *
 * @param entity an entity
 * @return the first of the following that exists and is non-empty: {@code
 *         entity.getCustomName()}, {@code entity.getName()}, {@code
 *         entity.getType().getName()}
 */
public static String getName(Entity entity) {
  String customName = entity.getCustomName();
  if (customName != null && !customName.isEmpty()) {
    return customName;
  }
  String name = entity.getName();
  if (name == null || name.isEmpty()) {
    name = entity.getType().getName();
  }
  return name;
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Evaluates a condition for an entity.
 *
 * @param entity the entity
 * @param condition the condition string to evaluate
 * @return true if the condition is satisfied; false otherwise
 */
public static boolean conditionValue(GlowLivingEntity entity, String condition) {
  if (condition.equals("ENTITY_ONFIRE")) {
    return entity.getFireTicks() > 0;
  }
  if (condition.startsWith("ENTITY_KILLER_")) {
    EntityType type = EntityType.valueOf(condition.substring("ENTITY_KILLER_".length()));
    return entity.getLastDamager() != null && entity.getLastDamager().getType() == type;
  }
  if (condition.contains(".")) {
    return (boolean) process(entity, condition);
  }
  // todo: more conditions, reflection
  return false;
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void start(GlowLivingEntity entity) {
  target = null;
  List<Entity> nearbyEntities = entity.getNearbyEntities(RANGE, RANGE / 2, RANGE);
  double nearestSquared = Double.MAX_VALUE;
  for (Entity nearbyEntity : nearbyEntities) {
    if (nearbyEntity.getType() != EntityType.PLAYER) {
      continue;
    }
    double dist = nearbyEntity.getLocation().distanceSquared(entity.getLocation());
    if (dist < nearestSquared) {
      target = (GlowPlayer) nearbyEntity;
      nearestSquared = dist;
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void start(GlowLivingEntity entity) {
  target = null;
  List<Entity> nearbyEntities = entity.getNearbyEntities(RANGE, RANGE / 2, RANGE);
  double nearestSquared = Double.MAX_VALUE;
  for (Entity nearbyEntity : nearbyEntities) {
    if (nearbyEntity.getType() != EntityType.PLAYER) {
      continue;
    }
    double dist = nearbyEntity.getLocation().distanceSquared(entity.getLocation());
    if (dist < nearestSquared) {
      target = (GlowPlayer) nearbyEntity;
      nearestSquared = dist;
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

continue;
if (!types.contains(entity.getType())) {
  continue;
  continue;
if (gameModes != null && entity.getType() != EntityType.PLAYER) {
  continue;
  continue;
if (maxLevel != null && entity.getType() != EntityType.PLAYER) {
  continue;
  continue;
if (minLevel != null && entity.getType() != EntityType.PLAYER) {
  continue;

代码示例来源:origin: GlowstoneMC/Glowstone

private GlowItem getFirstDroppedItem(Location location) {
  for (Entity entity : location.getChunk().getEntities()) {
    if (location.getBlockX() != entity.getLocation().getBlockX()
      || location.getBlockY() != entity.getLocation().getBlockY()
      || location.getBlockZ() != entity.getLocation().getBlockZ()) {
      continue;
    }
    if (entity.getType() != EntityType.DROPPED_ITEM) {
      continue;
    }
    return ((GlowItem) entity);
  }
  return null;
}

代码示例来源:origin: GlowstoneMC/Glowstone

if (source == null || source.getType() == EntityType.PRIMED_TNT) {
  damageCause = DamageCause.BLOCK_EXPLOSION;
} else {

代码示例来源:origin: GlowstoneMC/Glowstone

switch (entity.getType()) {
  case PLAYER:
  case ARMOR_STAND:

代码示例来源:origin: GlowstoneMC/Glowstone

if (e instanceof Creature && (e.getType() != EntityType.PIG_ZOMBIE || ((PigZombie) e)
  .isAngry()) && isWithinDistance(e, block.getRelative(BlockFace.DOWN), 8, 5, 8)) {
  GlowstoneMessages.Bed.MOB.send(player);

代码示例来源:origin: ProjectKorra/ProjectKorra

public static boolean isUndead(final Entity entity) {
  if (entity == null) {
    return false;
  } else if (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE) {
    return true;
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

Entity e = // some entity
if ("TypeOne".equals(e.getType()) {
 // process entity of type one...
} else if ("TypeTwo".equals(e.getType()) {
 // process entity of type two...
} else if ("TypeThree".equals(e.getType()) {
 // process entity of type three...
} else {
 // default processing logic
}

代码示例来源:origin: AddstarMC/Minigames

public EntityData(Entity ent, MinigamePlayer modifier, boolean created){
  this.ent = ent;
  entType = ent.getType();
  entLocation = ent.getLocation();
  player = modifier;
  this.created = created;
}

代码示例来源:origin: garbagemule/MobArena

private static boolean isFollowing(Entity entity) {
  switch (entity.getType()) {
    case WOLF:
      return !((Wolf) entity).isSitting();
    case OCELOT:
      return !((Ocelot) entity).isSitting();
  }
  return false;
}

代码示例来源:origin: mcMMO-Dev/mcMMO

/**
 * Fix issues with death messages caused by the mob healthbars.
 *
 * @param deathMessage The original death message
 * @param player The player who died
 * @return the fixed death message
 */
public static String fixDeathMessage(String deathMessage, Player player) {
  EntityDamageEvent lastDamageCause = player.getLastDamageCause();
  String replaceString = lastDamageCause instanceof EntityDamageByEntityEvent ? StringUtils.getPrettyEntityTypeString(((EntityDamageByEntityEvent) lastDamageCause).getDamager().getType()) : "a mob";
  return deathMessage.replaceAll("(?:\u00A7(?:[0-9A-FK-ORa-fk-or]){1}(?:[\u2764\u25A0]{1,10})){1,2}", replaceString);
}

代码示例来源:origin: NoCheatPlus/NoCheatPlus

private void debugNestedVehicleEnter(Player player) {
  debug(player, "Vehicle enter: Skip on nested vehicles, possibly with multiple players involved, who would do that?");
  List<String> vehicles = new LinkedList<String>();
  Entity tempVehicle = player.getVehicle();
  while (tempVehicle != null) {
    vehicles.add(tempVehicle.getType().toString());
    tempVehicle = tempVehicle.getVehicle();
  }
  if (!vehicles.isEmpty()) {
    debug(player, "Vehicle enter: Nested vehicles: " + StringUtil.join(vehicles, ", "));
  }
}

代码示例来源:origin: BigScary/GriefPrevention

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event)
{
  //treat it the same as interacting with an entity in general
  if(event.getRightClicked().getType() == EntityType.ARMOR_STAND)
  {
    this.onPlayerInteractEntity((PlayerInteractEntityEvent)event);
  }
}

代码示例来源:origin: bitquest/bitquest

@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
 Player player = event.getPlayer();
 Entity entity = event.getRightClicked();
 if (PROTECTED_ENTITIES.contains(entity.getType())) {
  if (!bitQuest.canBuild(entity.getLocation(), player)) {
   event.setCancelled(true);
  }
 }
}

代码示例来源:origin: BentoBoxWorld/BentoBox

/**
 * Handles placing items into ItemFrames
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerHitEntity(PlayerInteractEntityEvent e) {
  if (e.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) {
    checkIsland(e, e.getRightClicked().getLocation(), Flags.PLACE_BLOCKS);
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public void masterAngler(FishHook hook) {
  Player player = getPlayer();
  Location location = hook.getLocation();
  double biteChance = hook.getBiteChance();
  hookLocation = location;
  if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
    biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
  }
  if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
    biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
  }
  hook.setBiteChance(Math.min(biteChance, 1.0));
}

相关文章