Jump to content

Detect a block a set distance behind a player?


squidlex

Recommended Posts

Right now to get the space behind the player I am creating the AABB:

 AxisAlignedBB playerAABB = player.getEntityBoundingBox();
Vec3d lookVecBehind = Vec3d.fromPitchYaw(0f, player.rotationYaw).scale(-0.25f);
			
		        AxisAlignedBB wallCheck = new AxisAlignedBB(player.posX + lookVecBehind.x, playerAABB.minY,
						player.posZ + lookVecBehind.z, player.posX + lookVecBehind.x, playerAABB.minY,
						player.posZ + lookVecBehind.z).grow(ModConfig.otherMovement.wallJump.angle, 0.5, ModConfig.otherMovement.wallJump.angle);

The issue is that this is a perfect square, whereas I want to make it a rectangle with the longest side going away from the player as so:

Sprite-0001.png.4503f56fbf111fe119490a30680272be.png

I know this might take some complex maths, so thanks for your help if you know a solution!

Edited by squidlex
Link to comment
Share on other sites

Okay, so I'm trying to work out how to detect if there is a block in the shaded red area. Thanks to the massively helpful vemerion I'm now trying to raytrace this area, but I'm struggling getting it to work.

 

Does anyone have any tips/pointers? I'm not really sure how to set up World.rayTraceBlocks(Vec3D(), Vec3D) as whenever I put in the Player's location for one vector and the player's location + a value for the other it doesn't work.

 

Here's what I'm trying to achieve, where X and Y are both configurable lengths, this is really throwing my head so thanks so much for your help!

Sprite-0001.png.35016df5603255573fa570f94c89f154.png

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Announcements



×
×
  • Create New...

Important Information

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