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


Java Vec3.addVector方法代碼示例

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


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

示例1: renderBrokenItemStack

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
/**
 * Renders broken item particles using the given ItemStack
 */
public void renderBrokenItemStack(ItemStack stack)
{
    this.playSound("random.break", 0.8F, 0.8F + this.worldObj.rand.nextFloat() * 0.4F);

    for (int i = 0; i < 5; ++i)
    {
        Vec3 vec3 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
        vec3 = vec3.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
        vec3 = vec3.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
        double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
        Vec3 vec31 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
        vec31 = vec31.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
        vec31 = vec31.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
        vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
        this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:EntityLivingBase.java

示例2: getMovingObjectPositionFromPlayer

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
protected MovingObjectPosition getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
{
    float f = playerIn.rotationPitch;
    float f1 = playerIn.rotationYaw;
    double d0 = playerIn.posX;
    double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
    double d2 = playerIn.posZ;
    Vec3 vec3 = new Vec3(d0, d1, d2);
    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    float f6 = f3 * f4;
    float f7 = f2 * f4;
    double d3 = 5.0D;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:19,代碼來源:Item.java

示例3: getMovingObjectPositionFromPlayer

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer player, double targetingDistance)
{
	float f = 1.0F;
	float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
	float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
	
	double playerX = player.prevPosX + (player.posX - player.prevPosX) * f;
	double playerY = player.prevPosY + (player.posY - player.prevPosY) * f + (world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences
	double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
	
	Vec3 vecPlayer = Vec3.createVectorHelper(playerX, playerY, playerZ);
	
	float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
	float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
	float f5 = -MathHelper.cos(-f1 * 0.017453292F);
	float f6 = MathHelper.sin(-f1 * 0.017453292F);
	float f7 = f4 * f5;
	float f8 = f3 * f5;
	
	double maxDistance = targetingDistance;
	
	Vec3 vecTarget = vecPlayer.addVector(f7 * maxDistance, f6 * maxDistance, f8 * maxDistance);
	
	return world.func_147447_a(vecPlayer, vecTarget, false, false, true);	// false, true, false
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:26,代碼來源:AI_Targeting.java

示例4: getObjectMouseOver

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
private MovingObjectPosition getObjectMouseOver(DiscreteMovementCommand command)
{
    MovingObjectPosition mop = null;
    if (command.equals(DiscreteMovementCommand.USE))
        mop = Minecraft.getMinecraft().objectMouseOver;
    else if (command.equals(DiscreteMovementCommand.JUMPUSE))
    {
        long partialTicks = 0;  //Minecraft.timer.renderPartialTicks
        Entity viewer = Minecraft.getMinecraft().thePlayer;
        double blockReach = Minecraft.getMinecraft().playerController.getBlockReachDistance();
        Vec3 eyePos = viewer.getPositionEyes(partialTicks);
        Vec3 lookVec = viewer.getLook(partialTicks);
        int yOffset = 1;    // For the jump
        Vec3 searchVec = eyePos.addVector(lookVec.xCoord * blockReach, yOffset + lookVec.yCoord * blockReach, lookVec.zCoord * blockReach);
        mop = Minecraft.getMinecraft().theWorld.rayTraceBlocks(eyePos, searchVec, false, false, false);
    }
    return mop;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:19,代碼來源:DiscreteMovementCommandsImplementation.java

示例5: updateItemUse

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
/**
 * Plays sounds and makes particles for item in use state
 */
protected void updateItemUse(ItemStack itemStackIn, int p_71010_2_)
{
    if (itemStackIn.getItemUseAction() == EnumAction.DRINK)
    {
        this.playSound("random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }

    if (itemStackIn.getItemUseAction() == EnumAction.EAT)
    {
        for (int i = 0; i < p_71010_2_; ++i)
        {
            Vec3 vec3 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
            vec3 = vec3.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
            vec3 = vec3.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
            double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
            Vec3 vec31 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
            vec31 = vec31.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
            vec31 = vec31.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
            vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);

            if (itemStackIn.getHasSubtypes())
            {
                this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem()), itemStackIn.getMetadata()});
            }
            else
            {
                this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem())});
            }
        }

        this.playSound("random.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:37,代碼來源:EntityPlayer.java

示例6: rayTrace

import net.minecraft.util.Vec3; //導入方法依賴的package包/類
public MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
{
    Vec3 vec3 = this.getPositionEyes(partialTicks);
    Vec3 vec31 = this.getLook(partialTicks);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
    return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:8,代碼來源:Entity.java

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

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