Posted May 31, 201411 yr 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!
May 31, 201411 yr 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 } }
May 31, 201411 yr Author 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.
May 31, 201411 yr 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; } }
June 1, 201411 yr Author Thank you guys! The problem seems to be i can't use EntityLivingBase and i missed the break; line.
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.