当前位置: 首页>>代码示例>>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;未经允许,请勿转载。