Posted October 19, 20232 yr I have tried several different things in order to try to get where the player is looking at such as player.getLookAngle() (which now I realize doesn't have anything to do with that) and a few other methods that I can't remember right now, but the only thing I've found that works is getPlayerPOVHitResult, and that only works in children of the Item class. Currently, I'm trying to get an entity to spawn where the player is looking at 100 blocks in the air, and I have an item mostly set up to do so, but getPlayerPOVHitResult is not working in this situation. Here is exactly what I'm doing, if you know how to make this work properly your assistance would be highly appreciated: BlockHitResult povHitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); if(!level.isClientSide && hand == InteractionHand.MAIN_HAND && !player.isCrouching() && mode == 6 && mode6) { DescendingShellEntity descendingShell = new DescendingShellEntity(TMEntityTypes.DESCENDING_SHELL.get(), level); descendingShell.setPos(povHitResult.getBlockPos().getX(), povHitResult.getBlockPos().getY() + 100, povHitResult.getBlockPos().getZ()); level.addFreshEntity(descendingShell); Here's the GitHub repo if it helps: https://github.com/xCrazyFeline/Turtle-Magic-1.19.2-FORGE- Edited October 26, 20232 yr by xCrazyFeline Adding GitHub repo link Sanity is for losers. -Felix
October 28, 20232 yr I used the following code: public static @NotNull Vec3 clipWithDistance(@NotNull Player player, @NotNull Level level, double clipDistance) { double vecX = Math.sin(-player.getYRot() * (Math.PI / 180.0) - Math.PI) * -Math.cos(-player.getXRot() * (Math.PI / 180.0)); double vecY = Math.sin(-player.getXRot() * (Math.PI / 180.0)); double vecZ = Math.cos(-player.getYRot() * (Math.PI / 180.0) - Math.PI) * -Math.cos(-player.getXRot() * (Math.PI / 180.0)); return level.clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(vecX * clipDistance, vecY * clipDistance, vecZ * clipDistance), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getLocation(); } Note if you also want to recognise Fluid as a block, you have to change ClipContext.Fluid.
October 28, 20232 yr Author That works! Thank you! I'll add your name to the mod's credits for your assistance. (I really can not thank you enough for this, I've been working on it for weeks, and it also helped me with something else I was going to have to fix) Edited October 28, 20232 yr by xCrazyFeline Sanity is for losers. -Felix
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.