當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。