Jump to content

Recommended Posts

Posted

Hello,

I am trying to use the method rayTraceBlocks to see if my block can see the bottom of the world, however after approximately 11 Blocks of height (I say approximately as the distance has changed from time to time) the detected collision shifts 1 Block to the center of the world. If my block were for example at the position x: 4 y: 77 z: 0 the collision would be detected at x: 3 y: 55 z: 0 shifting 1 Block in the direction of the world center.

This is the Code of my raycast (-100 is just a test value):

Spoiler

@Override
	public void update() {
		if(!world.isRemote) {
		RayTraceResult result = world.rayTraceBlocks(new Vec3d(pos.getX()+0.5, pos.getY()-1, pos.getZ()+0.5), new Vec3d(0, -100, 0), true, true, true);
		if(result!=null) {
		BlockPos bpos = result.getBlockPos();
		System.out.println("Blockpos: "+bpos.getX()+" "+bpos.getY()+" "+bpos.getZ()+" from: "+pos.getX()+" "+pos.getY()+" "+pos.getZ());
		}
		}
	}

 

 

Thank you for your help!

Posted (edited)
40 minutes ago, GloriousAlpaca said:

I am trying to use the method rayTraceBlocks to see if my block can see the bottom of the world

Why not just use a loop going down towards zero or a mutable Block pos?

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

I have used that for another block, I just wanted to try using raycasts once, however maybe it isn't the right application.
How performance heavy are raycasts compared to just checking the blocks one by one ?

Posted

Extremely, just compare the code in the method that you’re calling to a simple  loop

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.