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

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

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

Entity.getEyeHeight介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

private static Vector3 getRelativeViewVector(Vector3 pos) {
  Entity renderEntity = Minecraft.getMinecraft().getRenderViewEntity();
  return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
}

代码示例来源:origin: Electrical-Age/ElectricalAge

public static double getHeadPosY(Entity e) {
  if (e instanceof EntityOtherPlayerMP)
    return e.posY + e.getEyeHeight();
  return e.posY;
}

代码示例来源:origin: Vazkii/Botania

public static RayTraceResult raytraceFromEntity(World worldIn, Entity playerIn, boolean useLiquids, double range) {
  float f = playerIn.rotationPitch;
  float f1 = playerIn.rotationYaw;
  double d0 = playerIn.posX;
  double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
  double d2 = playerIn.posZ;
  Vec3d vec3d = new Vec3d(d0, d1, d2);
  float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
  float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
  float f4 = -MathHelper.cos(-f * 0.017453292F);
  float f5 = MathHelper.sin(-f * 0.017453292F);
  float f6 = f3 * f4;
  float f7 = f2 * f4;
  double d3 = range; // Botania - use custom range param, don't limit to reach distance
  /*if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
  {
    d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
  }*/
  Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
  return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public BlockPos getPos() {
  return new BlockPos(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public Vec3d getLoc() {
  return new Vec3d(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
}

代码示例来源:origin: OpenModularTurretsTeam/OpenModularTurrets

@Override
protected void doTargetedShot(Entity target, ItemStack ammo) {
  shootRay(target.posX, target.posY + target.getEyeHeight(), target.posZ, getBaseTurretAccuracy());
}

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

public boolean teleportToEntity(Entity p_70816_1_) {
 Vec3d vec3 = new Vec3d(posX - p_70816_1_.posX, getEntityBoundingBox().minY + height / 2.0F - p_70816_1_.posY + p_70816_1_.getEyeHeight(),
   posZ - p_70816_1_.posZ);
 vec3 = vec3.normalize();
 double d0 = 16.0D;
 double d1 = posX + (rand.nextDouble() - 0.5D) * 8.0D - vec3.x * d0;
 double d2 = posY + (rand.nextInt(16) - 8) - vec3.y * d0;
 double d3 = posZ + (rand.nextDouble() - 0.5D) * 8.0D - vec3.z * d0;
 return teleportTo(d1, d2, d3);
}

代码示例来源:origin: OpenModularTurretsTeam/OpenModularTurrets

@Override
protected void doTargetedShot(Entity target, ItemStack ammo) {
  shootRay(target.posX, target.posY + target.getEyeHeight(), target.posZ, this.getActualTurretAccuracy());
}

代码示例来源:origin: Silentine/GrimoireOfGaia

/**
 * Teleport the enderman to another entity
 */
boolean teleportToEntity(Entity entity) {
  Vec3d vec3d = new Vec3d(posX - entity.posX, getEntityBoundingBox().minY + height / 2.0D - entity.posY + entity.getEyeHeight(), posZ - entity.posZ);
  vec3d = vec3d.normalize();
  double d1 = posX + (rand.nextDouble() - 0.5D) * 8.0D - vec3d.x * 16.0D;
  double d2 = posY + (rand.nextInt(16) - 8) - vec3d.y * 16.0D;
  double d3 = posZ + (rand.nextDouble() - 0.5D) * 8.0D - vec3d.z * 16.0D;
  return teleportTo(d1, d2, d3);
}

代码示例来源:origin: Silentine/GrimoireOfGaia

/**
 * Teleport the enderman to another entity
 */
boolean teleportToEntity(Entity entity) {
  Vec3d vec3d = new Vec3d(posX - entity.posX, getEntityBoundingBox().minY + height / 2.0D - entity.posY + entity.getEyeHeight(), posZ - entity.posZ);
  vec3d = vec3d.normalize();
  double d1 = posX + (rand.nextDouble() - 0.5D) * 8.0D - vec3d.x * 16.0D;
  double d2 = posY + (rand.nextInt(16) - 8) - vec3d.y * 16.0D;
  double d3 = posZ + (rand.nextDouble() - 0.5D) * 8.0D - vec3d.z * 16.0D;
  return teleportTo(d1, d2, d3);
}

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

public static Vector2d getPitchYaw(BlockPos pos, Entity entityIn)
{
  if (entityIn == null)
  {
    return new Vector2d(0, 0);
  }
  double distanceX = entityIn.posX - (pos.getX() + 0.5);
  double distanceY = entityIn.posY + (double) entityIn.getEyeHeight() - (pos.getY() + 0.5);
  double distanceZ = entityIn.posZ - (pos.getZ() + 0.5);
  double radialDistance = Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
  double yaw = Math.atan2(-distanceX, distanceZ) * 180 / Math.PI;
  double pitch = -Math.atan2(distanceY, radialDistance) * 180 / Math.PI;
  return new Vector2d(pitch, yaw);
}

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

/**
   * Updates the task
   */
  @Override
  public void updateTask() {
    double lx = watchedEntity.posX;
    double ly = watchedEntity.posY + watchedEntity.getEyeHeight();
    double lz = watchedEntity.posZ;
    dragon.getLookHelper().setLookPosition(lx, ly, lz, 10, dragon.getVerticalFaceSpeed());
    watchTicks--;
  }
}

代码示例来源:origin: SquidDev-CC/plethora

public ChatMessage(Entity entity, ITextComponent message) {
  this(
    entity.getEntityWorld().provider.getDimension(),
    new Vec3d(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ),
    message
  );
}

代码示例来源:origin: Vazkii/Psi

@Override
public Object execute(SpellContext context) throws SpellRuntimeException {
  Entity e = this.getParamValue(context, target);
  if(e == null)
    throw new SpellRuntimeException(SpellRuntimeException.NULL_TARGET);
  Vector3 vec = Vector3.fromEntity(e);
  if(e instanceof EntityPlayer)
    vec.add(0, e.getEyeHeight(), 0);
  return vec;
}

代码示例来源:origin: MightyPirates/TIS-3D

private boolean isRenderingBackFace(final Face face, final double dx, final double dy, final double dz) {
  final EnumFacing facing = Face.toEnumFacing(face.getOpposite());
  final double dotProduct = facing.getFrontOffsetX() * dx + facing.getFrontOffsetY() * (dy - rendererDispatcher.entity.getEyeHeight()) + facing.getFrontOffsetZ() * dz;
  return dotProduct < 0;
}

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

public boolean canEntityBeSeen(World world, BlockPos pos, Entity entityIn)
{
  return world.rayTraceBlocks(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), new Vec3d(entityIn.posX, entityIn.posY + (double) entityIn.getEyeHeight(), entityIn.posZ), false, true, false) == null;
}

代码示例来源:origin: Vazkii/Psi

public static RayTraceResult raycast(Entity e, double len) throws SpellRuntimeException {
  Vector3 vec = Vector3.fromEntity(e);
  if(e instanceof EntityPlayer)
    vec.add(0, e.getEyeHeight(), 0);
  
  Vec3d look = e.getLookVec();
  if(look == null)
    throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR);
  return raycast(e.getEntityWorld(), vec, new Vector3(look), len);
}

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

public static boolean canEntitySeeBlock(World world, Entity entity, BlockPos pos) {
  Vec3d relativePosition = new Vec3d(entity.posX - pos.getX() - 0.5, entity.posY + (double) entity.getEyeHeight() - pos.getY() - 0.5, entity.posZ - pos.getZ() - 0.5);
  EnumFacing dir = EnumFacing.getFacingFromVector((float) relativePosition.x, (float) relativePosition.y, (float) relativePosition.z);
  RayTraceResult result = world.rayTraceBlocks(new Vec3d(entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ), new Vec3d(pos.getX() + 0.5 + dir.getFrontOffsetX() * 0.4, pos.getY() + 0.5 + dir.getFrontOffsetY() * 0.4, pos.getZ() + 0.5 + dir.getFrontOffsetZ() * 0.4), false, true, true);
  return result == null || pos.equals(result.getBlockPos());
}

代码示例来源:origin: SquidDev-CC/plethora

public EntityLaser(World world, @Nonnull Entity shooter, float inaccuracy, float potency) {
  this(world);
  this.potency = potency;
  setShooter(shooter, PlayerHelpers.getProfile(shooter));
  setLocationAndAngles(shooter.posX, shooter.posY + shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
  posX -= MathHelper.cos(rotationYaw / 180.0f * (float) Math.PI) * 0.16f;
  posY -= 0.1;
  posZ -= MathHelper.sin(rotationYaw / 180.0f * (float) Math.PI) * 0.16f;
  setPosition(posX, posY, posZ);
  motionX = -MathHelper.sin(rotationYaw / 180.0f * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0f * (float) Math.PI);
  motionZ = MathHelper.cos(rotationYaw / 180.0f * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0f * (float) Math.PI);
  motionY = -MathHelper.sin(rotationPitch / 180.0f * (float) Math.PI);
  shoot(motionX, motionY, motionZ, 1.5f, inaccuracy);
}

代码示例来源:origin: TehNut/HWYLA

public static RayTraceResult rayTraceServer(Entity entity, double distance) {
    double eyeHeight = entity.posY + entity.getEyeHeight();
    Vec3d headVec = new Vec3d(entity.posX, eyeHeight, entity.posZ);
    Vec3d start = new Vec3d(headVec.x, headVec.y, headVec.z);
    Vec3d lookVec = entity.getLook(1.0F);
    headVec.add(new Vec3d(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance));

    return entity.getEntityWorld().rayTraceBlocks(start, headVec, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
  }
}

相关文章

微信公众号

最新文章

更多

Entity类方法