Posted January 25, 20178 yr How can i get entities in a cone in front of steve? 3 block length. I tried this from a tutorial: public static List<RayTraceResult> getMouseOverExtendedList(float dist) { Minecraft mc = FMLClientHandler.instance().getClient(); Entity theRenderViewEntity = mc.getRenderViewEntity(); AxisAlignedBB theViewBoundingBox = new AxisAlignedBB( theRenderViewEntity.posX - 2.0D, theRenderViewEntity.posY - 0.0D, theRenderViewEntity.posZ - 0.0D, theRenderViewEntity.posX + 2.0D, theRenderViewEntity.posY + 1.5D, theRenderViewEntity.posZ + 2.0D); RayTraceResult returnMOP = null; List<RayTraceResult> returnMOPList = new ArrayList<>(); if (mc.world != null) { double distancia = dist; returnMOP = theRenderViewEntity.rayTrace(distancia, 0); double calcdist = distancia; Vec3d vectorPosicionOjos = theRenderViewEntity.getPositionEyes(0); distancia = calcdist; if (returnMOP != null) { calcdist = returnMOP.hitVec.distanceTo(vectorPosicionOjos); } Vec3d lookvec = theRenderViewEntity.getLook(0); Vec3d lookVectorPlusDistancia = vectorPosicionOjos.addVector(lookvec.xCoord * distancia, lookvec.yCoord * distancia, lookvec.zCoord * distancia); float var9 = 1.0F; @SuppressWarnings("unchecked") List<Entity> list = mc.world.getEntitiesWithinAABBExcludingEntity(theRenderViewEntity, theViewBoundingBox.addCoord(lookvec.xCoord * distancia, lookvec.yCoord * distancia, lookvec.zCoord * distancia) .expand(var9, var9, var9)); double d = calcdist; for (Entity entity : list) { if (entity.canBeCollidedWith()) { returnMOPList.add(new RayTraceResult(entity)); } } } return returnMOPList; } But it didn't worked as i expected. Any help would be much apreciated.
January 25, 20178 yr That method, will only work client-side, as you are using client-side only classes ( Minecraft::getRenderViewEntity etc) What you can do, is; get a list of all entities around the player, using World#getEntitiesWithinAABB Create the "cone" or rather, triangle, by assigning 2 points away from the player, at equal distance from the player#getLookVec Go over each entity in the list we got earlier, and calculate whether their position is inside the triangle, using Barycentric Coordinates Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
January 29, 20178 yr Author Solved. I used acquireAllLookTargets method from here: https://github.com/coolAlias/ZeldaSwordSkills/blob/1.8/src/main/java/zeldaswordskills/util/TargetUtils.java And adjusted it to 1.11
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.