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


Java Vec3d.addVector方法代码示例

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


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

示例1: rayTrace

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
protected RayTraceResult rayTrace(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;
    Vec3d vec3d = new Vec3d(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;
    Vec3d vec3d1 = vec3d.addVector((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:Item.java

示例2: randomDisplayTick

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
	Vec3d smoke = new Vec3d(pos.getX(), pos.getY() + 1.65, pos.getZ());
	switch (state.getValue(FACING).getHorizontalIndex())
	{
	case 0:
		smoke = smoke.addVector(0.5, 0, 0.6);
		break;
	case 1:
		smoke = smoke.addVector(0.3, 0, 0.5);
		break;
	case 2:
		smoke = smoke.addVector(0.5, 0, 0.3);
		break;
	case 3:
		smoke = smoke.addVector(0.6, 0, 0.5);
		break;
	}
	world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, smoke.x, smoke.y, smoke.z, 0, 0, 0, 0, 0);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:22,代码来源:BlockInfernalSmelter.java

示例3: generateBranch

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private void generateBranch(World world, Random rand, BlockPos trunkPos, Vec3d endPos) {
    Vec3d curr = new Vec3d(trunkPos);
    Vec3d next = next(world, curr, endPos.subtract(curr).normalize(), endPos, trunkPos);
    BlockPos prev;
    do {
        BlockPos currBlock = new BlockPos(curr);
        Vec3d dir = endPos.subtract(curr).normalize();
        prev = currBlock;
        curr = next;
        next = next(world, curr, dir, endPos, trunkPos);

        IBlockState state = (xzEqual(currBlock, trunkPos) ? LOG : LOG.withProperty(BlockLog.LOG_AXIS, getLogAxis(world, currBlock, dir)));
        setBlockInWorld(world, currBlock, state);

        // check to avoid long straight up branches
        BlockPos nextBlock = new BlockPos(next);
        if (endPos.squareDistanceTo(next) > Math.sqrt(3) && xzEqual(prev, currBlock) && xzEqual(currBlock, nextBlock)) {
            next = next.addVector(rand.nextBoolean() ? -1 : 1, 0, rand.nextBoolean() ? -1 : 1);
        }
    } while (endPos.squareDistanceTo(curr) > Math.sqrt(3));

    generateLeaves(world, rand, curr);
    generateLeaves(world, rand, new Vec3d(prev));
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:25,代码来源:WorldGenTreeDryophyllum.java

示例4: rayTraceFromEntity

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private RayTraceResult rayTraceFromEntity(World world, Entity player, boolean par3, double range) {
	
	float f = 1.0F;
	float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
	float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
	double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
	double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
	if (player instanceof EntityPlayer)
		d1 += ((EntityPlayer)player).eyeHeight;
	double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
	Vec3d vec3 = new Vec3d(d0, d1, d2);
	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 d3 = range;
	Vec3d vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
	return world.rayTraceBlocks(vec3, vec31, par3);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:22,代码来源:TileShyPlant.java

示例5: rayTrace

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
protected RayTraceResult rayTrace(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;
    Vec3d vec3d = new Vec3d(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;
    if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
    {
        d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
    }
    Vec3d vec3d1 = vec3d.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:Item.java

示例6: addEntitiesToWorld

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
                worldIn.spawnEntityInWorld(entity);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:39,代码来源:Template.java

示例7: addEntitiesToWorld

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:39,代码来源:HarshenTemplate.java

示例8: setupControlVertices

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * Setup c1 and c2.
 */
private void setupControlVertices()
{
    //Line l1: v1 = p1 + t*d1.
    Vec3d p1 = new Vec3d(a1.x, a1.y, a1.z);
    Vec3d d1 = getDirectionVector(a1, a2);
    //Line l2: v2 = p2 + u*d2.
    Vec3d p2 = new Vec3d(b1.x, b1.y, b1.z);
    Vec3d d2 = getDirectionVector(b1, b2);

    //S is the scalar value that will produce the vertex (a2.x, defaultY, a2.z).
    //Control points work best if they are slightly further away, so multiply scalar by 1.2.
    double s = (defaultY - a1.y) / d1.y;
    double s1 = s * 1.3F;
    double s2 = s * 1.3F;

    //Point on line1 = p1 + scalar*d1
    //Point on line2 = p2 + scalar*d2
    Vec3d cl1 = p1.addVector(d1.x * s1, d1.y * s1, d1.z * s1);
    Vec3d cl2 = p2.addVector(d2.x * s2, d2.y * s2, d2.z * s2);

    //Convert to vertex.
    c1 = new Vertex((float) cl1.x, (float) cl1.y, (float) cl1.z);
    c2 = new Vertex((float) cl2.x, (float) cl2.y, (float) cl2.z);

    groupObj = new BezierGroupObj();
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:30,代码来源:BezierCurve.java

示例9: onExecutionStart

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F);
	Vec3d playerLook = player.getLookVec();
	Vec3d playerPos = player.getPositionVector();
	player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
	AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
	List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
	for (EntityLivingBase ent : lst)
	{
		if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
		{
			continue;
		}
		
		Vec3d ePos = ent.getPositionVector();
		Vec3d player2ent = ePos.subtract(playerPos).normalize();
		float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
		if (angle > 60)
		{
			continue;
		}
		
		ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F));
		player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F);
		if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean())
		{
			ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:35,代码来源:Slash.java

示例10: tracePlayerHighlight

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static RayTraceResult tracePlayerHighlight(EntityPlayerMP player) {
	Vec3d eyes = player.getPositionEyes(1F);
	Vec3d look = player.getLookVec();
	double range = player.interactionManager.getBlockReachDistance();
	Vec3d hit = eyes.addVector(look.x * range, look.y * range, look.z * range);
	return player.world.rayTraceBlocks(eyes, hit, false, false, true);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:8,代码来源:RayTraceHelper.java

示例11: modifyAcceleration

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Override
public Vec3d modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3d vec)
{
    if (densityDir > 0) return vec;
    Vec3d vec_flow = this.getFlowVector(world, pos);
    return vec.addVector(
            vec_flow.xCoord * (quantaPerBlock * 4),
            vec_flow.yCoord * (quantaPerBlock * 4),
            vec_flow.zCoord * (quantaPerBlock * 4));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:BlockFluidBase.java

示例12: rayTrace

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Nullable
@SideOnly(Side.CLIENT)
public static RayTraceResult rayTrace(EntityPlayerSP player, double blockReachDistance, float partialTicks, boolean ignoreNonOpaqueCube) {
  Vec3d vec3d = player.getPositionEyes(partialTicks);
  Vec3d vec3d1 = player.getLook(partialTicks);
  Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * blockReachDistance, vec3d1.yCoord * blockReachDistance, vec3d1.zCoord * blockReachDistance);
  return RayTracer.rayTraceBlocks(player.world, vec3d, vec3d2, ignoreNonOpaqueCube);
}
 
开发者ID:ToroCraft,项目名称:PowerProbe,代码行数:9,代码来源:RayTracer.java

示例13: updateItemUse

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * Plays sounds and makes particles for item in use state
 */
protected void updateItemUse(@Nullable ItemStack stack, int eatingParticleCount)
{
    if (stack != null && this.isHandActive())
    {
        if (stack.getItemUseAction() == EnumAction.DRINK)
        {
            this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
        }

        if (stack.getItemUseAction() == EnumAction.EAT)
        {
            for (int i = 0; i < eatingParticleCount; ++i)
            {
                Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
                vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
                double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
                Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
                vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
                vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);

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

            this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:EntityLivingBase.java

示例14: offsetSoundByName

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private static Vec3d offsetSoundByName(Vec3d soundPos, Vec3d playerPos, String name, String soundCategory)
{
	double offsetX = 0.0;
	double offsetY = 0.0;
	double offsetZ = 0.0;
	
	double offsetTowardsPlayer = 0.0;
	
	Vec3d toPlayerVector = playerPos.subtract(soundPos).normalize();
	
	//names
	if (name.matches(".*step.*"))
	{
		offsetY = 0.1;
	}
	
	//categories
	if (soundCategory.matches("block") || soundCategory.matches("record"))
	{
		offsetTowardsPlayer = 0.89;
	}
	
	if (soundPos.yCoord % 1.0 < 0.001 && soundPos.yCoord > 0.01)
	{
		offsetY = 0.1;
	}
	
	offsetX += toPlayerVector.xCoord * offsetTowardsPlayer;
	offsetY += toPlayerVector.yCoord * offsetTowardsPlayer;
	offsetZ += toPlayerVector.zCoord * offsetTowardsPlayer;
	
	//soundPos.xCoord += offsetX;
	//soundPos.yCoord += offsetY;
	//soundPos.zCoord += offsetZ;
	soundPos = soundPos.addVector(offsetX, offsetY, offsetZ);
	
	//logDetailed("Offset sound by " + offsetX + ", " + offsetY + ", " + offsetZ);
	
	return soundPos;
}
 
开发者ID:sonicether,项目名称:Sound-Physics,代码行数:41,代码来源:SoundPhysics.java

示例15: onExecutionTick

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
	player.rotationYaw += 40;
	Vec3d playerLook = player.getLookVec();
	Vec3d playerPos = player.getPositionVector();
	player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
	AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
	List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
	for (EntityLivingBase ent : lst)
	{
		if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
		{
			continue;
		}
		
		Vec3d ePos = ent.getPositionVector();
		Vec3d player2ent = ePos.subtract(playerPos).normalize();
		float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
		if (angle > 40)
		{
			continue;
		}
		
		player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 0.2F, 1.5F);
		ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75F));
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:29,代码来源:Spin.java


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