Jump to content

volkov

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by volkov

  1. sorry for stupid question that im about to ask but dose vectors need tow dots but vec3 constructor only requires 1 dot(set of coordinates) and is called vector ? also it works thanks! boolean islookinatit(Player player,LivingEntity entity) { Vec3 vec3 = player.getViewVector(1.0F).normalize(); Vec3 vec31 = new Vec3(entity.getX() - player.getX(), entity.getY() - player.getEyeY(), entity.getZ() - player.getZ()); double d0 = vec31.length(); vec31 = vec31.normalize(); double d1 = vec3.dot(vec31); return d1 > 1.0D - 0.025D / d0 && AtoElineOfSight(player, entity); } public boolean AtoElineOfSight(Entity Ea,Entity Eb) { if (Eb.level != Ea.level) { return false; } else { Vec3 Avec = new Vec3(Ea.getX(), Ea.getEyeY(), Ea.getZ()); Vec3 Bvec = new Vec3(Eb.getX(), Eb.getY(), Eb.getZ()); if (Bvec.distanceTo(Avec) > 128.0D) { return false; } else { return Ea.level.clip(new ClipContext(Avec, Bvec, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, Ea)).getType() == HitResult.Type.MISS; } } } but seems like im understood that im need it to collide not just with position of entity but with its boundingbox or hitbox of entity sorry for putting question so badly and also sorry for such a long delay with answer
  2. im looked if im not mistaken you are talking about function isLookingAtMe()? boolean isLookingAtMe(Player pPlayer) { ItemStack itemstack = pPlayer.getInventory().armor.get(3); if (itemstack.isEnderMask(pPlayer, this)) { return false; } else { Vec3 vec3 = pPlayer.getViewVector(1.0F).normalize(); Vec3 vec31 = new Vec3(this.getX() - pPlayer.getX(), this.getEyeY() - pPlayer.getEyeY(), this.getZ() - pPlayer.getZ()); double d0 = vec31.length(); vec31 = vec31.normalize(); double d1 = vec3.dot(vec31); return d1 > 1.0D - 0.025D / d0 ? pPlayer.hasLineOfSight(this) : false; } }
  3. thanks b.t.w. dose anybody know how to detect entity that collides with ray public static BlockHitResult getTargetofgun(Level pLevel, Player pPlayer, ClipContext.Fluid pFluidMode,double reach/*reach*/) { float f = pPlayer.getXRot(); float f1 = pPlayer.getYRot(); Vec3 vec3 = pPlayer.getEyePosition(); float f2 = Mth.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f3 = Mth.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f4 = -Mth.cos(-f * ((float)Math.PI / 180F)); float f5 = Mth.sin(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; Vec3 vec31 = vec3.add((double)f6 * reach, (double)f5 * reach, (double)f7 * reach); return pLevel.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, pFluidMode, pPlayer)); } is there a function like clip() that detects LivingEntity instead of block
  4. ammm a ray casting like when you send a ray from one dot in direction of another in my case cast a ray from player's head in direction of players view ,sorry for confusion
  5. im want to know how to cast a ray from players head in 1.18.1.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.