Search In
• More options...
Find results that contain...
Find results in...

# Problem with particle coordinates

## Recommended Posts

I am trying to use a particle to draw a beam from the player to the target. Instead the particle a good distance from both the player and the target:

The code:

```	@Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX,
float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
Vec3d lookVec = Helpers.getEntityLook(Minecraft.getMinecraft().player, 1).eyePosition;
drawBeam(buffer, origin, target, lookVec, 2);

}
public static void drawBeam(BufferBuilder buffer, Vec3d S, Vec3d E, Vec3d P, float width) {
Vec3d PS = S.subtract(P);
Vec3d SE = E.subtract(S);

Vec3d normal = PS.crossProduct(SE).normalize();

Vec3d half = normal.scale(width);
Vec3d p2 = S.subtract(half);
Vec3d p4 = E.subtract(half);
int brightness = 240;
int b1 = brightness >> 16 & 65535;
int b2 = brightness & 65535;
buffer.pos(p1.x, p1.y, p1.z).tex(0.0D, 0.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
buffer.pos(p2.x, p2.y, p2.z).tex(1.0D, 0.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
buffer.pos(p3.x, p3.y, p3.z).tex(1.0D, 1.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
buffer.pos(p4.x, p4.y, p4.z).tex(0.0D, 1.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();

}```

Edited by Lucius Q. User

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

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

×

• 14
• 23
• 1
• 9
• 0
• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...