net.minecraft.entity.Entity.isEntityAlive()方法的使用及代码示例

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

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

Entity.isEntityAlive介绍

暂无

代码示例

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
  public boolean canInteractWith(EntityPlayer var1) {
    return entity != null && entity.isEntityAlive();
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( entity1.isEntityAlive() )

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( entity1.isEntityAlive() )

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( entity1.isEntityAlive() )

代码示例来源:origin: ata4/dragon-mounts

/**
 * Returns whether an in-progress EntityAIBase should continue executing
 */
@Override
public boolean continueExecuting() {
  if (!watchedEntity.isEntityAlive()) {
    return false;
  }
  if (dragon.getDistanceSqToEntity(watchedEntity) > maxDist * maxDist) {
    return false;
  } else {
    return watchTicks > 0;
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static @Nullable CapturedMob create(@Nullable Entity entity) {
 if (!(entity instanceof EntityLivingBase) || !entity.isEntityAlive() || entity.world.isRemote || entity instanceof EntityPlayer || isBlacklisted(entity)) {
  return null;
 }
 return new CapturedMob((EntityLivingBase) entity);
}

代码示例来源:origin: ldtteam/minecolonies

@Override
public List<AbstractEntityMinecoloniesMob> getHorde(final WorldServer world)
{
  final List<AbstractEntityMinecoloniesMob> raiders = new ArrayList<>();
  for (final UUID uuid : new ArrayList<>(horde))
  {
    final Entity raider = world.getEntityFromUuid(uuid);
    if (!(raider instanceof AbstractEntityMinecoloniesMob) || !raider.isEntityAlive())
    {
      horde.remove(uuid);
      sendHordeMessage();
    }
    else
    {
      raiders.add((AbstractEntityMinecoloniesMob) raider);
    }
  }
  return raiders;
}

代码示例来源:origin: ldtteam/minecolonies

@Override
public void unregisterRaider(@NotNull final AbstractEntityMinecoloniesMob raider, final WorldServer world)
{
  for(final UUID uuid : new ArrayList<>(horde))
  {
    final Entity raiderEntity = world.getEntityFromUuid(uuid);
    if(raiderEntity == null || !raiderEntity.isEntityAlive() || uuid.equals(raider.getUniqueID()))
    {
      horde.remove(uuid);
    }
  }
  sendHordeMessage();
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private boolean tryBreeding(List<EntityPair> targets) {
  Entity animalA;
  Entity animalB;
  EntityPair pair;
  if (!targets.isEmpty()) {
    pair = targets.remove(0);
    animalA = pair.getEntityA(world);
    animalB = pair.getEntityB(world);
    if (!(animalA instanceof EntityAnimal) || !(animalB instanceof EntityAnimal)) {
      return false;
    }
    if (animalA.isEntityAlive() && animalB.isEntityAlive()) {
      EntityPlayer fakePlayer = AWFakePlayer.get(world);
      ((EntityAnimal) animalA).setInLove(fakePlayer);
      ((EntityAnimal) animalB).setInLove(fakePlayer);
      return true;
    }
  }
  return false;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public boolean apply(@Nullable Entity entity) {
 if (entity == null) {
  return false;
 }
 if (!entity.isEntityAlive() || entity.doesEntityNotTriggerPressurePlate() || ((entity instanceof EntityPlayer) && ((EntityPlayer) entity).isSpectator())
   || (capturedMob != null && !capturedMob.isSameType(entity))) {
  return false;
 }
 if (searchClass.isInstance(entity) && whiteClasses.isEmpty()) {
  return true;
 }
 for (Class<? extends Entity> clazz : whiteClasses) {
  if (clazz.isInstance(entity)) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public boolean apply(@Nullable Entity entity) {
    return entity.isEntityAlive() && PixieAIFlee.this.pixie.getEntitySenses().canSee(entity) && !PixieAIFlee.this.pixie.isOnSameTeam(entity);
  }
};

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public boolean apply(@Nullable Entity entity) {
    return entity instanceof  EntityPlayer && entity.isEntityAlive() && StymphalianBirdAIFlee.this.stymphalianBird.getEntitySenses().canSee(entity) && !StymphalianBirdAIFlee.this.stymphalianBird.isOnSameTeam(entity);
  }
};

代码示例来源:origin: WayofTime/BloodMagic

public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) {
  this.canBeSeenSelector = p_apply_1_ -> p_apply_1_.isEntityAlive() && EntityAIRetreatToHeal.this.theEntity.getEntitySenses().canSee(p_apply_1_);
  this.theEntity = theEntityIn;
  this.classToAvoid = classToAvoidIn;
  this.avoidTargetSelector = avoidTargetSelectorIn;
  this.avoidDistance = avoidDistanceIn;
  this.farSpeed = farSpeedIn;
  this.nearSpeed = nearSpeedIn;
  this.entityPathNavigate = theEntityIn.getNavigator();
  this.setMutexBits(3);
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * Returns the closest entity to avoid.
 *
 * @return Entity to avoid.
 */
private Entity getClosestToAvoid()
{
  if (targetEntityClass == EntityPlayer.class)
  {
    return CompatibilityUtils.getWorld(theEntity).getClosestPlayerToEntity(theEntity, (double) distanceFromEntity);
  }
  else
  {
    final Optional<Entity> entityOptional = CompatibilityUtils.getWorld(theEntity).getEntitiesInAABBexcluding(
     theEntity,
     theEntity.getEntityBoundingBox().expand(
      (double) distanceFromEntity,
      3.0D,
      (double) distanceFromEntity),
     target -> target.isEntityAlive() && EntityAICitizenAvoidEntity.this.theEntity.getEntitySenses().canSee(target))
                         .stream()
                         .filter(targetEntityClass::isInstance)
                         .findFirst();
    return entityOptional.isPresent() ? entityOptional.get() : null;
  }
}

代码示例来源:origin: CoFH/CoFHCore

public static void transferEntityToWorld(Entity entity, double x, double y, double z, WorldServer oldWorld, WorldServer newWorld) {
  oldWorld.profiler.startSection("placing");
  x = MathHelper.clamp(x, -29999872, 29999872);
  z = MathHelper.clamp(z, -29999872, 29999872);
  if (entity.isEntityAlive()) {
    entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
    newWorld.spawnEntity(entity);
    newWorld.updateEntityWithOptionalForce(entity, false);
  }
  oldWorld.profiler.endSection();
  entity.setWorld(newWorld);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private boolean tryCulling() {
  Entity entity;
  EntityAnimal animal;
  int fortune = getFortune();
  while (canCull()) {
    entity = world.getEntityByID(entitiesToCull.remove(0));
    if (entity instanceof EntityAnimal && entity.isEntityAlive()) {
      animal = (EntityAnimal) entity;
      if (animal.isInLove() || animal.getGrowingAge() < 0) {
        continue;
      }
      animal.captureDrops = true;
      animal.arrowHitTimer = 10;
      animal.attackEntityFrom(DamageSource.GENERIC, animal.getHealth() + 1);
      for (EntityItem item : animal.capturedDrops) {
        ItemStack stack = item.getItem();
        if (!stack.isEmpty()) {
          if (fortune > 0) {
            stack.grow(world.rand.nextInt(fortune));
          }
          InventoryTools.insertOrDropItem(mainInventory, stack, world, pos);
        }
      }
      animal.capturedDrops.clear();
      animal.captureDrops = false;
      return true;
    }
  }
  return false;
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
 * Changes the world that an entity is in. This allows for changing dimensions safer when
 * working with other mods.
 *
 * @param entity The entity to change the world of.
 * @param worldOld The old entity world.
 * @param worldNew The new entity world.
 */
public static void changeWorld (Entity entity, WorldServer worldOld, WorldServer worldNew) {
  
  final WorldProvider providerOld = worldOld.provider;
  final WorldProvider providerNew = worldNew.provider;
  final double moveFactor = providerOld.getMovementFactor() / providerNew.getMovementFactor();
  final double x = MathHelper.clamp(entity.posX * moveFactor, -29999872, 29999872);
  final double z = MathHelper.clamp(entity.posZ * moveFactor, -29999872, 29999872);
  
  if (entity.isEntityAlive()) {
    
    entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
    worldNew.spawnEntity(entity);
    worldNew.updateEntityWithOptionalForce(entity, false);
  }
  
  entity.setWorld(worldNew);
}

代码示例来源:origin: CoFH/CoFHCore

public static void transferEntityToWorld(Entity entity, WorldServer oldWorld, WorldServer newWorld) {
  WorldProvider pOld = oldWorld.provider;
  WorldProvider pNew = newWorld.provider;
  double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
  double x = entity.posX * moveFactor;
  double z = entity.posZ * moveFactor;
  oldWorld.profiler.startSection("placing");
  x = MathHelper.clamp(x, -29999872, 29999872);
  z = MathHelper.clamp(z, -29999872, 29999872);
  if (entity.isEntityAlive()) {
    entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
    newWorld.spawnEntity(entity);
    newWorld.updateEntityWithOptionalForce(entity, false);
  }
  oldWorld.profiler.endSection();
  entity.setWorld(newWorld);
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@SubscribeEvent
  public void onRenderWorldLast(RenderWorldLastEvent event) {

    Minecraft mc = Minecraft.getMinecraft();
    if (!Minecraft.isGuiEnabled())
      return;
    
    Entity cameraEntity = mc.getRenderViewEntity();
    Frustum frustrum = new Frustum();
    double viewX = cameraEntity.lastTickPosX + (cameraEntity.posX - cameraEntity.lastTickPosX) * event.getPartialTicks();
    double viewY = cameraEntity.lastTickPosY + (cameraEntity.posY - cameraEntity.lastTickPosY) * event.getPartialTicks();
    double viewZ = cameraEntity.lastTickPosZ + (cameraEntity.posZ - cameraEntity.lastTickPosZ) * event.getPartialTicks();
    frustrum.setPosition(viewX, viewY, viewZ);

    List<Entity> loadedEntities = mc.world.getLoadedEntityList();
    for (Entity entity : loadedEntities) {
      if (entity != null && entity instanceof DinosaurEntity) {
        if (entity.isInRangeToRender3d(cameraEntity.getPosition().getX(), cameraEntity.getPosition().getY(), cameraEntity.getPosition().getZ()) && (frustrum.isBoundingBoxInFrustum(entity.getRenderBoundingBox().grow(0.5D))) && entity.isEntityAlive()) {
          ((DinosaurEntity) entity).isRendered = true;
        } else {
          ((DinosaurEntity) entity).isRendered = false;
        }
      }
    }
  }
}

代码示例来源:origin: FTBTeam/FTB-Utilities

if (entity.isEntityAlive())

相关文章

微信公众号

最新文章

更多

Entity类方法