}
return true;
}
public boolean doBlink(ItemStack equipped, EntityPlayer player) {
Vector3d eye = Util.getEyePositionEio(player);
Vector3d look = Util.getLookVecEio(player);
Vector3d sample = new Vector3d(look);
sample.scale(Config.travelStaffMaxBlinkDistance);
sample.add(eye);
Vec3 eye3 = Vec3.createVectorHelper(eye.x, eye.y, eye.z);
Vec3 end = Vec3.createVectorHelper(sample.x, sample.y, sample.z);
double playerHeight = player.yOffset;
//if you looking at you feet, and your player height to the max distance, or part there of
double lookComp = -look.y * playerHeight;
double maxDistance = Config.travelStaffMaxBlinkDistance + lookComp;
MovingObjectPosition p = player.worldObj.rayTraceBlocks(eye3, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
if(p == null) {
//go as far as possible
for (double i = maxDistance; i > 1; i--) {
sample.set(look);
sample.scale(i);
sample.add(eye);
//we test against our feets location
sample.y -= playerHeight;
if(doBlinkAround(player, sample, true)) {
return true;
}
}
return false;
} else {
List<MovingObjectPosition> res = Util.raytraceAll(player.worldObj, eye3, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
for (MovingObjectPosition pos : res) {
if(pos != null) {
Block hitBlock = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(isBlackListedBlock(player, pos, hitBlock)) {
maxDistance = Math.min(maxDistance, VecmathUtil.distance(eye, new Vector3d(pos.blockX + 0.5, pos.blockY + 0.5, pos.blockZ + 0.5)) - 1.5 - lookComp);
}
}
}
eye3 = Vec3.createVectorHelper(eye.x, eye.y, eye.z);
Vector3d targetBc = new Vector3d(p.blockX, p.blockY, p.blockZ);
double sampleDistance = 1.5;
double teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5)) + sampleDistance;
while (teleDistance < maxDistance) {
sample.set(look);
sample.scale(sampleDistance);
sample.add(targetBc);
//we test against our feets location
sample.y -= playerHeight;
if(doBlinkAround(player, sample, false)) {
return true;
}
teleDistance++;
sampleDistance++;
}
sampleDistance = -0.5;
teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5)) + sampleDistance;
while (teleDistance > 1) {
sample.set(look);
sample.scale(sampleDistance);
sample.add(targetBc);
//we test against our feets location