# [1.16.5] helper to find an vector3d point in the space at fixed distance based on the direction the entity is looking at

## Recommended Posts

nod nod nod
long time ago i made this pieze of code to calculate a point in the space directly right in the player entity line of siege at an arbitrary float distance sooo later i can use that second vector3d point to raytrace
whatever the player is looking at, the old one i have dont works anymore and theres many changes in the entities class

scavenging on the arrow entity class i found an Vector3d vector3d = this.getDeltaMovement();
but i need something based on the direction the entity is looking at a set distance

is there some already made tool in minecraft code to do that ?

old code i need to update

```	    // #########################################################################3
public void calcularVectores(Entity player, int distancia, float precision) {
// float distancia = 5.0F;
this.vectorInicio = new Vec3d(
player.posX,
(player.posY + player.getEyeHeight()),
player.posZ
);
this.gpitch = util.fixGrad(player.getPitchYaw().x); // pitch, nose up or down about an axis

this.gyaw = util.fixGrad( player.getPitchYaw().y); //yaw, nose left or right about an axis

//100% = 0.0F grados de error
//0% = 45.0F grados de error en cualquier direccion
if( precision < 99.9F) {
float p = (((100F - precision) / 100F) * 45F);
this.gpitch += (p * ((50F - util.rollsAd100dice()) / 100));
this.gyaw += (p * ((50F - util.rollsAd100dice()) / 100));
}

double tmpryaw = this.ryaw - 1.5707964D;

this.vectorObjetivo = new Vec3d(
this.vectorInicio.x - ((Math.cos(tmpryaw)) * (Math.cos(this.rpitch) * distancia)) ,
this.vectorInicio.y - (Math.sin(this.rpitch) * distancia),
this.vectorInicio.z - ((Math.sin(tmpryaw)) * (Math.cos(this.rpitch) * distancia))
);

}
```

##### Share on other sites

I am not sure I understand, but you mentioned ray trace

Maybe you want entity.pick() which uses level.clip()?

e.g. Forge's debug overlay determining which block/fluid is being looked at.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

##### Share on other sites

more or less yes
getting the block the entity is looking at is one of the uses  but also helps to know if player is looking at an entity or agressive mob

the code just return the second vector3d soo i could do raytrace

## 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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

• ### Posts

• I want my mod to add two new NBT values to Block Displays and Item Displays (Like left-rotation, scale, transformation, etc.), which I call texture_repetition and texture_shift (both Vector3f variables). Texture_repetition allows the Display to repeat its texture or only show part of it, and the texture_shift value allows you to shift to the part of the texture you want the display to show. I already tried Mixins, and I assume I need to use the renderstate() function and entityData variable, but entityData is protected, which means I can not edit it using Mixins. How would I add these NBT values to the Display class without using the entityData class? (These two data values, if coded correctly, could allow slabs/stairs/walls of any block to be represented using Displays without being limited by the vanilla inventory options)
• the version is forge 1.20.1-47.2.4 https://mclo.gs/Dr4Mjmk
• It crashes as soon as i go above 360 mods or add "Just Another Void Dimension https://docs.google.com/document/d/1hcqI7x-TAou6YoTi3gSpLlmK8lj0qWgKQS50mu8Gxfw/edit   PS: Could not post the error here because of some TERMS(Basically the entire crash report) that are not allowed.
• so I am trying to set up a sword with a withering effect on left click or attack, but the idea is that the effect will be stronger or weaker depending on the dimension. so I want it to see which dimension the player is in if it is the right one then test for living entity and if both are true then add withering. I have the living entity tester, but I can't figure out how to add the dimension checker. I am on Minecraft version 1.20.1 and Forge version 47.2.0, with parchment mappings version 2023.09.03-1.20.1 Thanks in advance for any help!

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...