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


Java Vec3.normalize方法代碼示例

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


在下文中一共展示了Vec3.normalize方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldAttackPlayer

import net.minecraft.util.Vec3; //導入方法依賴的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
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:EntityEnderman.java

示例2: teleportToEntity

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
/**
 * Teleport the enderman to another entity
 */
protected boolean teleportToEntity(Entity p_70816_1_)
{
    Vec3 vec3 = new Vec3(this.posX - p_70816_1_.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - p_70816_1_.posY + (double)p_70816_1_.getEyeHeight(), this.posZ - p_70816_1_.posZ);
    vec3 = vec3.normalize();
    double d0 = 16.0D;
    double d1 = this.posX + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.xCoord * d0;
    double d2 = this.posY + (double)(this.rand.nextInt(16) - 8) - vec3.yCoord * d0;
    double d3 = this.posZ + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.zCoord * d0;
    return this.teleportTo(d1, d2, d3);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:14,代碼來源:EntityEnderman.java

示例3: handleMaterialAcceleration

import net.minecraft.util.Vec3; //導入方法依賴的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.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

    if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        return false;
    }
    else
    {
        boolean flag = false;
        Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

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

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

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

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

        return flag;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:59,代碼來源:World.java

示例4: getFlowVector

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
protected Vec3 getFlowVector(IBlockAccess worldIn, BlockPos pos)
{
    Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
    int i = this.getEffectiveFlowDecay(worldIn, pos);

    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        BlockPos blockpos = pos.offset(enumfacing);
        int j = this.getEffectiveFlowDecay(worldIn, blockpos);

        if (j < 0)
        {
            if (!worldIn.getBlockState(blockpos).getBlock().getMaterial().blocksMovement())
            {
                j = this.getEffectiveFlowDecay(worldIn, blockpos.down());

                if (j >= 0)
                {
                    int k = j - (i - 8);
                    vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * k), (double)((blockpos.getY() - pos.getY()) * k), (double)((blockpos.getZ() - pos.getZ()) * k));
                }
            }
        }
        else if (j >= 0)
        {
            int l = j - i;
            vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * l), (double)((blockpos.getY() - pos.getY()) * l), (double)((blockpos.getZ() - pos.getZ()) * l));
        }
    }

    if (((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() >= 8)
    {
        for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL)
        {
            BlockPos blockpos1 = pos.offset(enumfacing1);

            if (this.isBlockSolid(worldIn, blockpos1, enumfacing1) || this.isBlockSolid(worldIn, blockpos1.up(), enumfacing1))
            {
                vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
                break;
            }
        }
    }

    return vec3.normalize();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:47,代碼來源:BlockLiquid.java

示例5: setVelocity

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
public void setVelocity(Vec3 vDir, float v) {
	vDir.normalize();
	this.setVelocity(v * vDir.xCoord, v * vDir.yCoord, v * vDir.zCoord );
}
 
開發者ID:Kanbe-Kotori,項目名稱:ExtraAcC,代碼行數:5,代碼來源:EntityUpdraft.java

示例6: getFlowVector

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
protected Vec3 getFlowVector(IBlockAccess worldIn, BlockPos pos)
{
    Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
    int i = this.getEffectiveFlowDecay(worldIn, pos);

    for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL)
    {
        EnumFacing enumfacing = (EnumFacing) enumfacing0;
        BlockPos blockpos = pos.offset(enumfacing);
        int j = this.getEffectiveFlowDecay(worldIn, blockpos);

        if (j < 0)
        {
            if (!worldIn.getBlockState(blockpos).getBlock().getMaterial().blocksMovement())
            {
                j = this.getEffectiveFlowDecay(worldIn, blockpos.down());

                if (j >= 0)
                {
                    int k = j - (i - 8);
                    vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * k), (double)((blockpos.getY() - pos.getY()) * k), (double)((blockpos.getZ() - pos.getZ()) * k));
                }
            }
        }
        else if (j >= 0)
        {
            int l = j - i;
            vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * l), (double)((blockpos.getY() - pos.getY()) * l), (double)((blockpos.getZ() - pos.getZ()) * l));
        }
    }

    if (((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() >= 8)
    {
        for (Object enumfacing10 : EnumFacing.Plane.HORIZONTAL)
        {
            EnumFacing enumfacing1 = (EnumFacing) enumfacing10;
            BlockPos blockpos1 = pos.offset(enumfacing1);

            if (this.isBlockSolid(worldIn, blockpos1, enumfacing1) || this.isBlockSolid(worldIn, blockpos1.up(), enumfacing1))
            {
                vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
                break;
            }
        }
    }

    return vec3.normalize();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:49,代碼來源:BlockLiquid.java


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