Jump to content

Despawning mobs within a radius


Thornack

Recommended Posts

I have been trying for weeks to add functionality to my mob spawner which would run a check on a specific in game tick for all objects (mobs) within a specific radius and then if this check finds that the mobs exist it despawns them. I have been very unsuccessful. Currently I have a tile entity which I created called mobspawner and it has a working timer which is synced with the minecraft in game ticks. This mob spawner has the functionality to spawn mobs at a specific game time and does so forever. This is a problem since it eventually crashes the game due to too many entities being present. does anyone know of a way to implement such functionality? Any help is very much appreciated.

Link to comment
Share on other sites

I have found the following

 

AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)xCoord, (double)yCoord, (double)zCoord, (double)(xCoord + 1), (double)(yCoord + 1), (double)(zCoord + 1)).expand(1, 1, 1);

            List list = worldObj.getEntitiesWithinAABB(Entity.class, axisalignedbb);

            Iterator iterator = list.iterator();

            Entity ent;

            while (iterator.hasNext()){

                ent = (Entity) iterator.next();

                if(!(ent instanceof EntityLivingBase)){

                (EntityLivingBase) ent).setDead();

                }

            }

 

but cant seem to get it to work any ideas?

Link to comment
Share on other sites

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.