Jump to content

[1.8]getallTheEntityes close to this particular block. how get this done.<fixed>


perromercenary00

Recommended Posts

 

goo days

 

what I want is to get all entities within a distance of 5 blocks of this particular block in a list and then causes damage to each according to distance from the block

in the code I found this command

worldIn.getEntitiesWithinAABB (clazz, AABB, filter), who says to return a list,  I alredy have an idea that is AABB but not know how to load and use this object in minecraft as for others have no idea of  whath are the required values and this clazz and filter

 

i been doing an explosive box it explodes and all but behaves like box means more destrucction than damage over the closes entites i wanna this barrel behaves diferent causing more damage to creatures than destruction over the world.

 

i need guide to use getEntitiesWithinAAB or maiby a diferent method to achive the list thing.

 

very gratefull.

Link to comment
Share on other sites

Well, the parameters are:

-

clazz

: the entity class you want to check for, for example

EntityPlayer

will get all the

EntityPlayers

in the radius.

-

aabb

: an AxisAlignedBB which specified the box it will search for entities in. You get one using

AxisAlignedBB.getBoundingBox()

.

-

filter

: an IEntitySelector to specifiy which entities are applicable to put in the List. You can either make a new one, or use one of the existing ones.

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

well i do this

 

public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
chat.chatdp(playerIn, "activado");
ArrayList<EntityLivingBase> lisanimales = new ArrayList<EntityLivingBase>();
List lista=null; 

int f=5;
int x=pos.getX(),y=pos.getY(),z=pos.getZ();

BlockPos posMin = new BlockPos(x-5,y-1,z-5);
BlockPos posMax = new BlockPos(x+5,y+1,z+5);

AxisAlignedBB boundingBox=new AxisAlignedBB(pos, pos);
lista = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox);

int llist=lista.size();

for(int l=0 ;l<llist;l++){

chat.chatda(playerIn, ""+lista.get(l).toString());	
	;}


    return false;
}

it must return on player screen a list of all the entity living aroun the block. but no works also no errors it execute i get message "activado" but no list is display

Link to comment
Share on other sites

1. You should are calling new AxisAlignedBB() with the same position twice, this will find all the entities in one place. From the looks of your code you should probably be creating the AxisAlignedBB with posMin and posMax, not pos and pos.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

see i alredy see the little mistake

 

now is working like it must but tired i gonna end this code otherday

thnaks

 

 

public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
chat.chatdp(playerIn, "activado");
ArrayList<EntityLivingBase> lisanimales = new ArrayList<EntityLivingBase>();
List lista=null; 

int f=2;
int x=pos.getX(),y=pos.getY(),z=pos.getZ();

BlockPos posMin = new BlockPos(x-f,y-1,z-f);
BlockPos posMax = new BlockPos(x+f,y+1,z+f);

AxisAlignedBB boundingBox=new AxisAlignedBB(posMin, posMax);
lista = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox);

int llist=lista.size();

for(int l=0 ;l<llist;l++){
	EntityLivingBase mob=	(EntityLivingBase) lista.get(l);
chat.chatda(playerIn, ""+mob.getName()+" hp="+mob.getHealth() );

mob.setHealth(mob.getHealth()-20);
	;}

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.