Package net.minecraft.util

Examples of net.minecraft.util.Vec3


        }
    }

    public Vertex calculateFaceNormal()
    {
        Vec3 v1 = Vec3.createVectorHelper(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y, vertices[1].z - vertices[0].z);
        Vec3 v2 = Vec3.createVectorHelper(vertices[2].x - vertices[0].x, vertices[2].y - vertices[0].y, vertices[2].z - vertices[0].z);
        Vec3 normalVector = null;

        normalVector = v1.crossProduct(v2).normalize();

        return new Vertex((float) normalVector.xCoord, (float) normalVector.yCoord, (float) normalVector.zCoord);
    }
View Full Code Here


    @Override
    public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec)
    {
        if (densityDir > 0) return;
        Vec3 vec_flow = this.getFlowVector(world, x, y, z);
        vec.xCoord += vec_flow.xCoord * (quantaPerBlock * 4);
        vec.yCoord += vec_flow.yCoord * (quantaPerBlock * 4);
        vec.zCoord += vec_flow.zCoord * (quantaPerBlock * 4);
    }
View Full Code Here

        Block block = world.getBlock(x, y, z);
        if (!block.getMaterial().isLiquid())
        {
            return -1000.0;
        }
        Vec3 vec = ((BlockFluidBase) block).getFlowVector(world, x, y, z);
        return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D;
    }
View Full Code Here

        return quantaRemaining / quantaPerBlockFloat;
    }

    public Vec3 getFlowVector(IBlockAccess world, int x, int y, int z)
    {
        Vec3 vec = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
        int decay = quantaPerBlock - getQuantaValue(world, x, y, z);

        for (int side = 0; side < 4; ++side)
        {
            int x2 = x;
            int z2 = z;

            switch (side)
            {
                case 0: --x2; break;
                case 1: --z2; break;
                case 2: ++x2; break;
                case 3: ++z2; break;
            }

            int otherDecay = quantaPerBlock - getQuantaValue(world, x2, y, z2);
            if (otherDecay >= quantaPerBlock)
            {
                if (!world.getBlock(x2, y, z2).getMaterial().blocksMovement())
                {
                    otherDecay = quantaPerBlock - getQuantaValue(world, x2, y - 1, z2);
                    if (otherDecay >= 0)
                    {
                        int power = otherDecay - (decay - quantaPerBlock);
                        vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power);
                    }
                }
            }
            else if (otherDecay >= 0)
            {
                int power = otherDecay - decay;
                vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power);
            }
        }

        if (world.getBlock(x, y + 1, z) == this)
        {
            boolean flag =
                isBlockSolid(world, x,     y,     z - 1, 2) ||
                isBlockSolid(world, x,     y,     z + 1, 3) ||
                isBlockSolid(world, x - 1, y,     z,     4) ||
                isBlockSolid(world, x + 1, y,     z,     5) ||
                isBlockSolid(world, x,     y + 1, z - 1, 2) ||
                isBlockSolid(world, x,     y + 1, z + 1, 3) ||
                isBlockSolid(world, x - 1, y + 1, z,     4) ||
                isBlockSolid(world, x + 1, y + 1, z,     5);

            if (flag)
            {
                vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D);
            }
        }
        vec = vec.normalize();
        return vec;
    }
