Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void fleeFrom(Entity fleeFrom) {
- //ent field rerouting!
- EntityLiving ent = c_AIP.i.player;
- /*this.faceEntity(fleeFrom, 180F, 180F);
- //this.rotationYaw += 180;
- double d1 = posX - fleeFrom.posX;
- double d2 = posZ - fleeFrom.posZ;
- float f2 = (float)((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
- float f3 = f2 - rotationYaw;
- rotationYaw = updateRotation2(rotationYaw, f3, 360F);*/
- double d = fleeFrom.posX - ent.posX;
- double d1;
- for (d1 = fleeFrom.posZ - ent.posZ; d * d + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D)
- {
- d = (Math.random() - Math.random()) * 0.01D;
- }
- float f = MathHelper.sqrt_double(d * d + d1 * d1);
- //knockBack(entity, i, d, d1);
- float yaw = (float)((Math.atan2(d1, d) * 180D) / 3.1415927410125732D)/* - ent.rotationYaw*/;
- float look = ent.worldObj.rand.nextInt(15)-7;
- //int height = 10;
- double dist = ent.worldObj.rand.nextInt(2)+4;
- //dist adjuster
- if (fleeFrom instanceof EntityCreeper) {
- dist = ent.worldObj.rand.nextInt(8)+8;
- }
- int gatherX = (int)(ent.posX + ((double)(-Math.sin((yaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist));
- int gatherY = (int)(ent.posY-0.5 + (double)(-MathHelper.sin(ent.rotationPitch / 180.0F * 3.1415927F) * dist) - 0D); //center.posY - 0D;
- int gatherZ = (int)(ent.posZ + ((double)(Math.cos((yaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist));
- gatherX = (int)(ent.posX - (d / f * dist));
- gatherZ = (int)(ent.posZ - (d1 / f * dist));
- int id = ent.worldObj.getBlockId(gatherX, gatherY, gatherZ);
- int id2 = ent.worldObj.getBlockId(gatherX, gatherY+1, gatherZ);
- int offset = 0;
- int finalY = gatherY;
- while (offset < 10) {
- if (id != 0 && id2 == 0) {
- finalY += offset;
- break;
- }
- //id = ent.worldObj.getBlockId(gatherX, gatherY+offset++, gatherZ);
- id = ent.worldObj.getBlockId(gatherX, gatherY-offset, gatherZ);
- id2 = ent.worldObj.getBlockId(gatherX, gatherY-offset+1, gatherZ);
- if (id != 0 && id2 == 0) {
- finalY -= offset;
- break;
- }
- //id = ent.worldObj.getBlockId(gatherX, gatherY+offset++, gatherZ);
- id = ent.worldObj.getBlockId(gatherX, gatherY+offset, gatherZ);
- id2 = ent.worldObj.getBlockId(gatherX, gatherY+offset+1, gatherZ);
- offset++;
- }
- if (offset < 10) {
- System.out.println("flee");
- //if (c_AIP.i.pathToEntity == null) {
- c_AIP.i.walkTo(ent, gatherX, finalY, gatherZ, maxPFRange , 600, -1);
- //}
- //this.walkTo(this, homeX, homeY, homeZ, maxPFRange, 600);
- } else {
- //System.out.println("flee failed");
- //c_AIP.i.walkTo(ent, c_AIP.i.homeX, c_AIP.i.homeY, c_AIP.i.homeZ, maxPFRange, 600, -1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement