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


Java Vec3d.lengthVector方法代码示例

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


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

示例1: rayIntersectsAxisSlider

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * Calculate the distance between the start of the ray and the axis slider.
 * Assumes axis slider starts at origin.
 * @param ray - Ray to test.
 * @param p - End of slider.
 * @param n - Normal to slider.
 * @return - Distance or null if no intersection.
 */
public static Double rayIntersectsAxisSlider(RayTrace ray, Vec3d p, Vec3d n)
{
	Vec3d pI = getRayPlaneIntersection(ray,p,n);
	if(pI == null)
		return null;
	double t = getLineScalarForClosestPoint(new Vec3d(0, 0, 0), p, pI);
	double d;
	if(t < 0)
		d = pI.lengthVector();
	else if(t > 1.0F)
		d = pI.subtract(p).lengthVector();
	else
		d = pI.subtract(scale(p,t)).lengthVector();
	if(d < 0.05F)
		return ray.p0.distanceTo(pI);
	return null;
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:26,代码来源:MathHelper.java

示例2: shouldAttackPlayer

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = (ItemStack)player.inventory.armorInventory.get(3);

    if (itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
    {
        return false;
    }
    else
    {
        Vec3d vec3d = player.getLook(1.0F).normalize();
        Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)this.getEyeHeight() - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec3d1.lengthVector();
        vec3d1 = vec3d1.normalize();
        double d1 = vec3d.dotProduct(vec3d1);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityEnderman.java

示例3: shouldAttackPlayer

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
    {
        return false;
    }
    else
    {
        Vec3d vec3d = player.getLook(1.0F).normalize();
        Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)this.getEyeHeight() - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec3d1.lengthVector();
        vec3d1 = vec3d1.normalize();
        double d1 = vec3d.dotProduct(vec3d1);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:EntityEnderman.java

示例4: isEntityWithinPlayerFOV

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private boolean isEntityWithinPlayerFOV(EntityPlayer player, Entity entity) {
    // code used from the Enderman player looking code.
    Vec3d vec3 = player.getLook(1.0F).normalize();
    Vec3d vec31 = new Vec3d(entity.posX - player.posX, entity.getEntityBoundingBox().minY + entity.height / 2.0F - (player.posY + player.getEyeHeight()), entity.posZ - player.posZ);
    double d0 = vec31.lengthVector();
    vec31 = vec31.normalize();
    double d1 = vec3.dotProduct(vec31);
    return d1 > 1.0D - 2.5D / d0;
    // return d1 > 1.0D - 0.025D / d0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:EntityTrackUpgradeHandler.java

示例5: isPlayerLookingAtTarget

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private boolean isPlayerLookingAtTarget() {
    // code used from the Enderman player looking code.
    EntityPlayer player = FMLClientHandler.instance().getClient().player;
    World world = FMLClientHandler.instance().getClient().world;
    Vec3d vec3 = player.getLook(1.0F).normalize();
    Vec3d vec31 = new Vec3d(entity.posX - player.posX, entity.getEntityBoundingBox().minY + entity.height / 2.0F - (player.posY + player.getEyeHeight()), entity.posZ - player.posZ);
    double d0 = vec31.lengthVector();
    vec31 = vec31.normalize();
    double d1 = vec3.dotProduct(vec31);
    return d1 > 1.0D - 0.050D / d0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:RenderTarget.java

示例6: isPlayerLookingAtTarget

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private boolean isPlayerLookingAtTarget() {
    Vec3d vec3 = player.getLook(1.0F).normalize();
    Vec3d vec31 = new Vec3d(pos.getX() + 0.5D - player.posX, pos.getY() + 0.5D - player.posY - player.getEyeHeight(), pos.getZ() + 0.5D - player.posZ);
    double d0 = vec31.lengthVector();
    vec31 = vec31.normalize();
    double d1 = vec3.dotProduct(vec31);
    return d1 > 1.0D - 0.025D / d0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:RenderBlockTarget.java

示例7: shouldAttackPlayer

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private boolean shouldAttackPlayer(EntityPlayer player) {
	ItemStack itemstack = player.inventory.armorInventory.get(3);

	if (itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN) || itemstack.getItem() instanceof ItemSkullBase) {
		return false;
	}
	else {
		Vec3d vec3d = player.getLook(1.0F).normalize();
		Vec3d vec3d1 = new Vec3d(posX - player.posX, getEntityBoundingBox().minY + getEyeHeight() - (player.posY + player.getEyeHeight()), posZ - player.posZ);
		double d0 = vec3d1.lengthVector();
		vec3d1 = vec3d1.normalize();
		double d1 = vec3d.dotProduct(vec3d1);
		return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:16,代码来源:EntityEvolvedEnderman.java

示例8: acquireAllLookTargets

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private List<EntityLivingBase> acquireAllLookTargets(EntityLivingBase seeker, int distance, double radius) {
	
	if (distance < 0 || distance > MAX_DISTANCE) {
		distance = MAX_DISTANCE;
	}
	List<EntityLivingBase> targets = new ArrayList<EntityLivingBase>();
	Vec3d vec3 = seeker.getLookVec();
	double targetX = seeker.posX;
	double targetY = seeker.posY + seeker.getEyeHeight() - 0.10000000149011612D;
	double targetZ = seeker.posZ;
	double distanceTraveled = 0;

	while ((int) distanceTraveled < distance) {
		targetX += vec3.xCoord;
		targetY += vec3.yCoord;
		targetZ += vec3.zCoord;
		distanceTraveled += vec3.lengthVector();
		AxisAlignedBB bb = new AxisAlignedBB(targetX-radius, targetY-radius, targetZ-radius, targetX+radius, targetY+radius, targetZ+radius);
		List<EntityLivingBase> list = seeker.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb);
		for (EntityLivingBase target : list) {
			if (target != seeker && target.canBeCollidedWith() && isTargetInSight(vec3, seeker, target)) {
				if (!targets.contains(target)) {
					targets.add(target);
				}
			}
		}
	}
	return targets;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:30,代码来源:ItemEnderSnooker.java

示例9: isLyingInCone

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * @param x coordinates of point to be tested 
 * @param t coordinates of apex point of cone
 * @param b coordinates of center of basement circle
 * @param aperture in radians
 */
static public boolean isLyingInCone(Vec3d x, Vec3d start, Vec3d end, 
                                    float aperture){

    // This is for our convenience
    float halfAperture = aperture/2.f;

    // Vector pointing to X point from apex
    Vec3d apexToXVect = start.subtract(x);

    // Vector pointing from apex to circle-center point.
    Vec3d axisVect = start.subtract(end);

    // X is lying in cone only if it's lying in 
    // infinite version of its cone -- that is, 
    // not limited by "round basement".
    // We'll use dotProd() to 
    // determine angle between apexToXVect and axis.
    boolean isInInfiniteCone = apexToXVect.dotProduct(axisVect)
                               /apexToXVect.lengthVector()/axisVect.lengthVector()
                                 >
                               // We can safely compare cos() of angles 
                               // between vectors instead of bare angles.
                               MathHelper.cos(halfAperture);


    return isInInfiniteCone;

    // X is contained in cone only if projection of apexToXVect to axis
    // is shorter than axis. 
    // We'll use dotProd() to figure projection length.
   /* boolean isUnderRoundCap = dotProd(apexToXVect,axisVect)
                              /magn(axisVect)
                                <
                              magn(axisVect);
    return isUnderRoundCap;*/
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:43,代码来源:TF2Util.java

示例10: handleMaterialAcceleration

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * handles the acceleration of an object whilst in water. Not sure if it is used elsewhere.
 */
public boolean handleMaterialAcceleration(AxisAlignedBB bb, Material materialIn, Entity entityIn)
{
    int i = MathHelper.floor(bb.minX);
    int j = MathHelper.ceil(bb.maxX);
    int k = MathHelper.floor(bb.minY);
    int l = MathHelper.ceil(bb.maxY);
    int i1 = MathHelper.floor(bb.minZ);
    int j1 = MathHelper.ceil(bb.maxZ);

    if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        return false;
    }
    else
    {
        boolean flag = false;
        Vec3d vec3d = Vec3d.ZERO;
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

        for (int k1 = i; k1 < j; ++k1)
        {
            for (int l1 = k; l1 < l; ++l1)
            {
                for (int i2 = i1; i2 < j1; ++i2)
                {
                    blockpos$pooledmutableblockpos.setPos(k1, l1, i2);
                    IBlockState iblockstate = this.getBlockState(blockpos$pooledmutableblockpos);
                    Block block = iblockstate.getBlock();

                    if (iblockstate.getMaterial() == materialIn)
                    {
                        double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));

                        if ((double)l >= d0)
                        {
                            flag = true;
                            vec3d = block.modifyAcceleration(this, blockpos$pooledmutableblockpos, entityIn, vec3d);
                        }
                    }
                }
            }
        }

        blockpos$pooledmutableblockpos.release();

        if (vec3d.lengthVector() > 0.0D && entityIn.isPushedByWater())
        {
            vec3d = vec3d.normalize();
            double d1 = 0.014D;
            entityIn.motionX += vec3d.xCoord * 0.014D;
            entityIn.motionY += vec3d.yCoord * 0.014D;
            entityIn.motionZ += vec3d.zCoord * 0.014D;
        }

        return flag;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:61,代码来源:World.java

示例11: handleMaterialAcceleration

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * handles the acceleration of an object whilst in water. Not sure if it is used elsewhere.
 */
public boolean handleMaterialAcceleration(AxisAlignedBB bb, Material materialIn, Entity entityIn)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.ceiling_double_int(bb.maxX);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.ceiling_double_int(bb.maxY);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.ceiling_double_int(bb.maxZ);

    if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        return false;
    }
    else
    {
        boolean flag = false;
        Vec3d vec3d = Vec3d.ZERO;
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

        for (int k1 = i; k1 < j; ++k1)
        {
            for (int l1 = k; l1 < l; ++l1)
            {
                for (int i2 = i1; i2 < j1; ++i2)
                {
                    blockpos$pooledmutableblockpos.setPos(k1, l1, i2);
                    IBlockState iblockstate = this.getBlockState(blockpos$pooledmutableblockpos);
                    Block block = iblockstate.getBlock();

                    Boolean result = block.isEntityInsideMaterial(this, blockpos$pooledmutableblockpos, iblockstate, entityIn, (double)l, materialIn, false);
                    if (result != null && result == true)
                    {
                        // Forge: When requested call blocks modifyAcceleration method, and more importantly cause this method to return true, which results in an entity being "inWater"
                        flag = true;
                        vec3d = block.modifyAcceleration(this, blockpos$pooledmutableblockpos, entityIn, vec3d);
                        continue;
                    }
                    else if (result != null && result == false) continue;

                    if (iblockstate.getMaterial() == materialIn)
                    {
                        double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));

                        if ((double)l >= d0)
                        {
                            flag = true;
                            vec3d = block.modifyAcceleration(this, blockpos$pooledmutableblockpos, entityIn, vec3d);
                        }
                    }
                }
            }
        }

        blockpos$pooledmutableblockpos.release();

        if (vec3d.lengthVector() > 0.0D && entityIn.isPushedByWater())
        {
            vec3d = vec3d.normalize();
            double d1 = 0.014D;
            entityIn.motionX += vec3d.xCoord * 0.014D;
            entityIn.motionY += vec3d.yCoord * 0.014D;
            entityIn.motionZ += vec3d.zCoord * 0.014D;
        }

        return flag;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:71,代码来源:World.java


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