perromercenary00 Posted January 11, 2015 Posted January 11, 2015 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. Quote
larsgerrits Posted January 11, 2015 Posted January 11, 2015 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. Quote 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/
perromercenary00 Posted January 11, 2015 Author Posted January 11, 2015 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 Quote
shadowfacts Posted January 11, 2015 Posted January 11, 2015 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. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
perromercenary00 Posted January 12, 2015 Author Posted January 12, 2015 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); ;} Quote
Recommended Posts
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.