本文整理汇总了Java中net.minecraft.util.math.Vec3d.distanceTo方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3d.distanceTo方法的具体用法?Java Vec3d.distanceTo怎么用?Java Vec3d.distanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.Vec3d
的用法示例。
在下文中一共展示了Vec3d.distanceTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateAttenuation
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private static float calculateAttenuation(double x, double y, double z)
{
if (SoundPhysics.mc.thePlayer != null)
{
Vec3d playerPos = SoundPhysics.mc.thePlayer.getPositionVector();
double soundDistance = playerPos.distanceTo(new Vec3d(x, y, z));
float atten = (float)Math.max(1.0 - soundDistance / 16.0, 0.0f);
//logDetailed("Sound attenuation: " + atten);
return atten;
}
else
{
//System.out.println("NULL PLAYER");
return 1.0f;
}
}
示例2: rayIntersectsRotationWheel
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
* Calculate the distance between the start of the ray and the rotation wheel.
* @param ray - Ray to test.
* @param p - Centre of rotation wheel.
* @param n - Normal to rotation wheel.
* @return - Distance or null if not intersection.
*/
public static Double rayIntersectsRotationWheel(RayTrace ray, Vec3d p, Vec3d n)
{
Vec3d pI = getRayPlaneIntersection(ray,p,n);
if(pI == null)
return null;
double d = pI.distanceTo(p);
if(d > rotationWheelRadius - rotationWheelWidth && d < rotationWheelRadius + rotationWheelWidth)
return ray.p0.distanceTo(pI);
return null;
}
示例3: findSuitablePositionNearPlayer
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static BlockPos findSuitablePositionNearPlayer(@Nonnull EntityMeeCreeps meeCreep, @Nonnull EntityPlayer player, double distance) {
Vec3d playerPos = player.getPositionVector();
Vec3d entityPos = meeCreep.getPositionVector();
if (entityPos.distanceTo(playerPos) < (distance * 1.2)) {
// No need to move
return meeCreep.getPosition();
}
double dx = playerPos.x - entityPos.x;
double dy = playerPos.x - entityPos.x;
double dz = playerPos.x - entityPos.x;
Vec3d v = new Vec3d(-dx, -dy, -dz);
v = v.normalize();
Vec3d pos = new Vec3d(playerPos.x + v.x * distance, playerPos.y + v.y * distance, playerPos.z + v.z * distance);
// First find a good spot at the specific location
World world = player.getEntityWorld();
float width = meeCreep.width;
float eyeHeight = meeCreep.getEyeHeight();
// First try on the prefered spot
BlockPos p = scanSuitablePos(new BlockPos(pos.x, pos.y + .5, pos.z), world, width, eyeHeight);
if (p != null) return p;
// No good spot to stand on found. Try other spots around the prefered spot
p = scanAround(pos, world, width, eyeHeight);
if (p != null) return p;
// No good spot to stand on found. Try other spots around the player
p = scanAround(playerPos, world, width, eyeHeight);
if (p != null) return p;
// If all else fails we go stand where the player is
return player.getPosition();
}
示例4: getBestPitch
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
* Finds the pitch degree that yields the furthest distance
*/
public static double getBestPitch(ItemStack itemStack, Vec3d hitPos) {
EntityPlayer localPlayer = MC.player;
Vec3d initPos = EntityUtils.getEyePos(localPlayer);
Angle angle = new Angle();
angle.setYaw(LocalPlayerUtils.getViewAngles().getYaw());
double minAngle = localPlayer.rotationPitch;
double maxAngle = minAngle - 45.D;
double bestOffset = -1;
double bestDistance = -1;
for(int i = 0; i < BESTPOS_ITERATIONS; i++) {
double offset = Utils.scale(0.5D, 0, 1, minAngle, maxAngle);
angle.setPitch(offset);
Vec3d pos = getImpactPos(itemStack, initPos, hitPos, angle);
double distance = pos.distanceTo(hitPos);
if(bestDistance == -1 || distance < bestDistance) {
bestDistance = distance;
bestOffset = offset;
}
if((pos.y - hitPos.y) < 0)
minAngle = offset;
else
maxAngle = offset;
}
return bestOffset;
}
示例5: checkForStuck
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
* Checks if entity haven't been moved when last checked and if so, clears current {@link
* net.minecraft.pathfinding.PathEntity}
*/
protected void checkForStuck(Vec3d positionVec3)
{
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
this.clearPathEntity();
}
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck = positionVec3;
}
if (this.currentPath != null && !this.currentPath.isFinished())
{
Vec3d vec3d = this.currentPath.getCurrentPos();
if (vec3d.equals(this.timeoutCachedNode))
{
this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck;
}
else
{
this.timeoutCachedNode = vec3d;
double d0 = positionVec3.distanceTo(this.timeoutCachedNode);
this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double)this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D;
}
if (this.timeoutLimit > 0.0D && (double)this.timeoutTimer > this.timeoutLimit * 3.0D)
{
this.timeoutCachedNode = Vec3d.ZERO;
this.timeoutTimer = 0L;
this.timeoutLimit = 0.0D;
this.clearPathEntity();
}
this.lastTimeoutCheck = System.currentTimeMillis();
}
}
示例6: actualRayTrace
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static Entity actualRayTrace(Entity entity, double dist)
{
Vec3d vec3d = entity.getPositionEyes(1.0F);
Vec3d vec3d1 = entity.getLook(1.0F);
Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * dist, vec3d1.yCoord * dist, vec3d1.zCoord * dist);
Entity pointedEntity = null;
List<Entity> list = entity.worldObj.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec3d1.xCoord * dist, vec3d1.yCoord * dist, vec3d1.zCoord * dist).expand(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>()
{
public boolean apply(@Nullable Entity p_apply_1_)
{
return p_apply_1_ != null && p_apply_1_.canBeCollidedWith();
}
}));
for (int j = 0; j < list.size(); ++j)
{
Entity entity1 = (Entity)list.get(j);
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz((double)entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.isVecInside(vec3d))
{
if (dist >= 0.0D)
{
pointedEntity = entity1;
dist = 0.0D;
}
}
else if (raytraceresult != null)
{
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < dist || dist == 0.0D)
{
if (entity1.getLowestRidingEntity() == entity.getLowestRidingEntity() && !entity.canRiderInteract())
{
if (dist == 0.0D)
{
pointedEntity = entity1;
}
}
else
{
pointedEntity = entity1;
dist = d3;
}
}
}
}
return pointedEntity;
}
示例7: isInRange
import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
* Check if entity is in attack range
*/
public boolean isInRange(Vec3d fromPos, Vec3d toPos) {
double dist = isProjectileAimbotActivated() ? projectile_range.get() : range.get();
return dist <= 0 || fromPos.distanceTo(toPos) <= dist;
}