int j = MathHelper.floor_double(endVec.yCoord);
int k = MathHelper.floor_double(endVec.zCoord);
int l = MathHelper.floor_double(startVec.xCoord);
int i1 = MathHelper.floor_double(startVec.yCoord);
int j1 = MathHelper.floor_double(startVec.zCoord);
Block block = world.getBlock(l, i1, j1);
int k1 = world.getBlockMetadata(l, i1, j1);
if((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) && block.canCollideCheck(k1, includeLiquids)) {
MovingObjectPosition movingobjectposition = block.collisionRayTrace(world, l, i1, j1, startVec, endVec);
if(movingobjectposition != null) {
result.add(movingobjectposition);
}
}
MovingObjectPosition movingobjectposition2 = null;
k1 = 200;
while (k1-- >= 0) {
if(Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord)) {
return null;
}
if(l == i && i1 == j && j1 == k) {
if(p_147447_5_) {
result.add(movingobjectposition2);
} else {
return result;
}
}
boolean flag6 = true;
boolean flag3 = true;
boolean flag4 = true;
double d0 = 999.0D;
double d1 = 999.0D;
double d2 = 999.0D;
if(i > l) {
d0 = (double) l + 1.0D;
} else if(i < l) {
d0 = (double) l + 0.0D;
} else {
flag6 = false;
}
if(j > i1) {
d1 = (double) i1 + 1.0D;
} else if(j < i1) {
d1 = (double) i1 + 0.0D;
} else {
flag3 = false;
}
if(k > j1) {
d2 = (double) j1 + 1.0D;
} else if(k < j1) {
d2 = (double) j1 + 0.0D;
} else {
flag4 = false;
}
double d3 = 999.0D;
double d4 = 999.0D;
double d5 = 999.0D;
double d6 = endVec.xCoord - startVec.xCoord;
double d7 = endVec.yCoord - startVec.yCoord;
double d8 = endVec.zCoord - startVec.zCoord;
if(flag6) {
d3 = (d0 - startVec.xCoord) / d6;
}
if(flag3) {
d4 = (d1 - startVec.yCoord) / d7;
}
if(flag4) {
d5 = (d2 - startVec.zCoord) / d8;
}
boolean flag5 = false;
byte b0;
if(d3 < d4 && d3 < d5) {
if(i > l) {
b0 = 4;
} else {
b0 = 5;
}
startVec.xCoord = d0;
startVec.yCoord += d7 * d3;
startVec.zCoord += d8 * d3;
} else if(d4 < d5) {
if(j > i1) {
b0 = 0;
} else {
b0 = 1;
}
startVec.xCoord += d6 * d4;
startVec.yCoord = d1;
startVec.zCoord += d8 * d4;
} else {
if(k > j1) {
b0 = 2;
} else {
b0 = 3;
}
startVec.xCoord += d6 * d5;
startVec.yCoord += d7 * d5;
startVec.zCoord = d2;
}
Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord);
l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord));
if(b0 == 5) {
--l;
++vec32.xCoord;
}
i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord));
if(b0 == 1) {
--i1;
++vec32.yCoord;
}
j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord));
if(b0 == 3) {
--j1;
++vec32.zCoord;
}
Block block1 = world.getBlock(l, i1, j1);
int l1 = world.getBlockMetadata(l, i1, j1);
if(!p_147447_4_ || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) {
if(block1.canCollideCheck(l1, includeLiquids)) {
MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, startVec, endVec);
if(movingobjectposition1 != null) {
result.add(movingobjectposition1);
}
} else {
movingobjectposition2 = new MovingObjectPosition(l, i1, j1, b0, startVec, false);