View Full Code Here

        float var5 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * var4;
        float var6 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * var4;
        double var7 = player.prevPosX + (player.posX - player.prevPosX) * var4;
        double var9 = player.prevPosY + (player.posY - player.prevPosY) * var4 + 1.62D - player.yOffset;
        double var11 = player.prevPosZ + (player.posZ - player.prevPosZ) * var4;
        Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
        float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
        float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
        float var16 = -MathHelper.cos(-var5 * 0.017453292F);
        float var17 = MathHelper.sin(-var5 * 0.017453292F);
        float var18 = var15 * var16;
        float var20 = var14 * var16;
        double var21 = 500D;
        Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);

        MovingObjectPosition mo = player.worldObj.rayTraceBlocks(var13, var23);

        if (mo == null)
        {
View Full Code Here

  public static MovingObjectPosition rayTrace(EntityPlayer player, float partialTicks) {
    Attachments.playerLocal.set(player);
    double range = ((player.worldObj.isRemote)
        ? Minecraft.getMinecraft().playerController.getBlockReachDistance()
        : ((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance());
    Vec3 start = Vec3.createVectorHelper(player.posX, player.posY + 1.62 - player.yOffset, player.posZ);
    Vec3 look = player.getLook(1.0F);
    Vec3 end = start.addVector(look.xCoord * range, look.yCoord * range, look.zCoord * range);
    MovingObjectPosition target = player.worldObj.rayTraceBlocks(start, end);
    Attachments.playerLocal.remove();
    return target;
  }
View Full Code Here

      return false;

    if (!mob.getEntitySenses().canSee(player))
      return false;

    Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
        Vec3.createVectorHelper(player.posX, player.posY, player.posZ));

    if (randomTarget == null)
      return false;
View Full Code Here

    TileEntity tile = world.getTileEntity(x, y, z);
    if(tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe)tile).pipe instanceof PipeBlockRequestTable) {
      this.setBlockBoundsBasedOnState(world, x, y, z);
      origin = origin.addVector(( -x), ( -y), ( -z));
      direction = direction.addVector(( -x), ( -y), ( -z));
      Vec3 vec32 = origin.getIntermediateWithXValue(direction, this.minX);
      Vec3 vec33 = origin.getIntermediateWithXValue(direction, this.maxX);
      Vec3 vec34 = origin.getIntermediateWithYValue(direction, this.minY);
      Vec3 vec35 = origin.getIntermediateWithYValue(direction, this.maxY);
      Vec3 vec36 = origin.getIntermediateWithZValue(direction, this.minZ);
      Vec3 vec37 = origin.getIntermediateWithZValue(direction, this.maxZ);
      if( !this.isVecInsideYZBounds(vec32)) {
        vec32 = null;
      }
      if( !this.isVecInsideYZBounds(vec33)) {
        vec33 = null;
      }
      if( !this.isVecInsideXZBounds(vec34)) {
        vec34 = null;
      }
      if( !this.isVecInsideXZBounds(vec35)) {
        vec35 = null;
      }
      if( !this.isVecInsideXYBounds(vec36)) {
        vec36 = null;
      }
      if( !this.isVecInsideXYBounds(vec37)) {
        vec37 = null;
      }
      Vec3 vec38 = null;
      if(vec32 != null && (vec38 == null || origin.squareDistanceTo(vec32) < origin.squareDistanceTo(vec38))) {
        vec38 = vec32;
      }
      if(vec33 != null && (vec38 == null || origin.squareDistanceTo(vec33) < origin.squareDistanceTo(vec38))) {
        vec38 = vec33;
      }
      if(vec34 != null && (vec38 == null || origin.squareDistanceTo(vec34) < origin.squareDistanceTo(vec38))) {
        vec38 = vec34;
      }
      if(vec35 != null && (vec38 == null || origin.squareDistanceTo(vec35) < origin.squareDistanceTo(vec38))) {
        vec38 = vec35;
      }
      if(vec36 != null && (vec38 == null || origin.squareDistanceTo(vec36) < origin.squareDistanceTo(vec38))) {
        vec38 = vec36;
      }
      if(vec37 != null && (vec38 == null || origin.squareDistanceTo(vec37) < origin.squareDistanceTo(vec38))) {
        vec38 = vec37;
      }
      if(vec38 == null) {
        return null;
      } else {
        byte b0 = -1;
        if(vec38 == vec32) {
          b0 = 4;
        }
        if(vec38 == vec33) {
          b0 = 5;
        }
        if(vec38 == vec34) {
          b0 = 0;
        }
        if(vec38 == vec35) {
          b0 = 1;
        }
        if(vec38 == vec36) {
          b0 = 2;
        }
        if(vec38 == vec37) {
          b0 = 3;
        }
        return new MovingObjectPosition(x, y, z, b0, vec38.addVector(x, y, z));
      }
    }
    RaytraceResult raytraceResult = doRayTrace(world, x, y, z, origin, direction);

    if (raytraceResult == null) {
View Full Code Here

    if (player instanceof EntityPlayerMP) {
      reachDistance = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
    }

    double eyeHeight = world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight();
    Vec3 lookVec = player.getLookVec();
    Vec3 origin = Vec3.createVectorHelper(player.posX, player.posY + eyeHeight, player.posZ);
    Vec3 direction = origin.addVector(lookVec.xCoord * reachDistance, lookVec.yCoord * reachDistance, lookVec.zCoord * reachDistance);

    return doRayTrace(world, x, y, z, origin, direction);
  }
View Full Code Here

  }

  @Override
  public ItemStack pickItem(MovingObjectPosition hit)
  {
    Vec3 v3 = hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ );
    SelectedPart sp = cb.selectPart( v3 );
    if ( sp != null )
    {
      if ( sp.part != null )
        return sp.part.getItemStack( PartItemStack.Break );
View Full Code Here

TOP

Related Classes of net.minecraft.util.Vec3

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.