Advertisement
Corosus

Untitled

May 4th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1. public MovingObjectPosition getAimBlock(int yOffset, boolean noYaw) {
  2.         EntityLiving entityliving = this;
  3.         float f = 1.0F;
  4.         float f1 = entityliving.prevRotationPitch + (entityliving.rotationPitch - entityliving.prevRotationPitch) * f;
  5.         float f3 = entityliving.prevRotationYaw + (entityliving.rotationYaw - entityliving.prevRotationYaw) * f;
  6.         if (noYaw) f3 = 0.00001F;
  7.         //int i = (int)Math.floor((double)(f3 / 90F) + 0.5D);
  8.         //f3 = (float)i * 90F;
  9.         double d = entityliving.prevPosX + (entityliving.posX - entityliving.prevPosX) * (double)f;
  10.         double d1 = ((entityliving.prevPosY + (entityliving.posY - entityliving.prevPosY) * (double)f + 1.6200000000000001D)) - (double)entityliving.yOffset + yOffset;
  11.         double d2 = entityliving.prevPosZ + (entityliving.posZ - entityliving.prevPosZ) * (double)f;
  12.         Vec3D vec3d = Vec3D.createVector(d, d1, d2);
  13.         float f4 = MathHelper.cos(-f3 * 0.01745329F - 3.141593F);
  14.         float f5 = MathHelper.sin(-f3 * 0.01745329F - 3.141593F);
  15.         float f6 = -MathHelper.cos(-f1 * 0.01745329F - 0.7853982F);
  16.         float f7 = MathHelper.sin(-f1 * 0.01745329F - 0.7853982F);
  17.         float f8 = f5 * f6;
  18.         float f9 = f7;
  19.         float f10 = f4 * f6;
  20.         //entityliving.info = f3;
  21.         double d3 = 2.0D;
  22.         Vec3D vec3d1 = vec3d.addVector((double)f8 * d3, (double)f9 * d3, (double)f10 * d3);              // \/ water collide check
  23.         MovingObjectPosition movingobjectposition = entityliving.worldObj.rayTraceBlocks_do(vec3d, vec3d1, true);
  24.  
  25.         int id = -1;
  26.        
  27.         if(movingobjectposition == null) {
  28.             return null;
  29.         }
  30.        
  31.         if(movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
  32.             //id = worldObj.getBlockId(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
  33.             //System.out.println(movingobjectposition.blockX + " - " + movingobjectposition.blockY + " - " + movingobjectposition.blockZ);
  34.         }
  35.        
  36.         return movingobjectposition;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement