Jump to content

Recommended Posts

Posted

Well, entities have both planned and unplanned movement. For planned movement, which is usually figured out in the entity AI, it uses a "navigator" to find a path through the blocks. The navigators basically finds a series of positions that the entity can move between where its collision box doesn't collide. Then there is unplanned movement like if you knock it back. I haven't looked at that code specifically, but typically in games it will (a) look for collision before moving the entity into a location (b) reset position to the previous one if it finds itself in a collision. All the collision boxes (block and entity) in Minecraft are rectangular, restricted in size and cannot rotate so it is really simple math to detect a collision.

 

Why are you asking? 

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
2 minutes ago, jabelar said:

Why are you asking? 

I am trying to make a BlockPos custom method for a flying algorithim to my tameable dragon to detect it's altitude. I currently use world#getHeight but that causes issues because gethHeight finds the most uppermost solid block in the world, but the nether has a solid block roof above. I need a custom method which detects a solid block below and to do that I must understand how solid blocks interact with entities 

Posted
18 hours ago, gummby8 said:

So you want to find how high your entity is from the nearest solid block directly below the entity?

 


				BlockPos blockPos = new BlockPos(this.posX, this.posY, this.posZ);
				while (!worldObj.getBlockState(blockPos).getBlock().getMaterial().blocksMovement()) {
					blockPos = blockPos.down();
				}

 

That will find the nearest solid block straight down. Then you can calculate the distance

Ok it worked, now I need to detect if it is liquid, lava is Liquid right?

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.