Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- code snippets Cloud :
- public void onMouse(final MouseEvent a) {
- if (a.buttonstate && a.button == 0 && (mc.objectMouseOver == null || mc.objectMouseOver.entityHit == null) && findEnt(R) != null) {
- mc.playerController.attackEntity((EntityPlayer)mc.thePlayer, findEnt(R));
- }
- }
- public static Entity findEnt(final double a) {
- final Minecraft minecraft;
- final Minecraft getMinecraft = minecraft = Minecraft.getMinecraft();
- final MovingObjectPosition rayTrace = getMinecraft.thePlayer.rayTrace(a, 1.0f);
- double distanceTo = a;
- final Vec3 getPosition = getMinecraft.thePlayer.getPosition(1.0f);
- if (rayTrace != null) {
- distanceTo = rayTrace.hitVec.distanceTo(getPosition);
- }
- final Minecraft minecraft2 = minecraft;
- final Vec3 getLook = minecraft2.thePlayer.getLook(1.0f);
- final Vec3 addVector = getPosition.addVector(getLook.xCoord * a, getLook.yCoord * a, getLook.zCoord * a);
- Entity entity = null;
- final float n = 1.0f;
- final WorldClient theWorld = minecraft2.theWorld;
- final Minecraft minecraft3 = minecraft;
- final List getEntitiesWithinAABBExcludingEntity = theWorld.getEntitiesWithinAABBExcludingEntity((Entity)minecraft3.thePlayer, minecraft3.thePlayer.boundingBox.addCoord(getLook.xCoord * a, getLook.yCoord * a, getLook.zCoord * a).expand(1.0, 1.0, 1.0));
- double n2 = distanceTo;
- int i;
- for (int n3 = i = 0; i < getEntitiesWithinAABBExcludingEntity.size(); i = ++n3) {
- final Entity entity2;
- if ((entity2 = (Entity) getEntitiesWithinAABBExcludingEntity.get(n3)).canBeCollidedWith()) {
- final Entity entity3 = entity2;
- final float getCollisionBorderSize = entity3.getCollisionBorderSize();
- final AxisAlignedBB expand = entity3.boundingBox.expand((double)getCollisionBorderSize, (double)getCollisionBorderSize, (double)getCollisionBorderSize);
- final MovingObjectPosition calculateIntercept = expand.calculateIntercept(getPosition, addVector);
- if (expand.isVecInside(getPosition)) {
- if (0.0 < n2 || n2 == 0.0) {
- entity = entity2;
- n2 = 0.0;
- }
- }
- else {
- final double distanceTo2;
- if (calculateIntercept != null && ((distanceTo2 = getPosition.distanceTo(calculateIntercept.hitVec)) < n2 || n2 == 0.0)) {
- if (entity2 == minecraft.thePlayer.ridingEntity) {
- if (n2 == 0.0) {
- entity = entity2;
- }
- }else {
- entity = entity2;
- n2 = distanceTo2;
- }
- }
- }
- }
- }
- return entity;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement