当前位置: 首页>>代码示例>>Java>>正文


Java Vec3d.squareDistanceTo方法代码示例

本文整理汇总了Java中net.minecraft.util.math.Vec3d.squareDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3d.squareDistanceTo方法的具体用法?Java Vec3d.squareDistanceTo怎么用?Java Vec3d.squareDistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.math.Vec3d的用法示例。


在下文中一共展示了Vec3d.squareDistanceTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: breakBlockPacketSpam

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static void breakBlockPacketSpam(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		
		// check if side is facing towards player
		if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
			continue;
		
		// break block
		WConnection.sendPacket(new CPacketPlayerDigging(
			Action.START_DESTROY_BLOCK, pos, side));
		WConnection.sendPacket(
			new CPacketPlayerDigging(Action.STOP_DESTROY_BLOCK, pos, side));
		
		return;
	}
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:25,代码来源:BlockUtils.java

示例2: generateBranch

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private void generateBranch(World world, Random rand, BlockPos trunkPos, Vec3d endPos) {
    Vec3d curr = new Vec3d(trunkPos);
    Vec3d next = next(world, curr, endPos.subtract(curr).normalize(), endPos, trunkPos);
    BlockPos prev;
    do {
        BlockPos currBlock = new BlockPos(curr);
        Vec3d dir = endPos.subtract(curr).normalize();
        prev = currBlock;
        curr = next;
        next = next(world, curr, dir, endPos, trunkPos);

        IBlockState state = (xzEqual(currBlock, trunkPos) ? LOG : LOG.withProperty(BlockLog.LOG_AXIS, getLogAxis(world, currBlock, dir)));
        setBlockInWorld(world, currBlock, state);

        // check to avoid long straight up branches
        BlockPos nextBlock = new BlockPos(next);
        if (endPos.squareDistanceTo(next) > Math.sqrt(3) && xzEqual(prev, currBlock) && xzEqual(currBlock, nextBlock)) {
            next = next.addVector(rand.nextBoolean() ? -1 : 1, 0, rand.nextBoolean() ? -1 : 1);
        }
    } while (endPos.squareDistanceTo(curr) > Math.sqrt(3));

    generateLeaves(world, rand, curr);
    generateLeaves(world, rand, new Vec3d(prev));
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:25,代码来源:WorldGenTreeDryophyllum.java

示例3: pathFollow

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Override
@SuppressWarnings("ConstantConditions")
protected void pathFollow() {
	Vec3d vec3d = this.getEntityPosition();
	float f = this.entity.width * this.entity.width;

	if(vec3d.squareDistanceTo(this.currentPath.getVectorFromIndex(this.entity, this.currentPath.getCurrentPathIndex())) < (double) f) {
		this.currentPath.incrementPathIndex();
	}

	for(int j = Math.min(this.currentPath.getCurrentPathIndex() + 6, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j) {
		Vec3d vec3d1 = this.currentPath.getVectorFromIndex(this.entity, j);

		if(vec3d1.squareDistanceTo(vec3d) <= 36.0D && this.isDirectPathBetweenPoints(vec3d, vec3d1, 0, 0, 0)) {
			this.currentPath.setCurrentPathIndex(j);
			break;
		}
	}

	this.checkForStuck(vec3d);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:22,代码来源:FlightPathNavigate.java

示例4: pathFollow

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
protected void pathFollow()
{
    Vec3d vec3d = this.getEntityPosition();
    float f = this.theEntity.width * this.theEntity.width;
    int i = 6;

    if (vec3d.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex())) < (double)f)
    {
        this.currentPath.incrementPathIndex();
    }

    for (int j = Math.min(this.currentPath.getCurrentPathIndex() + 6, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j)
    {
        Vec3d vec3d1 = this.currentPath.getVectorFromIndex(this.theEntity, j);

        if (vec3d1.squareDistanceTo(vec3d) <= 36.0D && this.isDirectPathBetweenPoints(vec3d, vec3d1, 0, 0, 0))
        {
            this.currentPath.setCurrentPathIndex(j);
            break;
        }
    }

    this.checkForStuck(vec3d);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:PathNavigateSwimmer.java

示例5: getSquareDist

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private static double getSquareDist(Entity source, Entity dest) {
    Vec3d lowPosition = new Vec3d(source.posX, source.posY - 1, source.posZ);
    Vec3d position = new Vec3d(source.posX, source.posY, source.posZ);
    Vec3d eyePosition = new Vec3d(source.posX, source.posY + source.getEyeHeight(), source.posZ);
    double d0 = lowPosition.squareDistanceTo(dest.posX, dest.posY, dest.posZ);
    double d1 = position.squareDistanceTo(dest.posX, dest.posY, dest.posZ);
    double d2 = eyePosition.squareDistanceTo(dest.posX, dest.posY, dest.posZ);
    return Math.min(Math.min(d0, d1), d2);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:10,代码来源:WorkerHelper.java

示例6: getDistanceApartSq

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public double getDistanceApartSq() {
    Vec3d start = getShootPos();
    Vec3d hit = getHitPos();
    if(start != null && hit != null) {
        return start.squareDistanceTo(hit);
    } else return 0.D;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:8,代码来源:SimulationResult.java

示例7: placeBlockScaffold

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static boolean placeBlockScaffold(BlockPos pos)
{
	Vec3d eyesPos = new Vec3d(WMinecraft.getPlayer().posX,
		WMinecraft.getPlayer().posY + WMinecraft.getPlayer().getEyeHeight(),
		WMinecraft.getPlayer().posZ);
	
	for(EnumFacing side : EnumFacing.values())
	{
		BlockPos neighbor = pos.offset(side);
		EnumFacing side2 = side.getOpposite();
		
		// check if side is visible (facing away from player)
		if(eyesPos.squareDistanceTo(
			new Vec3d(pos).addVector(0.5, 0.5, 0.5)) >= eyesPos
				.squareDistanceTo(
					new Vec3d(neighbor).addVector(0.5, 0.5, 0.5)))
			continue;
		
		// check if neighbor can be right clicked
		if(!WBlock.canBeClicked(neighbor))
			continue;
		
		Vec3d hitVec = new Vec3d(neighbor).addVector(0.5, 0.5, 0.5)
			.add(new Vec3d(side2.getDirectionVec()).scale(0.5));
		
		// check if hitVec is within range (4.25 blocks)
		if(eyesPos.squareDistanceTo(hitVec) > 18.0625)
			continue;
		
		// place block
		RotationUtils.faceVectorPacketInstant(hitVec);
		WPlayerController.processRightClickBlock(neighbor, side2, hitVec);
		WPlayer.swingArmClient();
		mc.rightClickDelayTimer = 4;
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:41,代码来源:BlockUtils.java

示例8: 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();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:44,代码来源:PathNavigate.java

示例9: prepareToBreakBlockLegit

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static boolean prepareToBreakBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec);
		
		// check if hitVec is within range (4.25 blocks)
		if(distanceSqHitVec > 18.0625)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// check line of sight
		if(WMinecraft.getWorld().rayTraceBlocks(eyesPos, hitVec, false,
			true, false) != null)
			continue;
		
		// AutoTool
		WurstClient.INSTANCE.mods.autoToolMod.setSlot(pos);
		
		// face block
		if(!RotationUtils.faceVectorPacket(hitVec))
			return true;
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:38,代码来源:BlockUtils.java

示例10: breakBlockLegit

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static boolean breakBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec);
		
		// check if hitVec is within range (4.25 blocks)
		if(distanceSqHitVec > 18.0625)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// check line of sight
		if(WMinecraft.getWorld().rayTraceBlocks(eyesPos, hitVec, false,
			true, false) != null)
			continue;
		
		// damage block
		if(!mc.playerController.onPlayerDamageBlock(pos, side))
			return false;
		
		// swing arm
		WPlayer.swingArmPacket();
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:38,代码来源:BlockUtils.java

示例11: breakBlockSimple

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static boolean breakBlockSimple(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec);
		
		// check if hitVec is within range (6 blocks)
		if(distanceSqHitVec > 36)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// AutoTool
		WurstClient.INSTANCE.mods.autoToolMod.setSlot(pos);
		
		// face block
		RotationUtils.faceVectorPacket(hitVec);
		
		// damage block
		if(!mc.playerController.onPlayerDamageBlock(pos, side))
			return false;
		
		// swing arm
		WPlayer.swingArmPacket();
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:39,代码来源:BlockUtils.java

示例12: breakBlocksPacketSpam

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static void breakBlocksPacketSpam(Iterable<BlockPos> blocks)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	
	for(BlockPos pos : blocks)
	{
		Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
		double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
		
		for(EnumFacing side : EnumFacing.values())
		{
			Vec3d hitVec =
				posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
			
			// check if side is facing towards player
			if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec)
				continue;
			
			// break block
			WConnection.sendPacket(new CPacketPlayerDigging(
				Action.START_DESTROY_BLOCK, pos, side));
			WConnection.sendPacket(new CPacketPlayerDigging(
				Action.STOP_DESTROY_BLOCK, pos, side));
			
			break;
		}
	}
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:29,代码来源:BlockUtils.java

示例13: rightClickBlockLegit

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static boolean rightClickBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec);
		
		// check if hitVec is within range (4.25 blocks)
		if(distanceSqHitVec > 18.0625)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// check line of sight
		if(WMinecraft.getWorld().rayTraceBlocks(eyesPos, hitVec, false,
			true, false) != null)
			continue;
		
		// face block
		if(!RotationUtils.faceVectorPacket(hitVec))
			return true;
		
		// place block
		WPlayerController.processRightClickBlock(pos, side, hitVec);
		WPlayer.swingArmClient();
		mc.rightClickDelayTimer = 4;
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:40,代码来源:BlockUtils.java

示例14: func_190538_a

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Nullable
private Entity func_190538_a(Vec3d p_190538_1_, Vec3d p_190538_2_)
{
    Entity entity = null;
    List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D));
    double d0 = 0.0D;

    for (Entity entity1 : list)
    {
        if (entity1 != this.field_190539_a)
        {
            AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz(0.30000001192092896D);
            RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(p_190538_1_, p_190538_2_);

            if (raytraceresult != null)
            {
                double d1 = p_190538_1_.squareDistanceTo(raytraceresult.hitVec);

                if (d1 < d0 || d0 == 0.0D)
                {
                    entity = entity1;
                    d0 = d1;
                }
            }
        }
    }

    return entity;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:30,代码来源:EntityLlamaSpit.java

示例15: findEntityOnPath

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Nullable
protected Entity findEntityOnPath(Vec3d start, Vec3d end)
{
    Entity entity = null;
    List<Entity> list = this.worldObj.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D), ARROW_TARGETS);
    double d0 = 0.0D;

    for (int i = 0; i < list.size(); ++i)
    {
        Entity entity1 = (Entity)list.get(i);

        if (entity1 != this.shootingEntity || this.ticksInAir >= 5)
        {
            AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz(0.30000001192092896D);
            RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(start, end);

            if (raytraceresult != null)
            {
                double d1 = start.squareDistanceTo(raytraceresult.hitVec);

                if (d1 < d0 || d0 == 0.0D)
                {
                    entity = entity1;
                    d0 = d1;
                }
            }
        }
    }

    return entity;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:EntityArrow.java


注:本文中的net.minecraft.util.math.Vec3d.squareDistanceTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。