當前位置: 首頁>>代碼示例>>Java>>正文


Java Vec3d.add方法代碼示例

本文整理匯總了Java中net.minecraft.util.math.Vec3d.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Vec3d.add方法的具體用法?Java Vec3d.add怎麽用?Java Vec3d.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.math.Vec3d的用法示例。


在下文中一共展示了Vec3d.add方法的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: FireBall

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
public static Object FireBall(Object... args) {

        ScriptExecutor executor = (ScriptExecutor)args[0];

        Vec3d look = (Vec3d)executor.resolveInput((short)1);
        Double speed = (Double)executor.resolveInput((short)2);
        Vec3d initPos = (Vec3d)executor.resolveInput((short)3);
        Vec3d initPosRel = (Vec3d)executor.resolveInput((short)4);

        if (look == null) {
            look = executor.player.getLookVec();
        }
        if (speed == null) {
            speed = 0.1;
        }
        if (initPos == null) {
            if(initPosRel==null)
                initPos = executor.player.getPositionEyes(1.0F).add(executor.player.getLookVec().scale(2));
            else
                initPos = initPosRel.add(executor.player.getPositionVector());
        }

        look = look.scale(speed);

        EntityLargeFireball fireball = new EntityLargeSettableFireball(executor.player.worldObj, initPos.xCoord,
                                                                        initPos.yCoord, initPos.zCoord,
                                                                        look.xCoord, look.yCoord,
                                                                        look.zCoord);

        executor.player.worldObj.spawnEntityInWorld(fireball);

        executor.resolveOutput((short)5, true);
        return true;
    }
 
開發者ID:Drazuam,項目名稱:RunicArcana,代碼行數:35,代碼來源:DustSymbolFireball.java

示例3: placeBlockSimple

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
public static boolean placeBlockSimple(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	
	for(EnumFacing side : EnumFacing.values())
	{
		BlockPos neighbor = pos.offset(side);
		
		// check if neighbor can be right clicked
		if(!WBlock.canBeClicked(neighbor))
			continue;
		
		Vec3d hitVec =
			posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5));
		
		// check if hitVec is within range (6 blocks)
		if(eyesPos.squareDistanceTo(hitVec) > 36)
			continue;
		
		// place block
		WPlayerController.processRightClickBlock(neighbor,
			side.getOpposite(), hitVec);
		
		return true;
	}
	
	return false;
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:30,代碼來源:BlockUtils.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: rightClickBlockSimple

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
public static boolean rightClickBlockSimple(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;
		
		// place block
		WPlayerController.processRightClickBlock(pos, side, hitVec);
		
		return true;
	}
	
	return false;
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:29,代碼來源:BlockUtils.java

示例10: canSee

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
/**
 * checking if two Vec3d can see each other (there are not any block between)
 *
 * the started pos can be likely to:
 *                   for block: new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)
 *                   for entity: entity.getPositionVector().addVector(0, entity.getEyeHeight(), 0);
 *
 * @return if can see each other
 */
public static boolean canSee(World world, Vec3d traceStart, Vec3d traceEnd) {
    Vec3d vecDelta = new Vec3d(
            traceEnd.x - traceStart.x,
            traceEnd.y - traceStart.y,
            traceEnd.z - traceStart.z
    );

    // Normalize vector to the largest delta axis
    double vecDeltaLength = MathHelper.absMax(vecDelta.x, MathHelper.absMax(vecDelta.y, vecDelta.z));

    vecDelta = vecDelta.scale(1 / vecDeltaLength);

    // Limit how many non solid block a turret can see through
    for (int i = 0; i < 10; i++) {
        // Offset start position toward the target to prevent self collision
        traceStart = traceStart.add(vecDelta);

        RayTraceResult traced = world.rayTraceBlocks(traceStart.add(Vec3d.ZERO), traceEnd.add(Vec3d.ZERO));

        if (traced != null && traced.typeOfHit == RayTraceResult.Type.BLOCK) {
            IBlockState hitBlock = world.getBlockState(traced.getBlockPos());

            // If non solid block is in the way then proceed to continue
            // tracing
            if (hitBlock != null && !hitBlock.getMaterial().isSolid() && MathHelper.absMax(
                    MathHelper.absMax(traceStart.x - traceEnd.x, traceStart.y - traceEnd.y),
                    traceStart.z - traceEnd.z) > 1) {
                // Start at new position and continue
                traceStart = traced.hitVec;
                continue;
            }
        }
        return traced != null;
    }

    // If all above failed, the target cannot be seen
    return false;
}
 
開發者ID:MinecraftPangu,項目名稱:Pangu,代碼行數:48,代碼來源:AIUtils.java

