Jump to content

Recommended Posts

Posted

In a TickHander i was checking for entities around the player.

List<Entity> entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox.expand(19.8D, 19.8D, 19.8D));

 

My problem is i want to get only a specific entity out that list.

If its there that do something.

I tryed:

entities.contains(EntityGrunt.class)

entities == new EntityGrunt(mc.theWorld)

entities instanceof EntityGrunt

Nothing worked.

 

The code is working i can print out the list and its shows that there is EntityGrunt in the range.

Thanks!

Posted
List<Entity> entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox.expand(19.8D, 19.8D, 19.8D));
EntityLivingBase entity;
while(entities.iterator.hasNext()){
    entity = (EntityLivingBase)entities.iterator.next();
    if(entity instanceof EntityGrunt){
        //sample
    }
}

Posted

Thank you but it causes hanging to my game.

The game is still running i can see it on the console, but the screen is freezed.

I discovered that the "while" causes it. 

Posted

I wouldn't check for entities on the client world though.

 

Entity entity;
World world = //find some way to initialize the world in your tickhandler without using Minecraft.getMinecraft().theWorld;
if(!world.isRemote) {
List list = world.getEntitiesWithinAABB(EntityItem.class, this._golem.boundingBox.expand(20.0D, 4.0D, 20.0D));
EntityItem entityitem = null;
Iterator iterator = list.iterator();

while (iterator.hasNext()) {
	EntityItem entityitem1 = (EntityItem)iterator.next();
    	entity = entityitem1;
    	break;
}
}

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.