Jump to content

How can my entity search for a certain type of block (an easy way)


Recommended Posts

Posted

Hi everyone! I'm studying EntityAnimal now. I'd like to know if it's possible to make it look for a certain type of block.

 

I can make it find another Entity or subclass of entity using an algotithm kind of inspired by the one in EntityAINearestAttackableTarget.shouldExecute(), but I don't know how to use Bounding Boxes to detect the presence of blocks (yeah, still shooting in the dark when it comes to bounding boxes. Why doesn't anyone answer my questions about that? :'(). I use the same World.selectEntitiesWithinAABB used by shouldExecute method mentioned earlier.

 

Is there way to make an EntityAnimal find a block? (one that doesn't involve nested for loops to look at every block in an area around the animal, cause I think that would have a sensible performance impact)

 

Thanks in advance!!

 

P.S.: I didn't post my code for finding entities because it's not relevant, would be distracting and it doesn't do what I want, that is, to find a specific block. But if anyone is interested I can post it, as an off-topic answer.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

You could do a three dimensional loop worth of getBlockID(x,y,z).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You could do a three dimensional loop worth of getBlockID(x,y,z).

 

That was my initial ideia but I think that can be a performance breaker. The number of objects of MyEntityAnimal can be any arbitrarily big number (as many as the player spawns through eggs or breeding) and I think things would break pretty soon. Unless there's a way to make nearby MyEntityAnimal mobs act as one (they do just one search and share the location of the special blocks found among each other).

 

Do you think that's possible?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

No idea. :\

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.