示例11: findExitPortal

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
private void findExitPortal()
{
    Vec3d vec3d = (new Vec3d((double)this.getPos().getX(), 0.0D, (double)this.getPos().getZ())).normalize();
    Vec3d vec3d1 = vec3d.scale(1024.0D);

    for (int i = 16; getChunk(this.world, vec3d1).getTopFilledSegment() > 0 && i-- > 0; vec3d1 = vec3d1.add(vec3d.scale(-16.0D)))
    {
        LOG.debug("Skipping backwards past nonempty chunk at {}", new Object[] {vec3d1});
    }

    for (int j = 16; getChunk(this.world, vec3d1).getTopFilledSegment() == 0 && j-- > 0; vec3d1 = vec3d1.add(vec3d.scale(16.0D)))
    {
        LOG.debug("Skipping forward past empty chunk at {}", new Object[] {vec3d1});
    }

    LOG.debug("Found chunk at {}", new Object[] {vec3d1});
    Chunk chunk = getChunk(this.world, vec3d1);
    this.exitPortal = findSpawnpointInChunk(chunk);

    if (this.exitPortal == null)
    {
        this.exitPortal = new BlockPos(vec3d1.xCoord + 0.5D, 75.0D, vec3d1.zCoord + 0.5D);
        LOG.debug("Failed to find suitable block, settling on {}", new Object[] {this.exitPortal});
        (new WorldGenEndIsland()).generate(this.world, new Random(this.exitPortal.toLong()), this.exitPortal);
    }
    else
    {
        LOG.debug("Found block at {}", new Object[] {this.exitPortal});
    }

    this.exitPortal = findHighestBlock(this.world, this.exitPortal, 16, true);
    LOG.debug("Creating portal at {}", new Object[] {this.exitPortal});
    this.exitPortal = this.exitPortal.up(10);
    this.createExitPortal(this.exitPortal);
    this.markDirty();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:37,代碼來源:TileEntityEndGateway.java

示例12: performBlink

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
public static boolean performBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight() - 0.08, + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
            movePlayer(end, player, true);
            return true;
        }
        else {

            List<BlockPos> empty = getBlinkPositions(res, eye, end, distance, world);
            if(empty.size() == 0) {
                return false;
            }

            BlockPos target = empty.get(empty.size() / 2);

            if(target != null) {
                movePlayer(new Vec3d(target.getX() + 0.5, target.getY(), target.getZ() + 0.5), player, false);
                return true;
            }
        }

        return false;
    }
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:29,代碼來源:TeleportUtil.java

示例13: findExitPortal

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
private void findExitPortal()
{
    Vec3d vec3d = (new Vec3d((double)this.getPos().getX(), 0.0D, (double)this.getPos().getZ())).normalize();
    Vec3d vec3d1 = vec3d.scale(1024.0D);

    for (int i = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() > 0 && i-- > 0; vec3d1 = vec3d1.add(vec3d.scale(-16.0D)))
    {
        LOG.debug("Skipping backwards past nonempty chunk at {}", new Object[] {vec3d1});
    }

    for (int j = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() == 0 && j-- > 0; vec3d1 = vec3d1.add(vec3d.scale(16.0D)))
    {
        LOG.debug("Skipping forward past empty chunk at {}", new Object[] {vec3d1});
    }

    LOG.debug("Found chunk at {}", new Object[] {vec3d1});
    Chunk chunk = getChunk(this.worldObj, vec3d1);
    this.exitPortal = findSpawnpointInChunk(chunk);

    if (this.exitPortal == null)
    {
        this.exitPortal = new BlockPos(vec3d1.xCoord + 0.5D, 75.0D, vec3d1.zCoord + 0.5D);
        LOG.debug("Failed to find suitable block, settling on {}", new Object[] {this.exitPortal});
        (new WorldGenEndIsland()).generate(this.worldObj, new Random(this.exitPortal.toLong()), this.exitPortal);
    }
    else
    {
        LOG.debug("Found block at {}", new Object[] {this.exitPortal});
    }

    this.exitPortal = findHighestBlock(this.worldObj, this.exitPortal, 16, true);
    LOG.debug("Creating portal at {}", new Object[] {this.exitPortal});
    this.exitPortal = this.exitPortal.up(10);
    this.createExitPortal(this.exitPortal);
    this.markDirty();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:37,代碼來源:TileEntityEndGateway.java

示例14: getFluidCostBlink

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
public static int getFluidCostBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight(), + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
           return 0;
        }
        else {
            return ItemTransporter.teleportFluidBlinkCost;
        }
    }
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:15,代碼來源:TeleportUtil.java

示例15: getImpactPos

import net.minecraft.util.math.Vec3d; //導入方法依賴的package包/類
/**
 * Find the position the arrows trajectory will hit
 */
public static Vec3d getImpactPos(ItemStack itemStack, Vec3d initPos, Vec3d hitPos, Angle angle) {
    double force = getForce(itemStack);

    Angle initAngle = new Angle(-angle.getPitch(), angle.getYaw() + 90.D, 0);

    double fixX = Math.cos(initAngle.getYaw(true) - Math.PI / 2.0) * 0.16;
    double fixY = PROJECTILE_SHOOTPOS_OFFSET;
    double fixZ = Math.sin(initAngle.getYaw(true) - Math.PI / 2.0) * 0.16;

    initPos = initPos.subtract(fixX, fixY, fixZ);

    Vec3d velocity = initAngle.getCartesianCoords().normalize().scale(force);

    Vec3d acceleration = getGravity(itemStack);
    Vec3d airResistance = getAirResistance(itemStack);

    double bestDistance = -1;
    Vec3d startPos = VectorUtils.copy(initPos);
    Vec3d endPos = VectorUtils.copy(startPos);
    for(int i = 1; i < SIMULATION_ITERATIONS; i++) {
        // add velocity
        startPos = startPos.add(velocity);
        // add air resistance
        velocity = VectorUtils.multiplyBy(velocity, airResistance);
        // add gravity (acceleration)
        velocity = velocity.add(acceleration);

        double x = startPos.x - hitPos.x;
        double z = startPos.z - hitPos.z;

        double distance = x*x + z*z;
        if(distance == -1 || distance < bestDistance)
            bestDistance = distance;
        else
            break;
        endPos = VectorUtils.copy(startPos);
    }

    RayTraceResult trace = MC.world.rayTraceBlocks(startPos, endPos);
    if(trace != null &&
            trace.typeOfHit.equals(RayTraceResult.Type.BLOCK))
        return trace.hitVec;
    else
        return initPos;
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:49,代碼來源:ProjectileUtils.java


注:本文中的net.minecraft.util.math.Vec3d.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。